-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add background maps selector component. Currently with hardcod…
…ed data...
- Loading branch information
Showing
2 changed files
with
130 additions
and
2 deletions.
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
75 changes: 75 additions & 0 deletions
75
src/renderer/components/MapFilter/MapView/MapPreviewCard.js
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,75 @@ | ||
import { Box, Typography, makeStyles, useTheme } from '@material-ui/core' | ||
import React from 'react' | ||
import ReactMapboxGl from 'react-mapbox-gl' | ||
|
||
import { MAPBOX_ACCESS_TOKEN } from '../../../../../config' | ||
|
||
export const MapboxPreview = ReactMapboxGl({ | ||
accessToken: MAPBOX_ACCESS_TOKEN, | ||
dragRotate: false, | ||
pitchWithRotate: false, | ||
attributionControl: false, | ||
injectCSS: false | ||
}) | ||
|
||
export const MapPreviewCard = ({ onClick, selected, styleUrl, title }) => { | ||
const classes = useStyles() | ||
const theme = useTheme() | ||
|
||
return ( | ||
<> | ||
<button className={classes.container} onClick={onClick}> | ||
<div | ||
style={{ | ||
borderColor: selected | ||
? theme.palette.primary.main | ||
: theme.palette.common.white | ||
}} | ||
className={classes.inner} | ||
> | ||
<MapboxPreview | ||
className={classes.thumbnail} | ||
containerStyle={{ | ||
pointerEvents: 'none' | ||
}} | ||
style={styleUrl} | ||
center={[-75, -0]} | ||
zoom={[0]} | ||
/> | ||
</div> | ||
{title && <Typography className={classes.title}>{title}</Typography>} | ||
</button> | ||
</> | ||
) | ||
} | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
container: { | ||
alignItems: 'center', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
cursor: 'pointer', | ||
backgroundColor: 'transparent', | ||
border: 'none' | ||
}, | ||
inner: { | ||
borderRadius: 12, | ||
borderStyle: 'solid', | ||
marginBottom: 10, | ||
borderWidth: 4, | ||
overflow: 'hidden' | ||
}, | ||
thumbnail: { | ||
height: 80, | ||
width: 80, | ||
cursor: 'pointer', | ||
'& .mapboxgl-control-container': { | ||
display: 'none' | ||
} | ||
}, | ||
title: { | ||
textAlign: 'center', | ||
fontSize: 16, | ||
maxWidth: 80 | ||
} | ||
})) |