-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #156 from PublicHealthEngland/development
Essentials updates and improvements - fixes #79, #80, #125, #128, #134, #135, and #139. With thanks to @MikeCoats, @richardTowers, and @dracos for their contributions.
- Loading branch information
Showing
30 changed files
with
400 additions
and
169 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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* eslint-disable react-hooks/exhaustive-deps */ | ||
import React from 'react'; | ||
import React, { Fragment } from 'react'; | ||
import { Switch, Route, Redirect } from 'react-router'; | ||
import { Header, Footer } from 'govuk-react-jsx'; | ||
|
||
|
@@ -11,24 +11,43 @@ import Accessibility from 'pages/Accessibility'; | |
import Cookies from 'pages/Cookies'; | ||
import Navigation from 'components/Navigation'; | ||
import CookieBanner from 'components/CookieBanner'; | ||
import BackToTop from 'components/BackToTop'; | ||
|
||
|
||
const FooterContents = () => { | ||
|
||
return <Fragment> | ||
<p className={ "govuk-footer__meta-custom" }> | ||
For feedback email | ||
<a className="govuk-footer__link" | ||
href="mailto:[email protected]?Subject=Coronavirus%20dashboard%20feedback" | ||
rel="noopener noreferrer" | ||
target="_blank" | ||
>[email protected]</a> | ||
</p> | ||
<p className={ "govuk-footer__meta-custom" }> | ||
Developed by | ||
<a className="govuk-footer__link" | ||
href="https://www.gov.uk/government/organisations/public-health-england" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
>PHE</a> | ||
and | ||
<a className="govuk-footer__link" | ||
href="https://www.nhsx.nhs.uk/" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
>NHSX</a> | ||
</p> | ||
</Fragment> | ||
|
||
}; // FooterContents | ||
|
||
|
||
const F = props => <Footer | ||
{ ...props } | ||
meta={ { | ||
children: [ | ||
'For feedback email ', | ||
<a className="govuk-footer__link" | ||
href="mailto:[email protected]?Subject=Coronavirus%20dashboard%20feedback" | ||
rel="noopener noreferrer" target="_blank">[email protected]</a>, | ||
<br/>, | ||
<br/>, | ||
'Developed by ', | ||
<a className="govuk-footer__link" href="https://www.gov.uk/government/organisations/public-health-england" | ||
target="_blank" rel="noopener noreferrer">PHE</a>, | ||
' and ', | ||
<a className="govuk-footer__link" href="https://www.nhsx.nhs.uk/" target="_blank" | ||
rel="noopener noreferrer">NHSX</a>, | ||
], | ||
children: <FooterContents/>, | ||
items: [ | ||
{ children: ['Archive'], href: '/archive' }, | ||
{ children: ['Accessibility'], href: '/accessibility' }, | ||
|
@@ -38,6 +57,7 @@ const F = props => <Footer | |
} } | ||
/>; | ||
|
||
|
||
const App = () => { | ||
|
||
return ( | ||
|
@@ -51,6 +71,15 @@ const App = () => { | |
homepageUrlHref="https://gov.uk" | ||
/> | ||
<Navigation/> | ||
|
||
{/* We only want back-to-top links on the main & about pages. */} | ||
<Switch> | ||
{/* These back-to-top links are the 'overlay' style that stays | ||
on screen as we scroll. */} | ||
<Route path="/about" exact render={()=>(<BackToTop mode="overlay"/>)} /> | ||
<Route path="/" exact render={()=>(<BackToTop mode="overlay"/>)} /> | ||
</Switch> | ||
|
||
<Switch> | ||
<Route path="/region" component={ MobileRegionTable }/> | ||
<Route path="/about" component={ About }/> | ||
|
@@ -60,6 +89,15 @@ const App = () => { | |
<Route path="/" component={ Regional }/> | ||
<Redirect to="/"/> | ||
</Switch> | ||
|
||
{/* We only want back-to-top links on the main & about pages. */} | ||
<Switch> | ||
{/* These back-to-top links are the 'inline' style that sits | ||
statically between the end of the content and the footer. */} | ||
<Route path="/about" exact render={()=>(<BackToTop mode="inline"/>)} /> | ||
<Route path="/" exact render={()=>(<BackToTop mode="inline"/>)} /> | ||
</Switch> | ||
|
||
<Switch> | ||
<Route path="/" exact component={ F }/> | ||
<Route path="/about" exact component={ F }/> | ||
|
@@ -71,4 +109,5 @@ const App = () => { | |
); | ||
} | ||
|
||
|
||
export default App; |
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,50 @@ | ||
// @flow | ||
|
||
import React from 'react'; | ||
import type { ComponentType } from 'react'; | ||
|
||
import type { Props } from './BackToTop.types'; | ||
import * as Styles from './BackToTop.styles'; | ||
|
||
import useBackToTopOverlayVisible from 'hooks/useBackToTopOverlayVisible'; | ||
|
||
const BackToTopLink: ComponentType<Props> = () => { | ||
return ( | ||
<div class="govuk-width-container"> | ||
<a class="govuk-link govuk-link--no-visited-state" href="#top"> | ||
<svg role="presentation" focusable="false" class="back-to-top" xmlns="http://www.w3.org/2000/svg" width="13" height="17" viewBox="0 0 13 17"> | ||
<path fill="currentColor" d="M6.5 0L0 6.5 1.4 8l4-4v12.7h2V4l4.3 4L13 6.4z"></path> | ||
</svg>Back to top | ||
</a> | ||
</div> | ||
); | ||
}; | ||
|
||
/** | ||
* A govuk style back-to-top link component. | ||
* | ||
* This component can either appear as an 'overlay' stuck to the bottom of the | ||
* screen hovering over the content, or as an 'inline' link that sits between | ||
* other components in the vertical page flow. | ||
* | ||
* @param {string} mode Either 'overlay' or 'inline' to choose which style to | ||
* display this component. | ||
*/ | ||
const BackToTop: ComponentType<Props> = ({ mode }: Props) => { | ||
const visible = useBackToTopOverlayVisible('footer'); | ||
if (mode === 'overlay'){ | ||
return ( | ||
<Styles.OverlayContainer style={{opacity: visible ? 1 : 0}}> | ||
<BackToTopLink /> | ||
</Styles.OverlayContainer> | ||
); | ||
} else { | ||
return ( | ||
<Styles.InlineContainer style={{opacity: visible ? 0 : 1}}> | ||
<BackToTopLink /> | ||
</Styles.InlineContainer> | ||
); | ||
} | ||
}; | ||
|
||
export default BackToTop; |
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,25 @@ | ||
// @flow | ||
|
||
import styled from 'styled-components'; | ||
import type { ComponentType } from 'react'; | ||
|
||
|
||
export const OverlayContainer: ComponentType<*> = (() => { | ||
return styled.div` | ||
position: fixed; | ||
bottom: 0; | ||
width: 100%; | ||
padding-top: 20px; | ||
padding-bottom: 20px; | ||
background: transparent; | ||
z-index: 1234567; | ||
`; | ||
})(); | ||
|
||
export const InlineContainer: ComponentType<*> = (() => { | ||
return styled.div` | ||
width: 100%; | ||
margin-top: 20px; | ||
margin-bottom: 40px; | ||
`; | ||
})(); |
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,6 @@ | ||
// @flow | ||
|
||
export type Props = {| | ||
hover: boolean, | ||
|}; | ||
|
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 @@ | ||
export { default } from './BackToTop'; |
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
Oops, something went wrong.