Skip to content
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

feat: Add LTC facilities map #1703

Merged
merged 58 commits into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
06b06fe
chore: Add LTC map
kevee Dec 24, 2020
7870a10
chore: Move to build step
kevee Dec 25, 2020
71e0def
chore: Add electron dep
kevee Dec 25, 2020
8e2b5fd
chore: Fix mapbox version
kevee Dec 25, 2020
0ad18d8
chore: Set zoom level to 6
kevee Dec 25, 2020
e05a9b4
chore: Add layer toggle
kevee Dec 25, 2020
c814da7
chore: Set facilities regardless of layer
kevee Dec 25, 2020
adfe372
Merge remote-tracking branch 'origin/master' into feature/ltc-facilit…
kevee Jan 6, 2021
89e0fd1
chore: Change no-data background
kevee Jan 6, 2021
26686cf
chore: Darken legend
kevee Jan 6, 2021
f1832d4
Merge branch 'master' into feature/ltc-facilities-map
kevee Jan 6, 2021
51fc2ab
chore: Merge map components between LTC and HHS
kevee Jan 6, 2021
953fc97
Merge branch 'feature/ltc-facilities-map' of https://github.com/COVID…
kevee Jan 6, 2021
fb2924d
Merge remote-tracking branch 'origin/master' into feature/ltc-facilit…
kevee Feb 2, 2021
52e1c70
chore: Sync up legend
kevee Feb 2, 2021
b456e4d
chore: Add cms layer
kevee Feb 5, 2021
bfc3aa0
Merge branch 'master' into feature/ltc-facilities-map
kevee Feb 5, 2021
dd613b4
chore: Add CMS detail view
kevee Feb 5, 2021
36b0c13
chore: Fix infobox
kevee Feb 5, 2021
fa52bf6
chore: Fix sidebar for CMS deaths
kevee Feb 5, 2021
9b99b24
chore: Just use CMS cases
kevee Feb 5, 2021
c8412fb
chore: Remove death layer
kevee Feb 5, 2021
9102899
chore: Change to four-layer map
kevee Feb 9, 2021
5ade573
chore: Change base layers
kevee Feb 10, 2021
d2dce6e
chore: Add outbreak res & staff
kevee Feb 10, 2021
7d82018
chore: Typo U
kevee Feb 10, 2021
eed9f0a
chore: Change to radius for sidebar
kevee Feb 10, 2021
184f6a5
chore: Fix data event
kevee Feb 10, 2021
410657c
chore: Change to total covid-19 in CMS
kevee Feb 10, 2021
d6f2153
chore: Remove federal layer
kevee Feb 10, 2021
9ecf4ef
feat: Add facilities map to state pages
kevee Feb 10, 2021
74d946e
chore: Add legend
kevee Feb 10, 2021
d52e90f
chore: Fix missing state center
kevee Feb 10, 2021
8ec6135
chore: Default zoom
kevee Feb 10, 2021
b8b8308
chore: Add definitions, copy
kevee Feb 11, 2021
bee6771
chore: Tweaks to UI
kevee Feb 11, 2021
fe8bb14
Merge branch 'master' into feature/ltc-facilities-map
kevee Feb 11, 2021
45fff1b
chore: Fix cae
kevee Feb 15, 2021
eb2c2d3
Merge branch 'master' into feature/ltc-facilities-map
kevee Feb 15, 2021
3aaf001
chore: Move definitions
kevee Feb 15, 2021
28a788f
Merge branch 'feature/ltc-facilities-map' of https://github.com/COVID…
kevee Feb 15, 2021
9b7bb51
chore: fix the legend
kevee Feb 15, 2021
daf5c4c
chore: Add map button
kevee Feb 15, 2021
9ac658c
Merge branch 'master' into feature/ltc-facilities-map
kevee Feb 16, 2021
ec2535a
chore: Add state to facility card
kevee Feb 16, 2021
2835847
chore: Hash out states with no data for a certain layer
kevee Feb 16, 2021
e303c9e
fix: Label in infobox
kevee Feb 17, 2021
b175b8b
chore: Fix link to defintiions
kevee Feb 17, 2021
efeaa04
chore: Add assessment level to map
kevee Feb 17, 2021
98ff1f8
chore: Remove alert part
kevee Feb 17, 2021
c09a5b7
chore: Fix staff positive
kevee Feb 17, 2021
e503727
chore: Add state name
kevee Feb 17, 2021
836cd32
chore: Change logic for case/death card
kevee Feb 17, 2021
63b6a60
chore: Add state to infobox
kevee Feb 18, 2021
34f123d
chore: Remove sidebar numbers
kevee Feb 18, 2021
1579c64
Merge branch 'master' into feature/ltc-facilities-map
kevee Feb 18, 2021
581443c
chore: Change order of address
kevee Feb 18, 2021
7e8c47d
Merge branch 'feature/ltc-facilities-map' of https://github.com/COVID…
kevee Feb 18, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/components/common/map/infobox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React, { useContext } from 'react'
import MapContext from './map-context'
import infoboxStyle from './infobox.module.scss'

