@forrestjs/kitchensink
Version:
ForrestJS demonstrational tool
71 lines (64 loc) • 1.85 kB
JavaScript
import React from 'react';
import clsx from 'clsx';
import { makeStyles } from '@material-ui/core/styles';
import Drawer from '@material-ui/core/Drawer';
import Divider from '@material-ui/core/Divider';
import IconButton from '@material-ui/core/IconButton';
import ChevronLeftIcon from '@material-ui/icons/ChevronLeft';
import { LayoutDrawerList } from './LayoutDrawerList';
const drawerWidth = 240;
const useStyles = makeStyles((theme) => ({
toolbarIcon: {
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-end',
padding: '0 8px',
...theme.mixins.toolbar,
},
drawerPaper: {
position: 'relative',
whiteSpace: 'nowrap',
width: drawerWidth,
transition: theme.transitions.create('width', {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.enteringScreen,
}),
},
drawerPaperClose: {
overflowX: 'hidden',
transition: theme.transitions.create('width', {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.leavingScreen,
}),
width: theme.spacing(7),
[theme.breakpoints.up('sm')]: {
width: theme.spacing(9),
},
},
}));
export const LayoutDrawer = ({
isOpen,
handleClose,
primaryItems,
secondaryItems,
}) => {
const classes = useStyles();
return (
<Drawer
variant="permanent"
open={isOpen}
classes={{
paper: clsx(classes.drawerPaper, !isOpen && classes.drawerPaperClose),
}}
>
<div className={classes.toolbarIcon}>
<IconButton onClick={handleClose}>
<ChevronLeftIcon />
</IconButton>
</div>
<Divider />
{primaryItems.length > 0 && <LayoutDrawerList items={primaryItems} />}
{secondaryItems.length > 0 && <LayoutDrawerList items={secondaryItems} />}
</Drawer>
);
};