import React from 'react'; import PropTypes from 'prop-types'; import { withStyles } from '@material-ui/core/styles'; import Drawer from '@material-ui/core/Drawer'; import AppBar from '@material-ui/core/AppBar'; import Toolbar from '@material-ui/core/Toolbar'; 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 Typography from '@material-ui/core/Typography'; import IconButton from '@material-ui/core/IconButton'; import Hidden from '@material-ui/core/Hidden'; import Divider from '@material-ui/core/Divider'; import MenuIcon from '@material-ui/icons/Menu'; import HomeIcon from '@material-ui/icons/Home'; import AssignmentIcon from '@material-ui/icons/Assignment'; import MapIcon from '@material-ui/icons/Map'; import InfoIcon from '@material-ui/icons/Info'; import ListIcon from '@material-ui/icons/List'; import SlideshowIcon from '@material-ui/icons/Slideshow'; import Home from '../pages/Home'; import ViewMap from '../pages/ViewMap'; import About from '../pages/About'; import Quiz from '../pages/QuizPage'; import SightingList from '../pages/SightingList'; import Report from '../pages/Report'; import CssBaseline from '@material-ui/core/CssBaseline'; import ExpandLess from '@material-ui/icons/ExpandLess'; import ExpandMore from '@material-ui/icons/ExpandMore'; import Collapse from '@material-ui/core/Collapse'; const drawerWidth = 240; const styles = theme => ({ root: { display: 'flex', }, drawer: { [theme.breakpoints.up('sm')]: { width: drawerWidth, flexShrink: 0, }, }, nested: { paddingLeft: theme.spacing.unit * 4, }, appBar: { marginLeft: drawerWidth, [theme.breakpoints.up('sm')]: { width: `calc(100% - ${drawerWidth}px)`, }, }, menuButton: { marginRight: 20, [theme.breakpoints.up('sm')]: { display: 'none', }, }, toolbar: theme.mixins.toolbar, drawerPaper: { width: drawerWidth, }, content: { flexGrow: 1, width: '60%' }, }); class ResponsiveDrawer extends React.Component { state = { mobileOpen: false, key: 'Home', open: false }; handleDrawerToggle = () => { this.setState(state => ({ mobileOpen: !state.mobileOpen })); } handleClick = () => { this.setState(state => ({ open: !state.open })); } nav = (text) => { this.setState({ key: text }); } render() { const { classes, theme } = this.props; const drawer = (
this.nav('Home')}> this.nav('Report')}> this.nav('Map')}> this.nav('List')}> this.nav('About')}> {this.state.open ? : } this.nav('Easy-Quiz')}> this.nav('Medium-Quiz')}> this.nav('Hard-Quiz')}>
); return (
Marten Tracker
{this.state.key === 'Home' && } {this.state.key === 'Report' && } {this.state.key === 'Map' && } {this.state.key === 'List' && } {this.state.key === 'About' && } {this.state.key === 'Easy-Quiz' && } {this.state.key === 'Medium-Quiz' && } {this.state.key === 'Hard-Quiz' && }
); } } ResponsiveDrawer.propTypes = { classes: PropTypes.object.isRequired, // Injected by the documentation to work in an iframe. // You won't need it on your project. container: PropTypes.object, theme: PropTypes.object.isRequired, }; export default withStyles(styles, { withTheme: true })(ResponsiveDrawer);