From 73a205dc48ad19ff1a9d1c48df7c4da5bec52bd1 Mon Sep 17 00:00:00 2001 From: TomNUSDS <74203452+TomNUSDS@users.noreply.github.com> Date: Mon, 9 Aug 2021 08:04:24 -0700 Subject: [PATCH] Refactor layout (#486) * Refactor to move `` out of layout * `` is now in the methodology page. Starting the review there will help understand the motive for this change. * Fixed 404 page which seems way out of date. * Use row/col grid syntax --- .../src/components/J40MainGridContainer.tsx | 30 ++++ client/src/components/layout.tsx | 18 +-- client/src/pages/404.tsx | 66 ++++---- client/src/pages/cejst.tsx | 105 +++++++------ client/src/pages/contact.tsx | 64 ++++---- client/src/pages/index.tsx | 145 ++++++++++-------- client/src/pages/methodology.tsx | 73 +++++---- 7 files changed, 285 insertions(+), 216 deletions(-) create mode 100644 client/src/components/J40MainGridContainer.tsx diff --git a/client/src/components/J40MainGridContainer.tsx b/client/src/components/J40MainGridContainer.tsx new file mode 100644 index 00000000..5f3b38a8 --- /dev/null +++ b/client/src/components/J40MainGridContainer.tsx @@ -0,0 +1,30 @@ +// Trussworks GridContainer won't allow it to span 100% of the page, so +// this works around it and tries to hide the complexity in component +import React, {ReactNode} from 'react'; +import {GridContainer} from '@trussworks/react-uswds'; + +interface ILayoutProps { + children: ReactNode, + fullWidth?: boolean, + className?: string +} + +const J40MainGridContainer = ({ + children, + fullWidth = false, + className = 'j40-grid-container'}: ILayoutProps) => { + return fullWidth ? ( +
+ {children} +
+ ) : ( + + {children} + + ); +}; + +export default J40MainGridContainer; diff --git a/client/src/components/layout.tsx b/client/src/components/layout.tsx index bedca4ef..dc637de4 100644 --- a/client/src/components/layout.tsx +++ b/client/src/components/layout.tsx @@ -1,10 +1,7 @@ import React, {ReactNode} from 'react'; -import {GridContainer, Grid} from '@trussworks/react-uswds'; import J40Header from './J40Header'; import J40Footer from './J40Footer'; import {URLFlagProvider} from '../contexts/FlagContext'; -import DatasetContainer from '../components/DatasetContainer'; -// this has to be wrong interface ILayoutProps { children: ReactNode, @@ -12,22 +9,13 @@ interface ILayoutProps { } const Layout = ({children, location}: ILayoutProps) => { - const isMethodologyPage = location.pathname.match(/methodology\/?/); - // @ts-ignore return ( - - -
- {children} -
-
-
- {isMethodologyPage ? : null} +
+ {children} +
); diff --git a/client/src/pages/404.tsx b/client/src/pages/404.tsx index 6fcc0087..2e29a522 100644 --- a/client/src/pages/404.tsx +++ b/client/src/pages/404.tsx @@ -1,14 +1,12 @@ import * as React from 'react'; +import Layout from '../components/layout'; +import J40MainGridContainer from '../components/J40MainGridContainer'; import {Link} from 'gatsby-plugin-intl'; +import {Grid} from '@trussworks/react-uswds'; // styles -const pageStyles = { - color: '#232129', - padding: '96px', - fontFamily: '-apple-system, Roboto, sans-serif, serif', -}; const headingStyles = { - marginTop: 0, + marginTop: 32, marginBottom: 64, maxWidth: 320, }; @@ -16,6 +14,7 @@ const headingStyles = { const paragraphStyles = { marginBottom: 48, }; + const codeStyles = { color: '#8A6534', padding: 4, @@ -24,30 +23,39 @@ const codeStyles = { borderRadius: 4, }; +interface I404PageProps { + location: Location; +} + // markup -const NotFoundPage = () => { - return ( -
- Not found -

Page not found

-

- Sorry{' '} - - 😔 - {' '} - we couldn’t find what you were looking for. -
- {process.env.NODE_ENV === 'development' ? ( - <> -
- Try creating a page in src/pages/. -
- - ) : null} -
- Go home. -

