updated navigation structure

This commit is contained in:
Al Duncanson 2018-10-24 13:09:53 -04:00
parent a7ca249d1e
commit 60e252cb72
3 changed files with 149 additions and 49 deletions

View File

@ -3,10 +3,11 @@ body {
} }
.report-google-map-container > div { .report-google-map-container > div {
height: 92% !important;
width: 50% !important; width: 50% !important;
} }
.sighting-google-map-container > div { @media (min-width: 960px) {
height: 92% !important; .sighting-google-map-container > div {
width: calc(100% - 241px) !important;
}
} }

View File

@ -1,75 +1,173 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles'; import { withStyles } from '@material-ui/core/styles';
import Drawer from '@material-ui/core/Drawer';
import AppBar from '@material-ui/core/AppBar'; import AppBar from '@material-ui/core/AppBar';
import Tabs from '@material-ui/core/Tabs'; import Toolbar from '@material-ui/core/Toolbar';
import Tab from '@material-ui/core/Tab'; 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 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 ListIcon from '@material-ui/icons/List';
import SlideshowIcon from '@material-ui/icons/Slideshow';
import Home from '../pages/Home'; import Home from '../pages/Home';
import ViewMap from '../pages/ViewMap'; import ViewMap from '../pages/ViewMap';
import Quiz from '../pages/Quiz'; import Quiz from '../pages/Quiz';
import SightingList from '../pages/SightingList'; import SightingList from '../pages/SightingList';
import Report from '../pages/Report'; import Report from '../pages/Report';
import Info from '../pages/Info';
function TabContainer(props) { const drawerWidth = 240;
return (
<Typography component="div" style={{ padding: 8 * 3 }}>
{props.children}
</Typography>
);
}
TabContainer.propTypes = {
children: PropTypes.node.isRequired,
};
const styles = theme => ({ const styles = theme => ({
root: { root: {
flexGrow: 1, flexGrow: 1,
backgroundColor: theme.palette.background.paper, height: '100vh',
zIndex: 1,
overflow: 'hidden',
position: 'relative',
display: 'flex',
width: '100%',
},
appBar: {
position: 'absolute',
marginLeft: drawerWidth,
[theme.breakpoints.up('md')]: {
width: `calc(100% - ${drawerWidth}px)`,
},
},
navIconHide: {
[theme.breakpoints.up('md')]: {
display: 'none',
},
},
toolbar: theme.mixins.toolbar,
drawerPaper: {
width: drawerWidth,
[theme.breakpoints.up('md')]: {
position: 'relative',
},
},
content: {
flexGrow: 1,
backgroundColor: theme.palette.background.default,
padding: theme.spacing.unit * 3,
}, },
}); });
class SimpleTabs extends React.Component { class ResponsiveDrawer extends React.Component {
state = { state = {
value: 0, mobileOpen: false,
}; key: ''
}
handleChange = (event, value) => { handleDrawerToggle = () => {
this.setState({ value }); this.setState(state => ({ mobileOpen: !state.mobileOpen }));
}; }
nav = (text) => {
this.setState({
key: text
})
}
render() { render() {
const { classes } = this.props; const { classes, theme } = this.props;
const { value } = this.state;
const drawer = (
<div>
<div className={classes.toolbar} />
<Divider />
<List>
<ListItem button key='Home' onClick={() => this.nav('Home')}>
<ListItemIcon><HomeIcon/></ListItemIcon>
<ListItemText primary='Home' />
</ListItem>
<ListItem button key='Report' onClick={() => this.nav('Report')}>
<ListItemIcon><AssignmentIcon/></ListItemIcon>
<ListItemText primary='Report' />
</ListItem>
<ListItem button key='Map' onClick={() => this.nav('Map')}>
<ListItemIcon><MapIcon/></ListItemIcon>
<ListItemText primary='Map' />
</ListItem>
<ListItem button key='List' onClick={() => this.nav('List')}>
<ListItemIcon><ListIcon/></ListItemIcon>
<ListItemText primary='List' />
</ListItem>
<ListItem button key='Quiz' onClick={() => this.nav('Quiz')}>
<ListItemIcon><SlideshowIcon/></ListItemIcon>
<ListItemText primary='Quiz' />
</ListItem>
</List>
</div>
);
return ( return (
<div className={classes.root}> <div className={classes.root}>
<AppBar position="static"> <AppBar className={classes.appBar}>
<Tabs value={value} onChange={this.handleChange} centered> <Toolbar>
<Tab label="Home" /> <IconButton
<Tab label="Report a Sighting"/> color="inherit"
<Tab label="Sightings" /> aria-label="Open drawer"
<Tab label="Trail-Cam Quiz" /> onClick={this.handleDrawerToggle}
<Tab label="View Map" /> className={classes.navIconHide}
<Tab label="Marten Info" /> >
</Tabs> <MenuIcon />
</IconButton>
<Typography variant='title' color="inherit" noWrap>
The American Marten
</Typography>
</Toolbar>
</AppBar> </AppBar>
{value === 0 && <Home/>} <Hidden mdUp>
{value === 1 && <Report/>} <Drawer
{value === 2 && <SightingList/>} variant="temporary"
{value === 3 && <Quiz/>} anchor={theme.direction === 'rtl' ? 'right' : 'left'}
{value === 4 && <ViewMap/>} open={this.state.mobileOpen}
{value === 5 && <Info/>} onClose={this.handleDrawerToggle}
classes={{
paper: classes.drawerPaper,
}}
ModalProps={{
keepMounted: true, // Better open performance on mobile.
}}
>
{drawer}
</Drawer>
</Hidden>
<Hidden smDown implementation="css">
<Drawer
variant="permanent"
open
classes={{
paper: classes.drawerPaper,
}}
>
{drawer}
</Drawer>
</Hidden>
<div className={classes.toolbar} />
{this.state.key === 'Home' && <Home />}
{this.state.key === 'Report' && <Report />}
{this.state.key === 'Map' && <ViewMap />}
{this.state.key === 'List' && <SightingList />}
{this.state.key === 'Quiz' && <Quiz />}
</div> </div>
); );
} }
} }
SimpleTabs.propTypes = { ResponsiveDrawer.propTypes = {
classes: PropTypes.object.isRequired, classes: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired,
}; };
export default withStyles(styles)(SimpleTabs); export default withStyles(styles, { withTheme: true })(ResponsiveDrawer);

View File

@ -17,6 +17,7 @@ const styles = theme => ({
container: { container: {
display: 'flex', display: 'flex',
flexWrap: 'wrap', flexWrap: 'wrap',
marginTop: '64px'
}, },
textField: { textField: {
marginLeft: theme.spacing.unit * 2, marginLeft: theme.spacing.unit * 2,