const Infobox = ({ children }) => {
const mapContext = useContext(MapContext)

return (
<div
className={infoboxStyle.infobox}
style={{
left: Math.max(10, mapContext.infoboxPosition.x - 175),
top: mapContext.infoboxPosition.y + 15,
}}
>
{children}
</div>
)
}

export default Infobox
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@include padding(16);
@include type-size(100);
h3 {
@include type-size(100);
@include type-size(200);
font-weight: bold;
&:first-child {
margin-top: 0;
Expand Down
28 changes: 28 additions & 0 deletions src/components/common/map/layer-toggle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React, { useContext } from 'react'
import MapContext from './map-context'
import toggleStyle from './layer-toggle.module.scss'

const LayerToggle = ({ layers }) => {
const mapContext = useContext(MapContext)
return (
<div
className={toggleStyle.toggle}
role="group"
aria-label="Toggle map layers"
>
{layers.map(layer => (
<button
className={mapContext.mapLayer === layer.id && toggleStyle.active}
type="button"
onClick={() => {
mapContext.setMapLayer(layer.id)
}}
>
{layer.name}
</button>
))}
</div>
)
}

export default LayerToggle
30 changes: 30 additions & 0 deletions src/components/common/map/layer-toggle.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.toggle {
cursor: pointer;
display: flex;
width: fit-content;
button {
@include remove-button-style();
color: $color-slate-600;
border: solid $color-slate-200 2px;
font-weight: initial;
&:before {
display: block;
content: attr(title);
font-weight: 700;
height: 0;
overflow: hidden;
visibility: hidden;
}
@include type-size(100);
margin: -1px; // ignore-style-rule
padding: 2px 15px; // ignore-style-rule
white-space: nowrap;

&.active {
color: black;
border: solid black 2px;
font-weight: 700;
z-index: 1;
}
}
}
5 changes: 5 additions & 0 deletions src/components/common/map/map-context.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createContext } from 'react'

const MapContext = createContext()

export default MapContext
29 changes: 29 additions & 0 deletions src/components/common/map/overlay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react'
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
import overlayStyles from './overlay.module.scss'

const Overlay = ({ children, close }) => (
<>
<div
role="dialog"
className={overlayStyles.overlay}
onClick={() => close()}
onKeyDown={() => close()}
/>
<div className={overlayStyles.card} role="dialog">
<button
className={overlayStyles.close}
type="button"
onClick={event => {
event.preventDefault()
close()
}}
>
&times;
</button>
<div>{children}</div>
</div>
</>
)

export default Overlay
41 changes: 41 additions & 0 deletions src/components/common/map/overlay.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.overlay {
width: 0;
position: absolute;
height: 100%;
top: 0;
bottom: 0;
right: 0;
z-index: 1000;
background: rgba(0, 0, 0, 0.4);
box-shadow: inset 3px 0px 6px -2px rgba(0, 0, 0, 0.8);
@media (min-width: $viewport-md) {
width: 10%;
}
}

.card {
position: absolute;
width: 100%;
height: 100%;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 1000;
overflow-y: scroll;
background: white;
border-left: 1px solid $color-slate-100;
@include padding(16);

@media (min-width: $viewport-md) {
width: 90%;
}
h2 {
margin-top: 0;
}
.close {
@include remove-button-style();
float: right;
@include type-size(600);
}
}
66 changes: 66 additions & 0 deletions src/components/common/map/sidebar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React, { useState } from 'react'
import { Form, Input } from '~components/common/form'
import { Row, Col } from '~components/common/grid'
import sidebarStyle from './sidebar.module.scss'

const Sidebar = ({ children, map }) => {
const [query, setQuery] = useState(false)

return (
<div className={sidebarStyle.sidebar}>
<Form
onSubmit={event => {
event.preventDefault()
if (
typeof window === 'undefined' ||
typeof window.fetch === 'undefined'
) {
return
}
window
.fetch(
`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(
query,
)}.json?limit=1&access_token=${
process.env.GATSBY_MAPBOX_API_TOKEN
}`,
)
.then(response => response.json())
.then(response => {
if (response.features.length === 0) {
return
}
const feature = response.features.pop()
map.easeTo({
center: feature.center,
zoom: 7,
})
})
}}
noMargin
>
<Row>
<Col width={[4, 6, 8]}>
<Input
type="text"
label="Search facilities"
placeholder="Enter a city or zip code"
hideLabel
onChange={event => {
setQuery(event.target.value)
}}
/>
</Col>
<Col width={[4, 6, 4]} paddingLeft={[0, 0, 8]}>
<button type="submit" className={sidebarStyle.searchButton}>
Search
</button>
</Col>
</Row>
</Form>
{children}
</div>
)
}

export default Sidebar
40 changes: 40 additions & 0 deletions src/components/common/map/sidebar.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.sidebar {
box-sizing: border-box;
flex: 0 0 auto;
width: 100%;
order: 1;
input[type='text'] {
margin-bottom: 0;
}
p {
@include margin(16, left);
}
table {
overflow-y: scroll;
&[aria-hidden] {
margin-bottom: 0;
}
th {
padding-top: 0;
}
button {
@include remove-button-style();
text-align: left;
text-decoration: underline;
cursor: pointer;
}
}
form {
background: $color-slate-100;
@include padding(16, top left right);
}
@media (min-width: $viewport-md) {
order: 0;
max-width: 25%;
flex-basis: 25%;
}
@media (min-width: $viewport-lg) {
max-width: 30%;
flex-basis: 30%;
}
}
17 changes: 17 additions & 0 deletions src/components/common/map/wrapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react'
import classnames from 'classnames'
import wrapperStyle from './wrapper.module.scss'

const Wrapper = ({ children, fullWidth = false }) => (
<div
className={classnames(
wrapperStyle.wrapper,
fullWidth && wrapperStyle.fullWidth,
)}
role="img"
>
<div className={wrapperStyle.inset}>{children}</div>
</div>
)

export default Wrapper
33 changes: 33 additions & 0 deletions src/components/common/map/wrapper.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.wrapper {
box-sizing: border-box;
flex: 0 0 auto;
width: 100%;
order: 0;
@media (min-width: $viewport-md) {
order: 1;
max-width: 75%;
flex-basis: 75%;
}
@media (min-width: $viewport-lg) {
max-width: 70%;
flex-basis: 70%;
}
&.full-width {
@media (min-width: $viewport-md) {
order: 1;
max-width: 100%;
flex-basis: 100%;
}
@media (min-width: $viewport-lg) {
max-width: 100%;
flex-basis: 100%;
}
}
}

.inset {
position: relative;
flex: 1 0 auto;
width: 100%;
height: 80vh;
}
Loading