-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/ltc-facilities-map' of https://github.com/COVID…
…19tracking/website into feature/ltc-facilities-map
- Loading branch information
Showing
20 changed files
with
508 additions
and
96 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React from 'react' | ||
import classnames from 'classnames' | ||
|
||
import { Col } from '~components/common/grid' | ||
|
||
import styles from './chart-legend.module.scss' | ||
|
||
const ChartLegend = ({ | ||
legendColors, | ||
categories, | ||
selectedItem, | ||
setSelectedItem, | ||
legendNames, | ||
}) => { | ||
/** | ||
* Gets the appropriate classes for a legend item, based on the | ||
* item's category name. | ||
*/ | ||
const getCategoryStyles = categoryName => { | ||
if (selectedItem && categoryName === selectedItem) { | ||
return classnames(styles.category, styles.activeCategory) | ||
} | ||
return styles.category | ||
} | ||
|
||
return ( | ||
<Col width={[4, 6, 6]} className={styles.columnWrapper}> | ||
<div className={styles.legend}> | ||
{categories.map(category => ( | ||
<button | ||
className={getCategoryStyles(category)} | ||
onClick={() => setSelectedItem(category)} | ||
type="button" | ||
> | ||
<div | ||
style={{ 'background-color': legendColors[category] }} | ||
className={styles.swatch} | ||
/> | ||
{legendNames[category]} | ||
</button> | ||
))} | ||
{selectedItem ? ( | ||
<button | ||
onClick={() => setSelectedItem(null)} | ||
type="button" | ||
className={styles.resetButton} | ||
> | ||
Clear filter | ||
</button> | ||
) : ( | ||
// this is a placeholder for the reset button so that the page doesn't | ||
// jump when selectedItem goes from null to not null | ||
<div className={styles.resetButton}> </div> | ||
)} | ||
</div> | ||
</Col> | ||
) | ||
} | ||
|
||
export default ChartLegend |
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,56 @@ | ||
.column-wrapper { | ||
margin: 0 auto; | ||
} | ||
|
||
.legend { | ||
@media (min-width: $viewport-md) { | ||
display: grid; | ||
grid-template-columns: auto auto; | ||
grid-auto-rows: 1fr; | ||
grid-column-gap: 1rem; | ||
grid-row-gap: 0.5rem; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.category, | ||
.reset-button { | ||
border: none; | ||
background: inherit; | ||
cursor: pointer; | ||
} | ||
|
||
.category { | ||
display: flex; | ||
align-items: center; | ||
|
||
@media (max-width: $viewport-lg) { | ||
@include margin(0, right); | ||
@include margin(16, bottom); | ||
} | ||
|
||
@include margin(32, right); | ||
text-align: left; | ||
|
||
&:last-child { | ||
@include margin(0, right); | ||
} | ||
|
||
.swatch { | ||
flex-shrink: 0; | ||
@include margin(8, right); | ||
width: 12px; | ||
height: 12px; | ||
} | ||
} | ||
|
||
.active-category { | ||
font-weight: bold; | ||
} | ||
|
||
.reset-button { | ||
color: $color-slate-700; | ||
text-decoration: underline; | ||
grid-column: span 2; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -182,6 +182,5 @@ const MultiLineChart = ({ | |
</> | ||
) | ||
} | ||
// todo don't just use red | ||
|
||
export default MultiLineChart |
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
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,11 @@ | ||
import React from 'react' | ||
import { Link } from 'gatsby' | ||
|
||
const NoDataAlert = ({ state, dataType, metric }) => ( | ||
<span> | ||
{state} does not report {dataType.toLowerCase()} data for {metric}.{' '} | ||
<Link to="/race/get-better-data">Help us get better data.</Link> | ||
</span> | ||
) | ||
|
||
export default NoDataAlert |
46 changes: 46 additions & 0 deletions
46
src/components/pages/state/race-ethnicity/chart-section.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,46 @@ | ||
import React from 'react' | ||
|
||
import { Col } from '~components/common/grid' | ||
import ChartLegend from '~components/charts/chart-legend' | ||
|
||
import styles from './chart-section.module.scss' | ||
|
||
const ChartSection = ({ | ||
title, | ||
children, | ||
legendCategories, | ||
selectedItem, | ||
setSelectedItem, | ||
legendColors, | ||
legendRef, | ||
}) => { | ||
const categoryNames = { | ||
White: 'White', | ||
Black: 'Black or African American', | ||
LatinX: 'Hispanic or Latino', | ||
Asian: 'Asian', | ||
AIAN: 'American Indian and Alaskan Native', | ||
NHPI: 'Native Hawaiian and Other Pacific Islander', | ||
Ethnicity_Hispanic: 'Hispanic or Latino', | ||
Ethnicity_NonHispanic: 'Not Hispanic or Latino', | ||
} | ||
return ( | ||
<div className={styles.chartSection}> | ||
<h3 className={styles.chartSectionTitle}>{title}</h3> | ||
<Col width={[4, 4, 6]} className={styles.column}> | ||
{children} | ||
</Col> | ||
<div ref={legendRef}> | ||
<ChartLegend | ||
legendColors={legendColors} | ||
categories={legendCategories} | ||
selectedItem={selectedItem} | ||
setSelectedItem={setSelectedItem} | ||
legendNames={categoryNames} | ||
/> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default ChartSection |
20 changes: 20 additions & 0 deletions
20
src/components/pages/state/race-ethnicity/chart-section.module.scss
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,20 @@ | ||
.chart-section > div > svg { | ||
width: 50%; | ||
margin: 0 auto; | ||
display: block; | ||
} | ||
|
||
.chart-section-title { | ||
@include type-size(400); | ||
text-align: center; | ||
@include margin(0, bottom); | ||
} | ||
|
||
.column { | ||
margin: 0 auto; | ||
|
||
text { | ||
// The axis labels get very large on big screens without this rule. | ||
font-size: 9px; // ignore-style-rule | ||
} | ||
} |
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
Oops, something went wrong.