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

chore: Add rt.live warning #1780

Merged
merged 7 commits into from
Jan 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ exports[`Components : Charts: Bar chart renders correctly 1`] = `
viewBox="0 0 200 200"
>
<g
transform="translate(30 30"
transform="translate(30 30)"
>
<text
className="label directions"
Expand Down Expand Up @@ -226,7 +226,7 @@ exports[`Components : Charts: Bar chart renders correctly 2`] = `
viewBox="0 0 200 200"
>
<g
transform="translate(30 30"
transform="translate(30 30)"
>
<text
className="label directions"
Expand Down
2 changes: 1 addition & 1 deletion src/components/charts/bar-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const BarChart = ({
}
}}
>
<g transform={`translate(${marginLeft} ${marginTop}`}>
<g transform={`translate(${marginLeft} ${marginTop})`}>
<text className={classnames(chartStyles.label, styles.directions)}>
Use arrows to move, Escape to leave.
</text>
Expand Down
1 change: 0 additions & 1 deletion src/components/layout/header/data-warning.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
import React, { useState, useEffect } from 'react'
import { useStaticQuery, graphql } from 'gatsby'
import marked from 'marked'
Expand Down
2 changes: 2 additions & 0 deletions src/components/layout/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import HeaderSubNavigation from './sub-navigation'
import ReturnLinks from './return-links'
import Tools from './tools'
import DataWarning from './data-warning'
import RtLiveWarning from './rt-live-warning'

const expandStyles = {
open: { background: colors.colorPlum800 },
Expand Down Expand Up @@ -144,6 +145,7 @@ const Header = withSearch(
<>
<DevelopmentWarning />
{showWarning && <DataWarning />}
<RtLiveWarning />
<header
className={classnames(
'site-header',
Expand Down
59 changes: 59 additions & 0 deletions src/components/layout/header/rt-live-warning.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Link } from 'gatsby'
import React, { useState, useEffect } from 'react'
import Container from '~components/common/container'
import dataWarningStyle from './data-warning.module.scss'

const DataWarning = () => {
const [isHidden, setIsHidden] = useState(true)

useEffect(() => {
if (typeof document === 'undefined') {
return
}
if (document.cookie && document.cookie.search('rt_ctp_warning') > -1) {
return
}
if (
(typeof document.referrer !== 'undefined' &&
document.referrer.search('rt.live') > -1) ||
window.location.href.search(/\?source=rt/) > -1
) {
setIsHidden(false)
}
}, [])

return (
<>
{!isHidden && (
<div className={dataWarningStyle.warning}>
<Container>
<button
aria-label="Hide this warning"
type="button"
onClick={event => {
event.preventDefault()
setIsHidden(true)
const date = new Date()
date.setTime(date.getTime() + 10 * 24 * 60 * 60 * 1000)
document.cookie = `rt_ctp_warning=1; expires=${date.toISOString()}; path=/`
}}
>
&times;
</button>
<p role="alert">
Welcome, rt.live users. We are unaffiliated with rt.live and do
not estimate reproduction numbers for COVID-19. We do offer{' '}
<Link to="/data">
official public health data for 56 US states and territories
</Link>{' '}
and a <Link to="/data/charts">full set of chart tools</Link> you
may find helpful.
</p>
</Container>
</div>
)}
</>
)
}

export default DataWarning