1 |
456b0111
|
Vaclav Honzik
|
import * as React from 'react'
|
2 |
|
|
import { styled, useTheme } from '@mui/material/styles'
|
3 |
|
|
import Box from '@mui/material/Box'
|
4 |
|
|
import Drawer from '@mui/material/Drawer'
|
5 |
|
|
import CssBaseline from '@mui/material/CssBaseline'
|
6 |
|
|
import MuiAppBar, { AppBarProps as MuiAppBarProps } from '@mui/material/AppBar'
|
7 |
|
|
import Toolbar from '@mui/material/Toolbar'
|
8 |
|
|
import List from '@mui/material/List'
|
9 |
|
|
import Typography from '@mui/material/Typography'
|
10 |
|
|
import Divider from '@mui/material/Divider'
|
11 |
|
|
import IconButton from '@mui/material/IconButton'
|
12 |
|
|
import MenuIcon from '@mui/icons-material/Menu'
|
13 |
|
|
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft'
|
14 |
|
|
import ChevronRightIcon from '@mui/icons-material/ChevronRight'
|
15 |
|
|
import ListItem from '@mui/material/ListItem'
|
16 |
|
|
import ListItemIcon from '@mui/material/ListItemIcon'
|
17 |
|
|
import ListItemText from '@mui/material/ListItemText'
|
18 |
|
|
import InboxIcon from '@mui/icons-material/MoveToInbox'
|
19 |
|
|
import MailIcon from '@mui/icons-material/Mail'
|
20 |
|
|
import { FunctionComponent } from 'react'
|
21 |
|
|
import NavigationMenu from './NavigationMenu'
|
22 |
|
|
import { Paper } from '@mui/material'
|
23 |
|
|
|
24 |
|
|
const drawerWidth = 240
|
25 |
|
|
|
26 |
|
|
const Main = styled('main', { shouldForwardProp: (prop) => prop !== 'open' })<{
|
27 |
|
|
open?: boolean
|
28 |
|
|
}>(({ theme, open }) => ({
|
29 |
|
|
flexGrow: 1,
|
30 |
|
|
// padding: theme.spacing(3),
|
31 |
|
|
transition: theme.transitions.create('margin', {
|
32 |
|
|
easing: theme.transitions.easing.sharp,
|
33 |
|
|
duration: theme.transitions.duration.leavingScreen,
|
34 |
|
|
}),
|
35 |
|
|
marginLeft: `-${drawerWidth}px`,
|
36 |
|
|
...(open && {
|
37 |
|
|
transition: theme.transitions.create('margin', {
|
38 |
|
|
easing: theme.transitions.easing.easeOut,
|
39 |
|
|
duration: theme.transitions.duration.enteringScreen,
|
40 |
|
|
}),
|
41 |
|
|
marginLeft: 0,
|
42 |
|
|
}),
|
43 |
|
|
}))
|
44 |
|
|
|
45 |
|
|
interface AppBarProps extends MuiAppBarProps {
|
46 |
|
|
open?: boolean
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
const AppBar = styled(MuiAppBar, {
|
50 |
|
|
shouldForwardProp: (prop) => prop !== 'open',
|
51 |
|
|
})<AppBarProps>(({ theme, open }) => ({
|
52 |
|
|
transition: theme.transitions.create(['margin', 'width'], {
|
53 |
|
|
easing: theme.transitions.easing.sharp,
|
54 |
|
|
duration: theme.transitions.duration.leavingScreen,
|
55 |
|
|
}),
|
56 |
|
|
...(open && {
|
57 |
|
|
width: `calc(100% - ${drawerWidth}px)`,
|
58 |
|
|
marginLeft: `${drawerWidth}px`,
|
59 |
|
|
transition: theme.transitions.create(['margin', 'width'], {
|
60 |
|
|
easing: theme.transitions.easing.easeOut,
|
61 |
|
|
duration: theme.transitions.duration.enteringScreen,
|
62 |
|
|
}),
|
63 |
|
|
}),
|
64 |
|
|
}))
|
65 |
|
|
|
66 |
|
|
const DrawerHeader = styled('div')(({ theme }) => ({
|
67 |
|
|
display: 'flex',
|
68 |
|
|
alignItems: 'center',
|
69 |
|
|
padding: theme.spacing(0, 1),
|
70 |
|
|
// necessary for content to be below app bar
|
71 |
|
|
...theme.mixins.toolbar,
|
72 |
|
|
justifyContent: 'flex-end',
|
73 |
|
|
}))
|
74 |
|
|
|
75 |
|
|
export interface DrawerProps {
|
76 |
|
|
children: React.ReactNode
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
const PersistentDrawerLeft: FunctionComponent<DrawerProps> = ({ children }) => {
|
80 |
|
|
const [open, setOpen] = React.useState(false)
|
81 |
|
|
|
82 |
|
|
const onOpenDrawer = () => {
|
83 |
|
|
setOpen(true)
|
84 |
|
|
}
|
85 |
|
|
|
86 |
|
|
return (
|
87 |
|
|
<Box sx={{ display: 'flex' }}>
|
88 |
|
|
<CssBaseline />
|
89 |
|
|
<AppBar position="fixed" open={open}>
|
90 |
|
|
<Toolbar>
|
91 |
|
|
<IconButton
|
92 |
|
|
color="inherit"
|
93 |
|
|
aria-label="open drawer"
|
94 |
|
|
onClick={onOpenDrawer}
|
95 |
|
|
edge="start"
|
96 |
|
|
sx={{ mr: 2, ...(open && { display: 'none' }) }}
|
97 |
|
|
>
|
98 |
|
|
<MenuIcon />
|
99 |
|
|
</IconButton>
|
100 |
|
|
<Typography variant="h6" noWrap component="div">
|
101 |
|
|
Assyrian Toponyms App Prototype
|
102 |
|
|
</Typography>
|
103 |
|
|
</Toolbar>
|
104 |
|
|
</AppBar>
|
105 |
|
|
<NavigationMenu
|
106 |
|
|
open={open}
|
107 |
|
|
drawerWidth={drawerWidth}
|
108 |
|
|
setOpen={setOpen}
|
109 |
|
|
/>
|
110 |
|
|
<Main open={open} sx={{ mt: 2 }}>
|
111 |
|
|
<Paper style={{ minHeight: '100vh', borderRadius: 0 }}>
|
112 |
|
|
<DrawerHeader />
|
113 |
|
|
{children}
|
114 |
|
|
</Paper>
|
115 |
|
|
</Main>
|
116 |
|
|
</Box>
|
117 |
|
|
)
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
export default PersistentDrawerLeft
|