-
+const NotFoundPage =({location}: I404PageProps) => { + return ( + + +

Page not found

+
+ +

+ Sorry{' '} + + 😔 + {' '} + we couldn’t find what you were looking for. +
+ {process.env.NODE_ENV === 'development' ? ( + <> +
+ Try creating a page + in src/pages/. +
+ + ) : null} +
+ Go home. +

+
+
+
); }; diff --git a/client/src/pages/cejst.tsx b/client/src/pages/cejst.tsx index f6bf33cd..ed740911 100644 --- a/client/src/pages/cejst.tsx +++ b/client/src/pages/cejst.tsx @@ -3,64 +3,75 @@ import Layout from '../components/layout'; import MapWrapper from '../components/mapWrapper'; import HowYouCanHelp from '../components/HowYouCanHelp'; import DownloadPacket from '../components/downloadPacket'; +import J40MainGridContainer from '../components/J40MainGridContainer'; import * as styles from './cejst.module.scss'; +import {Grid} from '@trussworks/react-uswds'; + interface IMapPageProps { location: Location; } - const CEJSTPage = ({location}: IMapPageProps) => { // We temporarily removed MapControls, which would enable you to `setFeatures` also, for now // We will bring back later when we have interactive controls. - return ( - -
-

Just Progress communities

-
-
-

- Just Progress helps identify and prioritize communities across the - United States and U.S. territories - that have been historically overburdened and underserved. These - communities will receive 40% of - the benefits from investments in key areas outlined by the -   - - Executive Order on Tackling the Climate Crisis at Home and - Abroad - . -

-

- Download the Just Progress packet or explore the map below to see - the list of prioritized communites. To - learn more about how these communities were prioritized check out - the -   - - Methodology - -   - page. -

+ return ( + + +
+

Just Progress communities

+
+
+

+ Just Progress helps identify and prioritize communities across + the United States and U.S. territories + that have been historically overburdened and underserved. + These communities will receive 40% of + the benefits from investments in key areas outlined by the +   + + Executive Order on Tackling the Climate Crisis at Home and + Abroad + . +

+

+ Download the Just Progress packet or explore the map below to + see the list of prioritized communities. To learn more about + how + these communities were prioritized check out the +   + + Methodology + +   + page. +

+
+
- -
-
+ + -
- - -
-
- ); + +
+ +
+
+ + +
+ +
+
+ + ); }; export default CEJSTPage; diff --git a/client/src/pages/contact.tsx b/client/src/pages/contact.tsx index 6c97fee7..9761debd 100644 --- a/client/src/pages/contact.tsx +++ b/client/src/pages/contact.tsx @@ -1,6 +1,8 @@ import * as React from 'react'; import Layout from '../components/layout'; +import J40MainGridContainer from '../components/J40MainGridContainer'; import {FormattedMessage} from 'gatsby-plugin-intl'; +import {Grid} from '@trussworks/react-uswds'; interface ContactPageProps { location: Location; @@ -11,39 +13,45 @@ const ContactPage = ({location}: ContactPageProps) => { const techemail = 'screeningtool.support@usds.gov'; return ( -
-

-

+ + +
+

+

-

- + {generalemail}, - }}/> -

-

- {generalemail}, + }}/> +

+

+ {techemail}, - }}/> -

-
+ values={{ + tech_email_address: + {techemail}, + }}/> +

