j40-cejst-2/client/src/components/J40Header.tsx
Vim 522872037a
Website copy layout styling updates for Tuesday launch (#685)
* Add basic accordion in AreaDetail

* Refactor AreaDetail to use a Grid layout

- adds useWindowSize to detect window resizes for mobile view
- Map and AreaDetail to use Grid
- removes some component styling from J40
- updates snapshot
- MapWrapper to use Grid

* Add custom Accordion styling

- make J40 map a 9:3 Grid layout split
- override native Accordion heading styles
- make the Accordion multi-selectable
- add some dummy data for indicators

* Update AreaDetail to match design

- remove styles in AreaDetail
- increase height of MapInfoPanel
- add Accordian items (indicators)
- updates snapshot

* Add a Beta Tag to the logo

* Change the line height on indicators descriptions

* Update package-lock after the rebase

* Remove threshold from MapLegend

- move feature selected border color to utils
- remove all tooltip logic
- remove all styles associated with tooltips
- add legend label and descript to constants
- refactor tests to be snapshots

* Add borders between additional indicators

* Modify copy and update styles

- add the ordinal superscript back
- update the copy
- update the snapshots

* Add additional indicators keys

* Connect indicator keys to the UI

- update the areaDetail snapshot

* Render additional indicators accordion open onLoad

- update snapshot

* Update copy on About page

* Update copy on indicator descriptions

- update snapshots

* Update the "How you can help section"

- update the snapshot

* Add a comma to "ZIP file will contain..."

* Add the Datasets section to the methodology page

- update snapshot

* Update Methodology process list to trussworks

- remove custom process list
- remove custom CSS from global file
- change copy

* Modify layout of Methodology to using Grid

- modify Dataset section to use Grid
- remove outdated component CSS
- update the snapshot

* Update copy based on product feedback

- update snapshots

* Remove Accordions

- updates snapshots
- white CBG groups will show "Not community of focus"
2021-09-16 10:21:25 -07:00

145 lines
4.3 KiB
TypeScript

import React, {useState} from 'react';
import {Link, useIntl} from 'gatsby-plugin-intl';
import {
Header,
NavMenuButton,
PrimaryNav,
GovBanner,
Tag,
} from '@trussworks/react-uswds';
import {defineMessages} from 'react-intl';
// @ts-ignore
import siteLogo from '../../src/images/icon.png';
const J40Header = () => {
const intl = useIntl();
const [mobileNavOpen, setMobileNavOpen] = useState(false);
const messages = defineMessages({
titleLine1: {
id: 'header.title.line1',
defaultMessage: `Climate and Economic Justice`,
description: 'Title in nav header line 1 of 2',
},
titleLine2: {
id: 'header.title.line2',
defaultMessage: `Screening Tool`,
description: 'Title in nav header line 2 of 2',
},
about: {
id: 'header.about',
defaultMessage: 'About',
description: 'Header navigate item to the about page',
},
explore: {
id: 'header.explore',
defaultMessage: 'Explore the tool',
description: 'Header navigate item to the Explore the tool page',
},
methodology: {
id: 'header.methodology',
defaultMessage: 'Data & methodology',
description: 'Header navigate item to the Methodology page',
},
contact: {
id: 'header.contact',
defaultMessage: 'Contact',
description: 'Header navigate item to the Contact page',
},
});
const titleL1 = intl.formatMessage(messages.titleLine1);
const titleL2 = intl.formatMessage(messages.titleLine2);
const toggleMobileNav = (): void =>
setMobileNavOpen((prevOpen) => !prevOpen);
const headerLinks = () => {
// static map of all possible menu items. Originally, it was all strings,
// but we need to handle both onsite and offsite links.
const menuData = new Map<string, JSX.Element>([
['about',
<Link
to={'/'}
key={'about'}
activeClassName="usa-current"
className={'j40-header'}
data-cy={'nav-link-about'}
>
{intl.formatMessage(messages.about)}
</Link>,
],
['cejst',
<Link
to={'/cejst'}
key={'cejst'}
activeClassName="usa-current"
className={'j40-header'}
data-cy={'nav-link-explore'}
>
{intl.formatMessage(messages.explore)}
</Link>,
],
['methodology',
<Link
to={'/methodology'}
key={'methodology'}
activeClassName="usa-current"
className={'j40-header'}
data-cy={'nav-link-methodology'}
>
{intl.formatMessage(messages.methodology)}
</Link>,
],
['contact',
<Link
to={'/contact'}
key={'contact'}
activeClassName="usa-current"
className={'j40-header'}
data-cy={'nav-link-contact'}
>
{intl.formatMessage(messages.contact)}
</Link>,
],
]);
const menu =['about', 'cejst', 'methodology', 'contact'];
return menu.map((key) => menuData.get(key));
};
return (
<>
<GovBanner/>
<Header
basic={true} role={'banner'}
className={'usa-header j40-header'}>
<div className="usa-nav-container">
<div className="usa-navbar">
{/* Removing h1 from logo ease transition to USWDS tokens in headers */}
{/* https://wehavezeal.com/blog/web-development/2016/01/12/should-i-use-the-h1-tag-for-my-website-logo */}
<div className="usa-logo">
<img className="j40-sitelogo" src={siteLogo} alt={`${titleL1} ${titleL2}`} />
<span className={'usa-logo__text j40-title'}>
<span className={'j40-title-line1'}>{titleL1}</span><br/>
<span className={'j40-title-line2'}>{titleL2}</span>
<Tag className={'j40'}>Beta</Tag>
</span>
</div>
<NavMenuButton
key={'mobileMenuButton'}
onClick={toggleMobileNav}
label="Menu"/>
</div>
<PrimaryNav
items={headerLinks()}
mobileExpanded={mobileNavOpen}
onToggleMobileNav={toggleMobileNav}
className={'j40-header'}
>
</PrimaryNav>
</div>
</Header>
</>
);
};
export default J40Header;