Skip to content

Commit

Permalink
merge dev
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkendis committed Jan 7, 2021
2 parents d4a3890 + 189789c commit 76f7332
Show file tree
Hide file tree
Showing 27 changed files with 434 additions and 101 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/create_release_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ jobs:
run: |
echo GITHUB_CODE_VERSION=${{ env.BRANCH_NAME }} >> server/api/.env
echo GITHUB_SHA=${{ github.sha }} >> server/api/.env
echo DEBUG=True
echo DEBUG=True >> server/api/.env
echo DB_ECHO=True >> server/api/.env
- name: Build and Push Image to Docker Hub
uses: docker/build-push-action@v1
with:
Expand Down
24 changes: 24 additions & 0 deletions client/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,56 @@ import PropTypes from 'proptypes';
import { BrowserRouter } from 'react-router-dom';
import { connect } from 'react-redux';
import { getMetadataRequest } from '@reducers/metadata';
import { toggleMenu as reduxToggleMenu } from '@reducers/ui';
import { useSwipeable } from 'react-swipeable';

import Header from '@components/Header';
import Footer from '@components/Footer';
import Routes from './Routes';

const menuStyles = {
swipeAreaOpen: {
float: 'left',
position: 'fixed',
width: 150,
height: '100%',
},
};

const App = ({
getMetadata,
toggleMenu,
}) => {
useEffect(() => {
getMetadata();
});

const handleSwipeMenu = useSwipeable({
trackMouse: true,
onSwipedRight: () => toggleMenu(),
onSwipedLeft: () => toggleMenu(),
});

return (
<BrowserRouter>
<Header />
<Routes />
{/* area where you can swipe the menu sidebar */}
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
<div {...handleSwipeMenu} style={menuStyles.swipeAreaOpen} />
<Footer />
</BrowserRouter>
);
};

const mapDispatchToProps = dispatch => ({
getMetadata: () => dispatch(getMetadataRequest()),
toggleMenu: () => dispatch(reduxToggleMenu()),
});

export default connect(null, mapDispatchToProps)(App);

App.propTypes = {
getMetadata: PropTypes.func.isRequired,
toggleMenu: PropTypes.func.isRequired,
};
23 changes: 18 additions & 5 deletions client/components/FilterMenu/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import React, { useState } from 'react';
import PropTypes from 'proptypes';
import { connect } from 'react-redux';
import { toggleMenu as reduxToggleMenu } from '@reducers/ui';
import { makeStyles } from '@material-ui/core/styles';

import Card from '@material-ui/core/Card';
import CardHeader from '@material-ui/core/CardHeader';
import CardContent from '@material-ui/core/CardContent';
Expand All @@ -18,6 +22,7 @@ const useStyles = makeStyles(theme => ({
left: 35,
top: 75,
borderRadius: 10,
zIndex: 2000,
},
header: {
color: theme.palette.text.cyan,
Expand Down Expand Up @@ -46,7 +51,9 @@ const useStyles = makeStyles(theme => ({
},
}));

const FilterMenu = () => {
const FilterMenu = ({
toggleMenu,
}) => {
const [expanded, setExpanded] = useState(false);
const classes = useStyles();

Expand All @@ -62,9 +69,7 @@ const FilterMenu = () => {
<>
<GearButton
aria-label="toggle map menu"
// TODO: toggle left slider menu
// eslint-disable-next-line
onClick={() => console.log('toggle left slider')}
onClick={toggleMenu}
/>
<Typography
className={classes.headerTitle}
Expand Down Expand Up @@ -95,4 +100,12 @@ const FilterMenu = () => {
);
};

export default FilterMenu;
const mapDispatchToProps = dispatch => ({
toggleMenu: () => dispatch(reduxToggleMenu()),
});

export default connect(null, mapDispatchToProps)(FilterMenu);

FilterMenu.propTypes = {
toggleMenu: PropTypes.func.isRequired,
};
6 changes: 5 additions & 1 deletion client/components/GearButton/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ const useStyles = makeStyles(theme => ({
},
}));

const GearButton = ({ onClick }) => {
const GearButton = ({
onClick,
}) => {
const { gearIcon, button } = useStyles();
const [pressed, setPressed] = useState(false);

Expand All @@ -32,10 +34,12 @@ const GearButton = ({ onClick }) => {
onClick();
}
};

const toggleClick = () => {
setPressed(!pressed);
onClick();
};

return (
<IconButton
className={button}
Expand Down
253 changes: 253 additions & 0 deletions client/components/LeftDrawer/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
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,
zIndex: 2100,
},
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);
Loading

0 comments on commit 76f7332

Please sign in to comment.