// ** React Imports import { useState } from 'react' // ** Third Party Components import PerfectScrollbar from 'react-perfect-scrollbar' // ** MUI Imports import Radio from '@mui/material/Radio' import Switch from '@mui/material/Switch' import Divider from '@mui/material/Divider' import { styled } from '@mui/material/styles' import IconButton from '@mui/material/IconButton' import RadioGroup from '@mui/material/RadioGroup' import Typography from '@mui/material/Typography' import Box, { BoxProps } from '@mui/material/Box' import FormControlLabel from '@mui/material/FormControlLabel' import MuiDrawer, { DrawerProps } from '@mui/material/Drawer' // ** Icon Imports import Icon from 'src/@core/components/icon' // ** Type Import import { Settings } from 'src/@core/context/settingsContext' // ** Hook Import import { useSettings } from 'src/@core/hooks/useSettings' const Toggler = styled(Box)(({ theme }) => ({ right: 0, top: '50%', display: 'flex', cursor: 'pointer', position: 'fixed', zIndex: theme.zIndex.modal, padding: theme.spacing(2.5), transform: 'translateY(-50%)', color: theme.palette.common.white, backgroundColor: theme.palette.primary.main, borderTopLeftRadius: theme.shape.borderRadius, borderBottomLeftRadius: theme.shape.borderRadius })) const Drawer = styled(MuiDrawer)(({ theme }) => ({ width: 400, zIndex: theme.zIndex.modal, '& .MuiFormControlLabel-root': { marginRight: '0.6875rem' }, '& .MuiDrawer-paper': { border: 0, width: 400, zIndex: theme.zIndex.modal, boxShadow: theme.shadows[9] } })) const CustomizerSpacing = styled('div')(({ theme }) => ({ padding: theme.spacing(5, 6) })) const ColorBox = styled(Box)(({ theme }) => ({ width: 40, height: 40, display: 'flex', borderRadius: 8, cursor: 'pointer', alignItems: 'center', justifyContent: 'center', margin: theme.spacing(0, 1.5), color: theme.palette.common.white, transition: 'box-shadow .25s ease' })) const Customizer = () => { // ** State const [open, setOpen] = useState(false) // ** Hook const { settings, saveSettings } = useSettings() // ** Vars const { mode, skin, appBar, footer, layout, navHidden, direction, appBarBlur, themeColor, navCollapsed, contentWidth, verticalNavToggleType } = settings const handleChange = (field: keyof Settings, value: Settings[keyof Settings]): void => { saveSettings({ ...settings, [field]: value }) } return (
setOpen(true)}> theme.spacing(3.5, 5), borderBottom: theme => `1px solid ${theme.palette.divider}` }} > Theme Customizer Customize & Preview in Real Time setOpen(false)} sx={{ right: 20, top: '50%', position: 'absolute', color: 'text.secondary', transform: 'translateY(-50%)' }} > Theming {/* Skin */} Skin handleChange('skin', e.target.value as Settings['skin'])} sx={{ '& .MuiFormControlLabel-label': { fontSize: '.875rem', color: 'text.secondary' } }} > } /> } /> {/* Mode */} Mode handleChange('mode', e.target.value as any)} sx={{ '& .MuiFormControlLabel-label': { fontSize: '.875rem', color: 'text.secondary' } }} > } /> } /> {layout === 'horizontal' ? null : ( } /> )} {/* Color Picker */}
Primary Color handleChange('themeColor', 'primary')} sx={{ ml: 0, backgroundColor: '#666CFF', ...(themeColor === 'primary' ? { boxShadow: 9 } : { '&:hover': { boxShadow: 4 } }) }} > {themeColor === 'primary' ? : null} handleChange('themeColor', 'secondary')} sx={{ backgroundColor: 'secondary.main', ...(themeColor === 'secondary' ? { boxShadow: 9 } : { '&:hover': { boxShadow: 4 } }) }} > {themeColor === 'secondary' ? : null} handleChange('themeColor', 'success')} sx={{ backgroundColor: 'success.main', ...(themeColor === 'success' ? { boxShadow: 9 } : { '&:hover': { boxShadow: 4 } }) }} > {themeColor === 'success' ? : null} handleChange('themeColor', 'error')} sx={{ backgroundColor: 'error.main', ...(themeColor === 'error' ? { boxShadow: 9 } : { '&:hover': { boxShadow: 4 } }) }} > {themeColor === 'error' ? : null} handleChange('themeColor', 'warning')} sx={{ backgroundColor: 'warning.main', ...(themeColor === 'warning' ? { boxShadow: 9 } : { '&:hover': { boxShadow: 4 } }) }} > {themeColor === 'warning' ? : null} handleChange('themeColor', 'info')} sx={{ mr: 0, backgroundColor: 'info.main', ...(themeColor === 'info' ? { boxShadow: 9 } : { '&:hover': { boxShadow: 4 } }) }} > {themeColor === 'info' ? : null}
Layout {/* Content Width */} Content Width handleChange('contentWidth', e.target.value as Settings['contentWidth'])} sx={{ '& .MuiFormControlLabel-label': { fontSize: '.875rem', color: 'text.secondary' } }} > } /> } /> {/* AppBar */} AppBar Type handleChange('appBar', e.target.value as Settings['appBar'])} sx={{ '& .MuiFormControlLabel-label': { fontSize: '.875rem', color: 'text.secondary' } }} > } /> } /> {layout === 'horizontal' ? null : ( } /> )} {/* Footer */} Footer Type handleChange('footer', e.target.value as Settings['footer'])} sx={{ '& .MuiFormControlLabel-label': { fontSize: '.875rem', color: 'text.secondary' } }} > } /> } /> } /> {/* AppBar Blur */} AppBar Blur handleChange('appBarBlur', e.target.checked)} /> {/* RTL */} RTL handleChange('direction', e.target.checked ? 'rtl' : 'ltr')} /> Menu {/* Menu Layout */} Menu Layout { saveSettings({ ...settings, layout: e.target.value as Settings['layout'], lastLayout: e.target.value as Settings['lastLayout'] }) }} sx={{ '& .MuiFormControlLabel-label': { fontSize: '.875rem', color: 'text.secondary' } }} > } /> } /> {/* Menu Toggle */} {navHidden || layout === 'horizontal' ? null : ( Menu Toggle handleChange('verticalNavToggleType', e.target.value as Settings['verticalNavToggleType']) } sx={{ '& .MuiFormControlLabel-label': { fontSize: '.875rem', color: 'text.secondary' } }} > } /> } /> )} {/* Menu Collapsed */} {navHidden || layout === 'horizontal' ? null : ( Menu Collapsed handleChange('navCollapsed', e.target.checked)} /> )} {/* Menu Hidden */} {layout === 'horizontal' && appBar === 'hidden' ? null : ( Menu Hidden handleChange('navHidden', e.target.checked)} /> )}
) } export default Customizer