Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- import PropTypes from 'prop-types';
- import classNames from 'classnames';
- import { withStyles } from '@material-ui/core/styles';
- import Drawer from '@material-ui/core/Drawer';
- import Collapse from '@material-ui/core/Collapse';
- import AppBar from '@material-ui/core/AppBar';
- import Toolbar from '@material-ui/core/Toolbar';
- import Typography from '@material-ui/core/Typography';
- import IconButton from '@material-ui/core/IconButton';
- import MenuIcon from '@material-ui/icons/Menu';
- import ChevronLeftIcon from '@material-ui/icons/ChevronLeft';
- import ChevronRightIcon from '@material-ui/icons/ChevronRight';
- import Divider from '@material-ui/core/Divider';
- import List from '@material-ui/core/List';
- import ListItem from '@material-ui/core/ListItem';
- import ListItemIcon from '@material-ui/core/ListItemIcon';
- import ListItemText from '@material-ui/core/ListItemText';
- import ExpandLess from '@material-ui/icons/ExpandLess';
- import ExpandMore from '@material-ui/icons/ExpandMore';
- import StarBorder from '@material-ui/icons/StarBorder';
- import {
- Send as SendIcon,
- Drafts as DraftsIcon,
- Inbox as InboxIcon } from '@material-ui/icons';
- const drawerWidth = 240;
- const styles = theme => ({
- root: {
- flexGrow: 1,
- height: '100%',
- zIndex: 1,
- overflow: 'hidden',
- position: 'relative',
- display: 'flex',
- },
- 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: {
- marginLeft: 12,
- marginRight: 36,
- },
- hide: {
- display: 'none',
- },
- pageContent: {
- top: '120px',
- width: 'calc(100% - 72px)',
- left: '72px',
- position: 'relative',
- },
- drawerPaper: {
- position: 'absolute',
- 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.unit * 7,
- [theme.breakpoints.up('sm')]: {
- width: theme.spacing.unit * 9,
- },
- },
- toolbar: {
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'flex-end',
- padding: '0 8px',
- ...theme.mixins.toolbar,
- },
- content: {
- flexGrow: 1,
- backgroundColor: theme.palette.background.default,
- padding: theme.spacing.unit * 3,
- },
- nested: {
- paddingLeft: theme.spacing.unit * 4,
- },
- });
- class App extends React.PureComponent {
- state = {
- open: false,
- openInbox: false,
- };
- handleClick = () => {
- this.setState(state => ({ openInbox: !state.openInbox }));
- };
- handleDrawer = () => {
- this.setState(state => ({ open: !state.open }));
- };
- render() {
- const { classes, theme, title } = this.props;
- return (
- <React.Fragment>
- <AppBar
- position="absolute"
- className={classNames(classes.appBar, this.state.open && classes.appBarShift)}
- >
- <Toolbar disableGutters={!this.state.open}>
- <IconButton
- color="inherit"
- aria-label="open drawer"
- onClick={this.handleDrawer}
- className={classNames(classes.menuButton, this.state.open && classes.hide)}
- >
- <MenuIcon />
- </IconButton>
- <Typography variant="title" color="inherit" noWrap>
- {
- title || 'Agoralys Dashboard'
- }
- </Typography>
- </Toolbar>
- </AppBar>
- <Drawer
- variant="permanent"
- classes={{
- paper: classNames(classes.drawerPaper, !this.state.open && classes.drawerPaperClose),
- }}
- open={this.state.open}
- >
- <div className={classes.toolbar}>
- <IconButton onClick={this.handleDrawer}>
- {theme.direction === 'rtl' ? <ChevronRightIcon /> : <ChevronLeftIcon />}
- </IconButton>
- </div>
- <Divider />
- <List>
- <ListItem button>
- <ListItemIcon>
- <SendIcon />
- </ListItemIcon>
- <ListItemText inset primary="Sent mail" />
- </ListItem>
- <ListItem button>
- <ListItemIcon>
- <DraftsIcon />
- </ListItemIcon>
- <ListItemText inset primary="Drafts" />
- </ListItem>
- <ListItem button onClick={this.handleClick}>
- <ListItemIcon>
- <InboxIcon />
- </ListItemIcon>
- <ListItemText inset primary="Inbox" />
- {this.state.openInbox ? <ExpandLess /> : <ExpandMore />}
- </ListItem>
- <Collapse in={this.state.openInbox} timeout="auto" unmountOnExit>
- <List component="div" disablePadding>
- <ListItem button className={classes.nested}>
- <ListItemIcon>
- <StarBorder />
- </ListItemIcon>
- <ListItemText inset primary="Starred" />
- </ListItem>
- </List>
- </Collapse>
- </List>
- </Drawer>
- </React.Fragment>
- );
- }
- }
- App.propTypes = {
- children: PropTypes.oneOfType([
- PropTypes.arrayOf(PropTypes.node),
- PropTypes.node,
- ]).isRequired,
- classes: PropTypes.object.isRequired,
- theme: PropTypes.object.isRequired,
- title: PropTypes.string,
- };
- export default withStyles(styles, { withTheme: true })(App);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement