mirror of
https://github.com/sergeyyarkov/todo-app.git
synced 2026-10-11 02:19:04 +03:00
107 lines
2.7 KiB
JavaScript
107 lines
2.7 KiB
JavaScript
import React from 'react';
|
|
import AppBar from '@material-ui/core/AppBar';
|
|
import Drawer from '@material-ui/core/Drawer';
|
|
import DrawerContent from '../DrawerContent/DrawerContent'
|
|
import Hidden from '@material-ui/core/Hidden';
|
|
import IconButton from '@material-ui/core/IconButton';
|
|
import MenuIcon from '@material-ui/icons/Menu';
|
|
import Toolbar from '@material-ui/core/Toolbar';
|
|
import Typography from '@material-ui/core/Typography'
|
|
import { makeStyles, useTheme } from '@material-ui/core/styles'
|
|
|
|
const drawerWidth = 240;
|
|
|
|
const useStyles = makeStyles((theme) => ({
|
|
drawer: {
|
|
[theme.breakpoints.up('sm')]: {
|
|
width: drawerWidth,
|
|
flexShrink: 0,
|
|
},
|
|
},
|
|
appBar: {
|
|
[theme.breakpoints.up('sm')]: {
|
|
width: `calc(100% - ${drawerWidth}px)`,
|
|
marginLeft: drawerWidth,
|
|
},
|
|
},
|
|
menuButton: {
|
|
marginRight: theme.spacing(2),
|
|
[theme.breakpoints.up('sm')]: {
|
|
display: 'none',
|
|
},
|
|
},
|
|
drawerPaper: {
|
|
width: drawerWidth,
|
|
},
|
|
content: {
|
|
flexGrow: 1,
|
|
padding: theme.spacing(3),
|
|
},
|
|
}));
|
|
|
|
const Header = (props) => {
|
|
const { window } = props;
|
|
const classes = useStyles();
|
|
const theme = useTheme();
|
|
|
|
const [mobileOpen, setMobileOpen] = React.useState(false);
|
|
|
|
const handleDrawerToggle = () => {
|
|
setMobileOpen(!mobileOpen);
|
|
};
|
|
|
|
const container = window !== undefined ? () => window().document.body : undefined;
|
|
|
|
return (
|
|
<>
|
|
<AppBar position="fixed" className={classes.appBar}>
|
|
<Toolbar>
|
|
<IconButton
|
|
color="inherit"
|
|
aria-label="open drawer"
|
|
edge="start"
|
|
onClick={handleDrawerToggle}
|
|
className={classes.menuButton}
|
|
>
|
|
<MenuIcon />
|
|
</IconButton>
|
|
<Typography variant="h1" noWrap>
|
|
Todo app
|
|
</Typography>
|
|
</Toolbar>
|
|
</AppBar>
|
|
<nav className={classes.drawer} aria-label="mailbox folders">
|
|
<Hidden smUp implementation="css">
|
|
<Drawer
|
|
container={container}
|
|
variant="temporary"
|
|
anchor={theme.direction === 'rtl' ? 'right' : 'left'}
|
|
open={mobileOpen}
|
|
onClose={handleDrawerToggle}
|
|
classes={{
|
|
paper: classes.drawerPaper,
|
|
}}
|
|
ModalProps={{
|
|
keepMounted: true,
|
|
}}
|
|
>
|
|
<DrawerContent />
|
|
</Drawer>
|
|
</Hidden>
|
|
<Hidden xsDown implementation="css">
|
|
<Drawer
|
|
classes={{
|
|
paper: classes.drawerPaper,
|
|
}}
|
|
variant="permanent"
|
|
open
|
|
>
|
|
<DrawerContent />
|
|
</Drawer>
|
|
</Hidden>
|
|
</nav>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export default Header |