Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from "react";
  2. import API from "../../utils/API";
  3. import {AppBar, Button, Drawer, IconButton, makeStyles, Menu, MenuItem, Toolbar} from "@material-ui/core";
  4. import AddIcon from '@material-ui/icons/Add';
  5. import AccountIcon from '@material-ui/icons/AccountCircle'
  6. // import Dragable from 'react-dra'
  7.  
  8. const useStyles = makeStyles(theme => ({
  9.     root: {
  10.         flexGrow: 1,
  11.     },
  12.     menuButton: {
  13.         marginRight: theme.spacing(2),
  14.     },
  15.     title: {
  16.         flexGrow: 1,
  17.     },
  18.     list: {
  19.         backgroundColor: "grey",
  20.         height: '100%',
  21.         width: 250,
  22.         textAlign: "center",
  23.     },
  24.     text: {
  25.         marginTop: 42,
  26.         textAlign: "center",
  27.         color: 'white',
  28.     },
  29.     button: {
  30.         margin: theme.spacing(1),
  31.         size: "large",
  32.         fontSize: 24,
  33.         marginTop: 42,
  34.     }
  35. }));
  36.  
  37. const handleMenu = event => {
  38.     this.setAnchorEl(event.currentTarget);
  39. };
  40.  
  41. const handleClose = () => {
  42.     this.setAnchorEl(null);
  43. };
  44.  
  45. const toggleDrawer = (side, open) => event => {
  46.     if (event.type === 'keydown' && (event.key === 'Tab' || event.key === 'Shift')) {
  47.         return;
  48.     }
  49.     this.setState({ ...this.state, [side]: open });
  50. };
  51.  
  52. const disconnect = () => {
  53.     API.logout();
  54.     window.location = "/";
  55. };
  56.  
  57. const sideList = side => (
  58.     <div
  59.         className={useStyles.list}
  60.         role="presentation"
  61.         onClick={toggleDrawer(side, false)}
  62.         onKeyDown={toggleDrawer(side, false)}
  63.     >
  64.         <Button className={useStyles.button}>Weather</Button>
  65.     </div>
  66. );
  67.  
  68.  
  69. export class Dashboard extends React.Component {
  70.     constructor(props) {
  71.         super(props);
  72.         // [(this.state), (this.setState)] = React.useState({
  73.         //     left: false,
  74.         // });
  75.         this.state = {
  76.             left: false,
  77.             open: false,
  78.             widgetList: [],
  79.         };
  80.         // [(this.anchorEl), (this.setAnchorEl)] = React.useState(null);
  81.         this.anchorEl = null;
  82.     }
  83.  
  84.     render() {
  85.         // const classes = useStyles();
  86.         const open = Boolean(this.anchorEl);
  87.         return (
  88.             <div className="Dashboard">
  89.                 <div className={useStyles.root}>
  90.                     <AppBar position="absolute" color="default">
  91.                         <Toolbar>
  92.                             <IconButton edge="start" className={useStyles.menuButton} color="inherit" aria-label="menu" onClick={toggleDrawer('left', true)}>
  93.                                 <AddIcon/>
  94.                             </IconButton>
  95.                             <div style={{marginLeft: "auto"}}>
  96.                                 <IconButton
  97.                                     edge="end"
  98.                                     position="absolute"
  99.                                     aria-label="account of current user"
  100.                                     aria-controls="menu-appbar"
  101.                                     aria-haspopup="true"
  102.                                     onClick={handleMenu}
  103.                                     color="inherit"
  104.                                 >
  105.                                     <AccountIcon/>
  106.                                 </IconButton>
  107.                                 <Menu
  108.                                     id="menu-appbar"
  109.                                     anchorEl={this.anchorEl}
  110.                                     anchorOrigin={{
  111.                                         vertical: 'top',
  112.                                         horizontal: 'right',
  113.                                     }}
  114.                                     keepMounted
  115.                                     transformOrigin={{
  116.                                         vertical: 'top',
  117.                                         horizontal: 'right',
  118.                                     }}
  119.                                     open={this.open}
  120.                                     onClose={handleClose}
  121.                                 >
  122.                                     <MenuItem onClick={handleClose}>Profile</MenuItem>
  123.                                     <MenuItem onClick={disconnect}>Disconnect</MenuItem>
  124.                                 </Menu>
  125.                             </div>
  126.                             <Drawer open={this.state.left} onClose={toggleDrawer('left', false)}>
  127.                                 {sideList('left')}
  128.                             </Drawer>
  129.                         </Toolbar>
  130.                     </AppBar>
  131.                 </div>
  132.                     {/*<ButtonAppBar/>*/}
  133.                 <h1>Work in progress</h1>
  134.             </div>
  135.         );
  136.     }
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement