Skip to content

Commit

Permalink
chore: Add screenshot YAML config
Browse files Browse the repository at this point in the history
  • Loading branch information
kevee committed Dec 15, 2020
1 parent 4db04a8 commit a460c56
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 64 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public
# Data API build directory
_data
_api
_screenshots

# Storybook build
storybook-static
Expand Down
8 changes: 8 additions & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ const gatsbyConfig = {
'gatsby-plugin-sharp',
'gatsby-transformer-sharp',
'gatsby-plugin-svgr',
'gatsby-transformer-yaml',
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'screenshotConfig',
path: `${__dirname}/_screenshots/configs/taco`,
},
},
{
resolve: 'gatsby-plugin-google-analytics-gdpr',
options: {
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@
"gatsby-remark-autolink-headers": "^2.3.14",
"gatsby-remark-smartypants": "^2.3.12",
"gatsby-source-contentful": "4.0.0",
"gatsby-source-filesystem": "^2.3.31",
"gatsby-source-filesystem": "^2.8.0",
"gatsby-transformer-remark": "^2.8.36",
"gatsby-transformer-sharp": "^2.5.16",
"gatsby-transformer-yaml": "^2.4.13",
"gatsby-transformer-yaml": "^2.8.0",
"get-contrast": "^2.0.0",
"is-url": "^1.2.4",
"json2csv": "^5.0.1",
Expand Down Expand Up @@ -161,9 +161,10 @@
"test:coverage": "jest --coverage --maxWorkers 1",
"test:lint": "eslint ./src",
"test:dev": "run-s test:lint test",
"setup": "run-s setup:api-repo setup:env-vars setup:data-repo",
"setup": "run-s setup:api-repo setup:env-vars setup:data-repo setup:screenshot-repo",
"setup:env-vars": "curl -L https://covidtracking.com/__developer/env-vars > .env",
"setup:api-repo": "rm -rf _api || true && git clone --depth 1 https://github.com/COVID19Tracking/covid-public-api.git _api && rm -rf _api/.git",
"setup:data-repo": "rm -rf _data || true && git clone --depth 1 --branch data https://github.com/COVID19Tracking/website-data _data && rm -rf _data/.git"
"setup:data-repo": "rm -rf _data || true && git clone --depth 1 --branch data https://github.com/COVID19Tracking/website-data _data && rm -rf _data/.git",
"setup:screenshot-repo": "rm -rf _screenshot || true && git clone --depth 1 https://github.com/COVID19Tracking/screenshots _screenshots && rm -rf _screenshots/.git"
}
}
4 changes: 4 additions & 0 deletions src/components/pages/data/states.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const States = ({
raceDataCombined,
raceDataSeparate,
hhsHospitalization,
screenshotLinks,
}) => {
const stateList = []

Expand Down Expand Up @@ -58,6 +59,9 @@ const States = ({
? hhsHospitalization.find(record => record.nodes[0].state === state.state)
: false

state.links = screenshotLinks
? screenshotLinks.find(item => item.childTacoYaml.state === state.state)
: false
stateList.push(state)
})

Expand Down
7 changes: 3 additions & 4 deletions src/components/pages/state/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from '~components/pages/state/state-links'
import preambleStyle from './preamble.module.scss'

const StatePreamble = ({ state, covidState }) => {
const StatePreamble = ({ state, urls, covidState }) => {
const { contentfulSnippet } = useStaticQuery(
graphql`
query {
Expand All @@ -37,6 +37,7 @@ const StatePreamble = ({ state, covidState }) => {
)
const [stateLinksAreOpen, setStateLinksAreOpen] = useState(false)
const [downloadDataIsOpen, setDownloadDataIsOpen] = useState(false)
const { links } = urls.childTacoYaml
// todo make state grade wrap as a circle with the grade description
return (
<OverviewWrapper className={preambleStyle.preamble}>
Expand All @@ -47,9 +48,7 @@ const StatePreamble = ({ state, covidState }) => {
<h3 className={preambleStyle.header}>Where this data comes from</h3>
<StateLinks
twitter={state.twitter}
covid19Site={state.covid19Site}
covid19SiteSecondary={state.covid19SiteSecondary}
covid19SiteTertiary={state.covid19SiteTertiary}
links={links}
stateName={state.name}
stateSlug={state.childSlug.slug}
/>
Expand Down
32 changes: 15 additions & 17 deletions src/components/pages/state/state-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ import {
import stateLinksStyle from './state-links.module.scss'
import preambleStyle from './preamble.module.scss'

const StateLinks = ({
twitter,
covid19Site,
covid19SiteSecondary,
covid19SiteTertiary,
stateName,
stateSlug,
}) => {
const StateLinks = ({ twitter, stateName, stateSlug, links }) => {
const getLink = type => {
const currentLink = links && links.find(link => link.name === type)
if (!currentLink) {
return false
}
return currentLink.url
}
return (
<div className={stateLinksStyle.container}>
{covid19Site && (
<a href={covid19Site} className={stateLinksStyle.link}>
{getLink('primary') && (
<a href={getLink('primary')} className={stateLinksStyle.link}>
<span>Best current data source</span>
</a>
)}
{covid19SiteSecondary && (
<a href={covid19SiteSecondary} className={stateLinksStyle.link}>
{getLink('secondary') && (
<a href={getLink('secondary')} className={stateLinksStyle.link}>
<span>Secondary data source</span>
</a>
)}
{covid19SiteTertiary && (
<a href={covid19SiteTertiary} className={stateLinksStyle.link}>
{getLink('tertiary') && (
<a href={getLink('tertiary')} className={stateLinksStyle.link}>
<span>Tertiary data source</span>
</a>
)}
Expand Down Expand Up @@ -67,11 +67,9 @@ const StateLinksDisclosurePanel = ({ state }) => (
<DisclosurePanel>
<StateLinks
twitter={state.twitter}
covid19Site={state.covid19Site}
covid19SiteSecondary={state.covid19SiteSecondary}
covid19SiteTertiary={state.covid19SiteTertiary}
stateName={state.name}
stateSlug={state.childSlug.slug}
links={state.links && state.links.childTacoYaml.links}
/>
</DisclosurePanel>
)
Expand Down
14 changes: 12 additions & 2 deletions src/pages/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const DataPage = ({ data }) => {
raceDataCombined={data.allCovidRaceDataCombined.nodes}
raceDataSeparate={data.allCovidRaceDataSeparate.nodes}
hhsHospitalization={data.allHhsHospitalizationCovid.group}
screenshotLinks={data.urls.nodes}
/>
</Layout>
)
Expand Down Expand Up @@ -121,8 +122,6 @@ export const query = graphql`
}
allCovidStateInfo(sort: { fields: name }) {
nodes {
covid19Site
covid19SiteSecondary
name
notes
state
Expand Down Expand Up @@ -318,5 +317,16 @@ export const query = graphql`
}
}
}
urls: allFile {
nodes {
childTacoYaml {
links {
url
name
}
state
}
}
}
}
`
12 changes: 11 additions & 1 deletion src/templates/state/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const StateTemplate = ({ pageContext, data, path }) => {
allTweets,
allCovidAnnotation,
allHhsHospitalizationCovid,
urls,
} = data
return (
<Layout
Expand All @@ -40,7 +41,7 @@ const StateTemplate = ({ pageContext, data, path }) => {
path={path}
showWarning
>
<StatePreamble state={state} covidState={covidState} />
<StatePreamble state={state} urls={urls} covidState={covidState} />
<SummaryCharts
name={state.name}
chartTables={`/data/state/${state.childSlug.slug}/chart-tables`}
Expand Down Expand Up @@ -329,5 +330,14 @@ export const query = graphql`
total_pediatric_patients_hospitalized_confirmed_covid
}
}
urls: file(childTacoYaml: { state: { eq: "CA" } }) {
childTacoYaml {
links {
url
name
}
state
}
}
}
`
Loading

0 comments on commit a460c56

Please sign in to comment.