From d3c7705bedebd65c94f9eea691aaf2fe03b0cafe Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 19 Aug 2023 13:58:45 -0700 Subject: Move to Vite --- modern/src/common/components/PageLayout.jsx | 118 ++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 modern/src/common/components/PageLayout.jsx (limited to 'modern/src/common/components/PageLayout.jsx') diff --git a/modern/src/common/components/PageLayout.jsx b/modern/src/common/components/PageLayout.jsx new file mode 100644 index 00000000..e81c9754 --- /dev/null +++ b/modern/src/common/components/PageLayout.jsx @@ -0,0 +1,118 @@ +import React, { useState } from 'react'; +import { + AppBar, + Breadcrumbs, + Divider, + Drawer, + IconButton, + Toolbar, + Typography, + useMediaQuery, + useTheme, +} from '@mui/material'; +import makeStyles from '@mui/styles/makeStyles'; +import ArrowBackIcon from '@mui/icons-material/ArrowBack'; +import MenuIcon from '@mui/icons-material/Menu'; +import { useNavigate } from 'react-router-dom'; +import { useTranslation } from './LocalizationProvider'; + +const useStyles = makeStyles((theme) => ({ + desktopRoot: { + height: '100%', + display: 'flex', + }, + mobileRoot: { + height: '100%', + display: 'flex', + flexDirection: 'column', + }, + desktopDrawer: { + width: theme.dimensions.drawerWidthDesktop, + }, + mobileDrawer: { + width: theme.dimensions.drawerWidthTablet, + }, + mobileToolbar: { + zIndex: 1, + }, + content: { + flexGrow: 1, + alignItems: 'stretch', + display: 'flex', + flexDirection: 'column', + overflowY: 'auto', + }, +})); + +const PageTitle = ({ breadcrumbs }) => { + const theme = useTheme(); + const t = useTranslation(); + + const desktop = useMediaQuery(theme.breakpoints.up('md')); + + if (desktop) { + return ( + {t(breadcrumbs[0])} + ); + } + return ( + + {breadcrumbs.slice(0, -1).map((breadcrumb) => ( + {t(breadcrumb)} + ))} + {t(breadcrumbs[breadcrumbs.length - 1])} + + ); +}; + +const PageLayout = ({ menu, breadcrumbs, children }) => { + const classes = useStyles(); + const theme = useTheme(); + const navigate = useNavigate(); + + const desktop = useMediaQuery(theme.breakpoints.up('md')); + + const [openDrawer, setOpenDrawer] = useState(false); + + return desktop ? ( +
+ + + navigate('/')}> + + + + + + {menu} + +
{children}
+
+ ) : ( +
+ setOpenDrawer(false)} + classes={{ paper: classes.mobileDrawer }} + > + {menu} + + + + setOpenDrawer(true)}> + + + + + +
{children}
+
+ ); +}; + +export default PageLayout; -- cgit v1.2.3