@forrestjs/kitchensink
Version:
ForrestJS demonstrational tool
103 lines (95 loc) • 2.67 kB
JavaScript
import React from 'react';
import clsx from 'clsx';
import { makeStyles } from '@material-ui/core/styles';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import IconButton from '@material-ui/core/IconButton';
import Typography from '@material-ui/core/Typography';
// import Badge from '@material-ui/core/Badge';
import MenuIcon from '@material-ui/icons/Menu';
// import NotificationsIcon from '@material-ui/icons/Notifications';
// import { useGetContext, useGetConfig } from '../../services/react-root';
// import { LayoutDrawer } from './LayoutDrawer';
const drawerWidth = 240;
const useStyles = makeStyles((theme) => ({
toolbar: {
paddingRight: 24, // keep right padding when drawer closed
},
toolbarIcon: {
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-end',
padding: '0 8px',
...theme.mixins.toolbar,
},
appBar: {
zIndex: theme.zIndex.drawer + 1,
transition: theme.transitions.create(['width', 'margin'], {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.leavingScreen,
}),
},
appBarShift: {
marginLeft: drawerWidth,
width: `calc(100% - ${drawerWidth}px)`,
transition: theme.transitions.create(['width', 'margin'], {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.enteringScreen,
}),
},
menuButton: {
marginRight: 36,
},
menuButtonHidden: {
display: 'none',
},
title: {
flexGrow: 1,
},
appBarSpacer: theme.mixins.toolbar,
}));
export const LayoutAppBar = ({
hasDrawer,
isDrawerOpen,
handleDrawerOpen,
title,
}) => {
const classes = useStyles();
return (
<AppBar
position="absolute"
className={clsx(classes.appBar, isDrawerOpen && classes.appBarShift)}
>
<Toolbar className={classes.toolbar}>
{hasDrawer && (
<IconButton
edge="start"
color="inherit"
aria-label="open drawer"
onClick={handleDrawerOpen}
className={clsx(
classes.menuButton,
isDrawerOpen && classes.menuButtonHidden,
)}
>
<MenuIcon />
</IconButton>
)}
<Typography
component="h1"
variant="h6"
color="inherit"
noWrap
className={classes.title}
>
{title}
</Typography>
{/* <IconButton color="inherit">
<Badge badgeContent={4} color="secondary">
<NotificationsIcon />
</Badge>
</IconButton> */}
</Toolbar>
</AppBar>
);
};