Skip to content

Commit

Permalink
Merge pull request #1089 from hackforla/1017-FRONT-nc-info
Browse files Browse the repository at this point in the history
Added location info to map
  • Loading branch information
adamkendis authored Apr 22, 2021
2 parents 70c562e + 74a1961 commit cdd06d3
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 15 deletions.
83 changes: 83 additions & 0 deletions client/components/Map/LocationDetail.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import React from 'react';
import PropTypes from 'prop-types';
import { makeStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
import Link from '@material-ui/core/Link';
import Box from '@material-ui/core/Box';

const useStyles = makeStyles(theme => ({
locationInfo: {
borderRadius: 10,
width: 325,
backgroundColor: theme.palette.primary.main,
padding: 15,
marginTop: theme.gaps.xs,
},
header: {
color: theme.palette.text.cyan,
letterSpacing: '2px',
},
subheader: {
...theme.typography.body2,
color: '#A8A8A8',
},
link: {
...theme.typography.h2,
color: '#ececec',
},
}));

const LocationDetail = ({
address,
nc,
// ccs,
}) => {
const classes = useStyles();

return (
<div className={classes.locationInfo}>
<Typography
className={classes.header}
variant="h1"
component="h2"
>
INFORMATION
</Typography>
{address && (
<Box mt={1}>
<Typography component="div" className={classes.subheader}>Address:</Typography>
<Typography component="span">{address}</Typography>
</Box>
)}
{nc && (
<Box mt={1}>
<Typography component="div" className={classes.subheader}>Neighborhood Council District:</Typography>
<Link
className={classes.link}
href={nc.website}
target="_blank"
rel="noopener"
underline="always"
>
{nc.councilName}
</Link>
</Box>
)}
</div>
);
};

export default LocationDetail;

LocationDetail.propTypes = {
address: PropTypes.string,
nc: PropTypes.shape({
website: PropTypes.string,
councilName: PropTypes.string,
}),
};

LocationDetail.defaultProps = {
address: undefined,
nc: null,
};
23 changes: 10 additions & 13 deletions client/components/Map/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { connect } from 'react-redux';
import { withStyles } from '@material-ui/core/styles';
import mapboxgl from 'mapbox-gl';
import FilterMenu from '@components/main/Desktop/FilterMenu';
import LocationDetail from './LocationDetail';

import { REQUEST_TYPES } from '@components/common/CONSTANTS';
import { getNcByLngLat, setSelectedNcId } from '@reducers/data';
Expand Down Expand Up @@ -87,13 +88,6 @@ const styles = theme => ({
left: 35,
top: 75,
},
locationInfo: {
marginTop: 5,
borderRadius: 10,
width: 325,
backgroundColor: theme.palette.primary.main,
padding: 10,
},
})

class Map extends React.Component {
Expand All @@ -114,6 +108,7 @@ class Map extends React.Component {
mapStyle: 'streets',
canReset: true,
selectedRequestId: null,
selectedNc: null,
requests: props.requests,
};

Expand Down Expand Up @@ -215,6 +210,12 @@ class Map extends React.Component {
}
});
}

if (this.props.selectedNcId !== prevProps.selectedNcId) {
const { councils, selectedNcId } = this.props;
const nc = councils.find(({ councilId }) => councilId === selectedNcId);
this.setState({ selectedNc: nc });
}
}

initLayers = addListeners => {
Expand Down Expand Up @@ -494,6 +495,7 @@ class Map extends React.Component {
// hoveredRegionName,
canReset,
selectedRequestId,
selectedNc,
selectedTypes,
address,
} = this.state;
Expand Down Expand Up @@ -547,12 +549,7 @@ class Map extends React.Component {
canReset={!!filterGeo && canReset}
/>
<FilterMenu />
<div className={classes.locationInfo}>
<div>Placeholder</div>
TODO: Add NC/CC, links
{address && <p>Address: {address}</p>}
{selectedNcId && <p>ncId: {selectedNcId}</p>}
</div>
<LocationDetail address={address} nc={selectedNc} />
</div>
{/* <MapLayers
selectedTypes={selectedTypes}
Expand Down
2 changes: 1 addition & 1 deletion client/components/main/Desktop/FilterMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ const useStyles = makeStyles(theme => ({
},
headerTitle: {
...theme.typography.h1,
marginLeft: theme.gaps.xs,
fontWeight: 600,
letterSpacing: '2px',
marginLeft: theme.gaps.xs,
},
headerContent: {
display: 'flex',
Expand Down
1 change: 0 additions & 1 deletion client/theme/typography.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default {
h2: {
fontSize: 18,
fontWeight: robotoMedium,

},
h3: {
fontFamily: oswald,
Expand Down

0 comments on commit cdd06d3

Please sign in to comment.