+
+ +
); }; diff --git a/client/src/pages/index.tsx b/client/src/pages/index.tsx index 90f2e29b..40cb4f7c 100644 --- a/client/src/pages/index.tsx +++ b/client/src/pages/index.tsx @@ -1,8 +1,10 @@ import * as React from 'react'; import Layout from '../components/layout'; import AreasOfFocusList from '../components/areasOfFocusList'; +import J40MainGridContainer from '../components/J40MainGridContainer'; import {FormattedMessage, useIntl} from 'gatsby-plugin-intl'; import {defineMessages} from 'react-intl'; +import {Grid} from '@trussworks/react-uswds'; interface IndexPageProps { location: Location; @@ -20,9 +22,9 @@ const IndexPage = ({location}: IndexPageProps) => { presidentalLinkUri: { id: 'index.presidentalLinkUri', defaultMessage: 'https://www.whitehouse.gov/briefing-room/' + - 'presidential-actions/2021/01/27/' + - 'executive-order-on-tackling-the-climate-' + - 'crisis-at-home-and-abroad/', + 'presidential-actions/2021/01/27/' + + 'executive-order-on-tackling-the-climate-' + + 'crisis-at-home-and-abroad/', description: 'Link url to presidential actions executive order. Part of paragraph 3', }, presidentalLinkLabel: { @@ -48,13 +50,15 @@ const IndexPage = ({location}: IndexPageProps) => { }); return ( -
-

{intl.formatMessage(messages.aboutHeader)}

+ + +
+

{intl.formatMessage(messages.aboutHeader)}

-

{ overburdened and underserved communities. `}/>

-

{ the lived experiences of community members. `}/>

-

{intl.formatMessage(messages.presidentalLinkLabel)} - }}/> -

+ values={{ + presidentLink: + {intl.formatMessage(messages.presidentalLinkLabel)} + , + }}/> +

-

+

- + -

+

-

-

+

-

- + {intl.formatMessage(messages.transparentLabel)}, - }}/> -

+ values={{ + inlineHeader: + {intl.formatMessage(messages.transparentLabel)}, + }}/> +

-

- + { decision-making, such as groups in rural and tribal areas, to understand their needs and ask for their input. `} - values={{ - inlineHeader: {intl.formatMessage(messages.inclusiveLabel)}, - }}/> -

+ values={{ + inlineHeader: + {intl.formatMessage(messages.inclusiveLabel)}, + }}/> +

-

- + { being built and the processes for stakeholder and public engagement. `} - values={{ - inlineHeader: {intl.formatMessage(messages.iterativeLabel)}, - }}/> -

-
- - ); + values={{ + inlineHeader: + {intl.formatMessage(messages.iterativeLabel)}, + }}/> +

+
+ + +
); }; export default IndexPage; diff --git a/client/src/pages/methodology.tsx b/client/src/pages/methodology.tsx index af7e5b04..f269c6df 100644 --- a/client/src/pages/methodology.tsx +++ b/client/src/pages/methodology.tsx @@ -1,5 +1,8 @@ import * as React from 'react'; import Layout from '../components/layout'; +import DatasetContainer from '../components/DatasetContainer'; +import J40MainGridContainer from '../components/J40MainGridContainer'; +import {Grid} from '@trussworks/react-uswds'; interface MethodPageProps { location: Location; @@ -7,36 +10,46 @@ interface MethodPageProps { // markup const IndexPage = ({location}: MethodPageProps) => { - return ( - -
-

Methodology

-

- The Just Progress tool combines demographic, environmental, and - socio-economic data to generate a cumulative index score, referred to - as the Just Progress Index. The tool currently utilizes national, - publically-available data from the United States Census Bureau’s - American Community Survey (ACS) and the EPA’s EJScreen tool. -

-

- The various inputs into the Just Progress Index are averaged into 2 - categories: Pollution Burden and Demographics. -

-

- Pollution Burden: health risks arising from proximity and potential - exposures to pollution and other adverse environmental conditions -

-

- Demographics: sensitive populations and socioeconomic factors that - make a community more vulnerable -

-

- Pollution Burden average x Demographics average = Just Progress - Index -

-
-
- ); + return ( + + +
+

Methodology

+

+ The Just Progress tool combines demographic, environmental, and + socio-economic data to generate a cumulative index score, referred + to as the Just Progress Index. The tool currently utilizes + national, + publically-available data from the United States Census Bureau’s + American Community Survey (ACS) and the EPA’s EJScreen tool. +

+

+ The various inputs into the Just Progress Index are averaged into + 2 categories: Pollution Burden and Demographics. +

+

+ Pollution Burden: health risks arising from proximity and + potential exposures to pollution and other adverse environmental + conditions +

+

+ Demographics: sensitive populations and socioeconomic factors that + make a community more vulnerable +

+

+ Pollution Burden average x Demographics average = Just Progress + Index +

+
+
+
+ + + + + + +
); }; export default IndexPage;