[5d6f37a] | 1 | // @mui
|
---|
| 2 | import Box from '@mui/material/Box';
|
---|
| 3 | // hooks
|
---|
| 4 | import { useBoolean } from 'src/hooks/use-boolean';
|
---|
| 5 | import { useResponsive } from 'src/hooks/use-responsive';
|
---|
| 6 | // components
|
---|
| 7 | import { useSettingsContext } from 'src/components/settings';
|
---|
| 8 | //
|
---|
| 9 | import Main from './main';
|
---|
| 10 | import Header from './header';
|
---|
| 11 | import NavMini from './nav-mini';
|
---|
| 12 | import NavVertical from './nav-vertical';
|
---|
| 13 | import NavHorizontal from './nav-horizontal';
|
---|
| 14 |
|
---|
| 15 | // ----------------------------------------------------------------------
|
---|
| 16 |
|
---|
| 17 | type Props = {
|
---|
| 18 | children: React.ReactNode;
|
---|
| 19 | };
|
---|
| 20 |
|
---|
| 21 | export default function DashboardLayout({ children }: Props) {
|
---|
| 22 | const settings = useSettingsContext();
|
---|
| 23 |
|
---|
| 24 | const lgUp = useResponsive('up', 'lg');
|
---|
| 25 |
|
---|
| 26 | const nav = useBoolean();
|
---|
| 27 |
|
---|
| 28 | const isHorizontal = settings.themeLayout === 'horizontal';
|
---|
| 29 |
|
---|
| 30 | const isMini = settings.themeLayout === 'mini';
|
---|
| 31 |
|
---|
| 32 | const renderNavMini = <NavMini />;
|
---|
| 33 |
|
---|
| 34 | const renderHorizontal = <NavHorizontal />;
|
---|
| 35 |
|
---|
| 36 | const renderNavVertical = <NavVertical openNav={nav.value} onCloseNav={nav.onFalse} />;
|
---|
| 37 |
|
---|
| 38 | if (isHorizontal) {
|
---|
| 39 | return (
|
---|
| 40 | <>
|
---|
| 41 | <Header onOpenNav={nav.onTrue} />
|
---|
| 42 |
|
---|
| 43 | {lgUp ? renderHorizontal : renderNavVertical}
|
---|
| 44 |
|
---|
| 45 | <Main>{children}</Main>
|
---|
| 46 | </>
|
---|
| 47 | );
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | if (isMini) {
|
---|
| 51 | return (
|
---|
| 52 | <>
|
---|
| 53 | <Header onOpenNav={nav.onTrue} />
|
---|
| 54 |
|
---|
| 55 | <Box
|
---|
| 56 | sx={{
|
---|
| 57 | minHeight: 1,
|
---|
| 58 | display: 'flex',
|
---|
| 59 | flexDirection: { xs: 'column', lg: 'row' },
|
---|
| 60 | }}
|
---|
| 61 | >
|
---|
| 62 | {lgUp ? renderNavMini : renderNavVertical}
|
---|
| 63 |
|
---|
| 64 | <Main>{children}</Main>
|
---|
| 65 | </Box>
|
---|
| 66 | </>
|
---|
| 67 | );
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | return (
|
---|
| 71 | <>
|
---|
| 72 | <Header onOpenNav={nav.onTrue} />
|
---|
| 73 |
|
---|
| 74 | <Box
|
---|
| 75 | sx={{
|
---|
| 76 | minHeight: 1,
|
---|
| 77 | display: 'flex',
|
---|
| 78 | flexDirection: { xs: 'column', lg: 'row' },
|
---|
| 79 | }}
|
---|
| 80 | >
|
---|
| 81 | {renderNavVertical}
|
---|
| 82 |
|
---|
| 83 | <Main>{children}</Main>
|
---|
| 84 | </Box>
|
---|
| 85 | </>
|
---|
| 86 | );
|
---|
| 87 | }
|
---|