diff --git a/.gitignore b/.gitignore index a3d768cc1..edc04705b 100644 --- a/.gitignore +++ b/.gitignore @@ -71,6 +71,7 @@ public # Data API build directory _data _api +_screenshots # Storybook build storybook-static diff --git a/gatsby-config.js b/gatsby-config.js index 2421e65a4..4182ae14a 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -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: { diff --git a/package.json b/package.json index 9a0126f21..03205b7af 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" } } diff --git a/src/components/pages/data/states.js b/src/components/pages/data/states.js index e8b095fa3..9d7d641f0 100644 --- a/src/components/pages/data/states.js +++ b/src/components/pages/data/states.js @@ -12,6 +12,7 @@ const States = ({ raceDataCombined, raceDataSeparate, hhsHospitalization, + screenshotLinks, }) => { const stateList = [] @@ -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) }) diff --git a/src/components/pages/state/preamble.js b/src/components/pages/state/preamble.js index 6cf94c7d8..0757773f9 100644 --- a/src/components/pages/state/preamble.js +++ b/src/components/pages/state/preamble.js @@ -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 { @@ -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 ( @@ -47,9 +48,7 @@ const StatePreamble = ({ state, covidState }) => {

Where this data comes from

diff --git a/src/components/pages/state/state-links.js b/src/components/pages/state/state-links.js index 5b13ece1a..edf98ef18 100644 --- a/src/components/pages/state/state-links.js +++ b/src/components/pages/state/state-links.js @@ -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 (
- {covid19Site && ( - + {getLink('primary') && ( + Best current data source )} - {covid19SiteSecondary && ( - + {getLink('secondary') && ( + Secondary data source )} - {covid19SiteTertiary && ( - + {getLink('tertiary') && ( + Tertiary data source )} @@ -67,11 +67,9 @@ const StateLinksDisclosurePanel = ({ state }) => ( ) diff --git a/src/pages/data/index.js b/src/pages/data/index.js index c08c19ccc..4f228d63a 100644 --- a/src/pages/data/index.js +++ b/src/pages/data/index.js @@ -71,6 +71,7 @@ const DataPage = ({ data }) => { raceDataCombined={data.allCovidRaceDataCombined.nodes} raceDataSeparate={data.allCovidRaceDataSeparate.nodes} hhsHospitalization={data.allHhsHospitalizationCovid.group} + screenshotLinks={data.urls.nodes} /> ) @@ -121,8 +122,6 @@ export const query = graphql` } allCovidStateInfo(sort: { fields: name }) { nodes { - covid19Site - covid19SiteSecondary name notes state @@ -318,5 +317,16 @@ export const query = graphql` } } } + urls: allFile { + nodes { + childTacoYaml { + links { + url + name + } + state + } + } + } } ` diff --git a/src/templates/state/index.js b/src/templates/state/index.js index c3aa1ec1f..c3e281a5d 100644 --- a/src/templates/state/index.js +++ b/src/templates/state/index.js @@ -32,6 +32,7 @@ const StateTemplate = ({ pageContext, data, path }) => { allTweets, allCovidAnnotation, allHhsHospitalizationCovid, + urls, } = data return ( { path={path} showWarning > - + =5.1.0, safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@~5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + safe-buffer@5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" @@ -18557,11 +18607,6 @@ safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -safe-buffer@>=5.1.0, safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@~5.2.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - safe-regex@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e" @@ -19787,6 +19832,15 @@ strip-url-auth@^1.0.0: resolved "https://registry.yarnpkg.com/strip-url-auth/-/strip-url-auth-1.0.1.tgz#22b0fa3a41385b33be3f331551bbb837fa0cd7ae" integrity sha1-IrD6OkE4WzO+PzMVUbu4N/oM164= +strtok3@^6.0.3: + version "6.0.4" + resolved "https://registry.yarnpkg.com/strtok3/-/strtok3-6.0.4.tgz#ede0d20fde5aa9fda56417c3558eaafccc724694" + integrity sha512-rqWMKwsbN9APU47bQTMEYTPcwdpKDtmf1jVhHzNW2cL1WqAxaM9iBb9t5P2fj+RV2YsErUWgQzHD5JwV0uCTEQ== + dependencies: + "@tokenizer/token" "^0.1.1" + "@types/debug" "^4.1.5" + peek-readable "^3.1.0" + style-loader@^0.23.1: version "0.23.1" resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-0.23.1.tgz#cb9154606f3e771ab6c4ab637026a1049174d925" @@ -20282,6 +20336,14 @@ token-stream@1.0.0: resolved "https://registry.yarnpkg.com/token-stream/-/token-stream-1.0.0.tgz#cc200eab2613f4166d27ff9afc7ca56d49df6eb4" integrity sha1-zCAOqyYT9BZtJ/+a/HylbUnfbrQ= +token-types@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/token-types/-/token-types-2.0.0.tgz#b23618af744818299c6fbf125e0fdad98bab7e85" + integrity sha512-WWvu8sGK8/ZmGusekZJJ5NM6rRVTTDO7/bahz4NGiSDb/XsmdYBn6a1N/bymUHuWYTWeuLUg98wUzvE4jPdCZw== + dependencies: + "@tokenizer/token" "^0.1.0" + ieee754 "^1.1.13" + tough-cookie@^2.3.3, tough-cookie@~2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" @@ -21880,6 +21942,11 @@ xstate@^4.11.0, xstate@^4.13.0, xstate@^4.9.1: resolved "https://registry.yarnpkg.com/xstate/-/xstate-4.13.0.tgz#0be22ceb8bae2bc6a025fab330fe44204d76771c" integrity sha512-UnUJJzP2KTPqnmxIoD/ymXtpy/hehZnUlO6EXqWC/72XkPb15p9Oz/X4WhS3QE+by7NP+6b5bCi/GTGFzm5D+A== +xstate@^4.14.0: + version "4.15.1" + resolved "https://registry.yarnpkg.com/xstate/-/xstate-4.15.1.tgz#0553453c1cd201fedaf35a3cc518fe56090dbc3a" + integrity sha512-8dD/GnTwxUuDr/cY42vi+Enu4mpbuUXWISYJ0a9BC+cIFvqufJsepyDLS6lLsznfUP0GS5Yx9m3IQWFhAoGt/A== + xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1: version "4.0.2" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"