-
-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
836 map setting menu left drawer #875
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7b65095
WIP left drawer
Tanvez f0d3fcf
Merge dev branch
Tanvez 80f8c8d
Revert "Merge dev branch"
Tanvez 2414f00
Add drawer list item, swipe functionality and esc button press
Tanvez f56ba58
Change isOpen to false in reducers
Tanvez 1ba4784
Add selected colors for menu
Tanvez f8d9d70
Merge with dev
Tanvez f00bec6
Refactor gear icon and styling to fit left drawer
Tanvez be219a3
linting
adamkendis 97ed526
fix eslint errors
Tanvez e94d279
Fix keydown to keypress and remove unused styles
Tanvez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,252 @@ | ||
import React from 'react'; | ||
import PropTypes from 'proptypes'; | ||
import { makeStyles, useTheme } from '@material-ui/core/styles'; | ||
import Drawer from '@material-ui/core/Drawer'; | ||
import CssBaseline from '@material-ui/core/CssBaseline'; | ||
import List from '@material-ui/core/List'; | ||
import Divider from '@material-ui/core/Divider'; | ||
import IconButton from '@material-ui/core/IconButton'; | ||
import ChevronLeftIcon from '@material-ui/icons/ChevronLeft'; | ||
import ChevronRightIcon from '@material-ui/icons/ChevronRight'; | ||
import ListItem from '@material-ui/core/ListItem'; | ||
import ListItemIcon from '@material-ui/core/ListItemIcon'; | ||
import ListItemText from '@material-ui/core/ListItemText'; | ||
import LinkIcon from '@material-ui/icons/Link'; | ||
import { connect } from 'react-redux'; | ||
import { toggleMenu as reduxToggleMenu } from '@reducers/ui'; | ||
import Radio from '@material-ui/core/Radio'; | ||
|
||
const drawerWidth = 275; | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
root: { | ||
display: 'flex', | ||
}, | ||
menuButton: { | ||
marginRight: theme.spacing(2), | ||
}, | ||
hide: { | ||
display: 'none', | ||
}, | ||
drawer: { | ||
width: drawerWidth, | ||
flexShrink: 0, | ||
}, | ||
drawerPaper: { | ||
width: drawerWidth, | ||
backgroundColor: '#2A404E', | ||
}, | ||
content: { | ||
flexGrow: 1, | ||
padding: theme.spacing(3), | ||
transition: theme.transitions.create('margin', { | ||
easing: theme.transitions.easing.sharp, | ||
duration: theme.transitions.duration.leavingScreen, | ||
}), | ||
marginLeft: -drawerWidth, | ||
}, | ||
share: { | ||
marginBottom: '100px', | ||
paddingLeft: '25px', | ||
}, | ||
listItem: { | ||
paddingTop: '15px', | ||
paddingBottom: '15px', | ||
height: '24px', | ||
}, | ||
listItemTitle: { | ||
paddingLeft: '28px', | ||
}, | ||
})); | ||
|
||
const PersistentDrawerLeft = ({ menuIsOpen, toggleMenu }) => { | ||
// TODO ADD FUNCTIONALITY | ||
const [selectedMapStyleValue, setMapStyleValue] = React.useState('Point Map'); | ||
const [selectedMapModeValue, setMapModeValue] = React.useState('Dark'); | ||
const [selectedDataColorScheme, setDataColorScheme] = React.useState('Original'); | ||
const [selectedBoundariesValue, setBoundariesValue] = React.useState('None'); | ||
|
||
const handleChangeMapStyle = event => { | ||
setMapStyleValue(event.target.value); | ||
}; | ||
|
||
const handleChangeMapMode = event => { | ||
setMapModeValue(event.target.value); | ||
}; | ||
|
||
const handleChangeDataColorScheme = event => { | ||
setDataColorScheme(event.target.value); | ||
}; | ||
|
||
const handleChangeBoundaries = event => { | ||
setBoundariesValue(event.target.value); | ||
}; | ||
|
||
const classes = useStyles(); | ||
const theme = useTheme(); | ||
|
||
const onClickShare = () => { | ||
// TODO ADD FUNCTIONALITY | ||
}; | ||
|
||
const escFunction = e => { | ||
e.preventDefault(); | ||
if (e.key === 'Escape' | ||
) { | ||
toggleMenu(); | ||
} | ||
}; | ||
|
||
React.useEffect(() => { | ||
document.addEventListener('keypress', escFunction, false); | ||
return () => { | ||
document.removeEventListener('keypress', escFunction, false); | ||
}; | ||
}, [escFunction]); | ||
|
||
return ( | ||
<div className={classes.root}> | ||
<CssBaseline /> | ||
<Drawer | ||
className={classes.drawer} | ||
variant="persistent" | ||
anchor="left" | ||
open={menuIsOpen} | ||
classes={{ | ||
paper: classes.drawerPaper, | ||
}} | ||
> | ||
<div className={classes.drawerHeader}> | ||
<IconButton onClick={toggleMenu}> | ||
{theme.direction === 'ltr' ? <ChevronLeftIcon /> : <ChevronRightIcon />} | ||
</IconButton> | ||
</div> | ||
<Divider /> | ||
<List> | ||
<ListItem key="Map Style" className={classes.listItemTitle}> | ||
<ListItemText primary="Map Style" /> | ||
</ListItem> | ||
{['Point Map', 'Heat Map'].map(text => ( | ||
<ListItem className={classes.listItem} style={{ color: selectedMapStyleValue === text && '#87C8BC' }} button key={text}> | ||
<ListItemIcon> | ||
<Radio | ||
checked={selectedMapStyleValue === text} | ||
onChange={handleChangeMapStyle} | ||
value={text} | ||
style={{ color: selectedMapStyleValue === text && '#87C8BC' }} | ||
name="radio-button" | ||
inputProps={{ 'aria-label': text }} | ||
/> | ||
</ListItemIcon> | ||
<ListItemText primary={text} /> | ||
</ListItem> | ||
))} | ||
</List> | ||
<Divider /> | ||
{ | ||
/** | ||
* TODO ADD DYNAMIC LIST OF ITEMS | ||
* ADD COLOR TO RADIO BUTTONS | ||
*/ | ||
} | ||
<List> | ||
<ListItem key="Map Mode" className={classes.listItemTitle}> | ||
<ListItemText primary="Map Mode" /> | ||
</ListItem> | ||
{['Dark', 'Light', 'Street'].map(text => ( | ||
<ListItem style={{ color: selectedMapModeValue === text && '#87C8BC' }} button key={text} className={classes.listItem}> | ||
<ListItemIcon> | ||
<Radio | ||
checked={selectedMapModeValue === text} | ||
onChange={handleChangeMapMode} | ||
value={text} | ||
style={{ color: selectedMapModeValue === text && '#87C8BC' }} | ||
name="radio-button" | ||
inputProps={{ 'aria-label': text }} | ||
/> | ||
</ListItemIcon> | ||
<ListItemText primary={text} /> | ||
</ListItem> | ||
))} | ||
</List> | ||
<Divider /> | ||
<List> | ||
<ListItem key="Data Color Scheme" className={classes.listItemTitle}> | ||
<ListItemText primary="Data Color Scheme" /> | ||
</ListItem> | ||
{['Original', 'Prism', 'Bold'].map(text => ( | ||
<ListItem | ||
style={{ color: selectedDataColorScheme === text && '#87C8BC' }} | ||
button | ||
key={text} | ||
className={classes.listItem} | ||
> | ||
<ListItemIcon> | ||
<Radio | ||
checked={selectedDataColorScheme === text} | ||
onChange={handleChangeDataColorScheme} | ||
value={text} | ||
style={{ color: selectedDataColorScheme === text && '#87C8BC' }} | ||
name="radio-button" | ||
inputProps={{ 'aria-label': text }} | ||
/> | ||
</ListItemIcon> | ||
<ListItemText primary={text} /> | ||
</ListItem> | ||
))} | ||
</List> | ||
<Divider /> | ||
<List> | ||
<ListItem key="Boundaries" className={classes.listItemTitle}> | ||
<ListItemText primary="Boundaries" /> | ||
</ListItem> | ||
{['None', 'Neighborhood Councils', 'City Councils'].map(text => ( | ||
<ListItem | ||
style={{ color: selectedDataColorScheme === text && '#87C8BC' }} | ||
button | ||
key={text} | ||
className={classes.listItem} | ||
selected={selectedBoundariesValue === text} | ||
> | ||
<ListItemIcon> | ||
<Radio | ||
checked={selectedBoundariesValue === text} | ||
onChange={handleChangeBoundaries} | ||
value={text} | ||
style={{ color: selectedBoundariesValue === text && '#87C8BC' }} | ||
name="radio-button" | ||
inputProps={{ 'aria-label': text }} | ||
/> | ||
</ListItemIcon> | ||
<ListItemText primary={text} /> | ||
</ListItem> | ||
))} | ||
</List> | ||
<Divider /> | ||
<List> | ||
<ListItem key="Share" className={classes.share}> | ||
<ListItemIcon onClick={onClickShare}> | ||
<LinkIcon /> | ||
</ListItemIcon> | ||
<ListItemText primary="Share" /> | ||
</ListItem> | ||
</List> | ||
</Drawer> | ||
</div> | ||
); | ||
}; | ||
|
||
PersistentDrawerLeft.propTypes = { | ||
menuIsOpen: PropTypes.bool.isRequired, | ||
toggleMenu: PropTypes.func.isRequired, | ||
}; | ||
|
||
const mapStateToProps = state => ({ | ||
menuIsOpen: state.ui.menu.isOpen, | ||
}); | ||
|
||
const mapDispatchToProps = dispatch => ({ | ||
toggleMenu: () => dispatch(reduxToggleMenu()), | ||
}); | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(PersistentDrawerLeft); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like this is preventing the chrome devtools keyboard shortcut from working. a couple options that fixed it, hopefully without causing any side effects:
if
blockkeypress fires after keydown, so maybe that's somehow messing up the shortcut?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will look into it