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

refactor: Refactor page header to use USWDS components #1247

Merged
merged 89 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
077d914
Adding initial header draft
sandrahoang686 Nov 6, 2024
d0173fc
Import styles for the uswds header component
AliceR Nov 7, 2024
2c04768
Format header file with prettier
AliceR Nov 7, 2024
d01a8d4
Use stylelint and prettier to format scss
AliceR Nov 7, 2024
f0f174d
Make toggle work for multiple menus
AliceR Nov 7, 2024
157be1c
Update nav menu to use navItems config
sandrahoang686 Nov 7, 2024
1dc6e0b
Remove ModalNavLink type and create ButtonNavLink type
sandrahoang686 Nov 7, 2024
506bd79
remove placeholder vars
sandrahoang686 Nov 7, 2024
e6e9851
Add old logo to header
AliceR Nov 11, 2024
973875d
Use flexible logo container and drop logo component
AliceR Nov 11, 2024
aeb15b1
Restore old header and enable feature flag
AliceR Nov 12, 2024
3593fe1
Fix logo in new header
AliceR Nov 12, 2024
5e8fae0
Avoid nav wrapper for uswds header
AliceR Nov 12, 2024
0a8f153
update FF & update directories
sandrahoang686 Nov 12, 2024
1f0d3e4
Make contact-us link style, Updated to add actionNavItem, decouple bu…
sandrahoang686 Nov 13, 2024
3a09d0f
Use env flag utils and fix env var
AliceR Nov 13, 2024
7326a72
Encapsulate components
AliceR Nov 13, 2024
32137bf
Fix toggle for multiple dropdowns
AliceR Nov 14, 2024
9497962
Refactor nav items into separate components
AliceR Nov 14, 2024
5ebcbce
Extract dynamic nav creation
AliceR Nov 14, 2024
78543f0
Remove toggle expansion from nav item external link
AliceR Nov 14, 2024
c8e5b7f
change dynamicNavMenu function name to something more suitable and up…
sandrahoang686 Nov 15, 2024
1e9ad22
rid of ButtonNavItem, rid of actionIdMap, and filename change for bet…
sandrahoang686 Nov 15, 2024
0705da6
Rename Proptype NavItemCTA
sandrahoang686 Nov 15, 2024
8b5d508
remove styled components and add scss file for logo-container, add ma…
sandrahoang686 Nov 18, 2024
a05431b
Add jest test for page-header
AliceR Nov 18, 2024
81199ab
Fix some type issues to make tests run
AliceR Nov 18, 2024
7431771
Test nav bar, but can't find by data-testid
AliceR Nov 18, 2024
31ff4fb
Match logo/title to design, organize page-header dir, and scss file
sandrahoang686 Nov 18, 2024
f6049b4
Add light/dark mode and more uswds tokens, fix logo container to match
sandrahoang686 Nov 18, 2024
2a08e20
Add more tests for header nav
AliceR Nov 19, 2024
9ee11aa
Limit query scope
AliceR Nov 19, 2024
96f9189
resolved conflics, add id to NavItem types
sandrahoang686 Nov 19, 2024
b9dd0ac
add id to navtypes and update accessibility styling on primary nav items
sandrahoang686 Nov 19, 2024
4929296
Fix type import in legacy page header
AliceR Nov 20, 2024
653577f
Mock NavLink in header test: ✅
AliceR Nov 20, 2024
4b79efc
Test user clicks on dropdown
AliceR Nov 20, 2024
9650683
Add test for header theme mode
AliceR Nov 21, 2024
0d0d464
Add extension to test Netlify build
dzole0311 Nov 21, 2024
c263635
Remove TODO, moved to PR comment
AliceR Nov 21, 2024
f448915
remove theme mode and custom headernav styles
sandrahoang686 Nov 22, 2024
1410620
overrwrite default ui role-based token
sandrahoang686 Nov 22, 2024
f0bfae2
Remove test case for dark mode
AliceR Nov 25, 2024
7c0d031
Use mock/veda.config.js for header test
AliceR Nov 25, 2024
aebb463
Format file, no changes
AliceR Nov 25, 2024
1db702c
Use theme variable to set fontC
AliceR Nov 25, 2024
bc529ba
Update font in the theme to public sans
AliceR Nov 25, 2024
9f12bed
Format /nav files, no actual changes
AliceR Nov 25, 2024
5178ab3
Update how stylelint is processing styled components
AliceR Nov 25, 2024
0eaad3e
Remove stylelint-config-prettier-scss
AliceR Nov 25, 2024
31a281f
Remove stylelint-config-styled-components
AliceR Nov 25, 2024
9f381d1
Upgrade stylelint-config-recommended
AliceR Nov 25, 2024
9b3cad7
Fix stylelint no-empty-source
AliceR Nov 25, 2024
42197b9
Fix linking / remove react-router-dom dep, works in nextJs now
sandrahoang686 Nov 25, 2024
09ec487
change forward to use for styling
sandrahoang686 Nov 25, 2024
d8f7052
clean up ternary logic around GoogleForm & other cleanup
sandrahoang686 Nov 26, 2024
4b1d19f
move title&version to be props passed in to pageheader, fix logoconta…
sandrahoang686 Nov 26, 2024
f531e13
clean up title logic more
sandrahoang686 Nov 26, 2024
ae764cc
rename logo prop and correct type, no overrided needed
sandrahoang686 Nov 26, 2024
0a63c46
update pageheader test
sandrahoang686 Nov 26, 2024
326f189
remove classname from smart-link component
sandrahoang686 Nov 26, 2024
d3ecb69
remove unused uswds logo
sandrahoang686 Nov 26, 2024
cf2137f
update uswds forwards and update font-weight setting
sandrahoang686 Nov 26, 2024
382835f
Fix dependendy arrays and format
AliceR Nov 26, 2024
756c13f
Add custom hook to fix nav on resize
AliceR Nov 26, 2024
25e6a14
Add expanded to the deps array
AliceR Nov 26, 2024
066f7fc
Fix formatting
AliceR Nov 27, 2024
6a05249
Remove router mock, cookie test was relying on the actual implementation
AliceR Nov 27, 2024
b9a264c
Use SetState from /aliases
AliceR Nov 27, 2024
e4cd0f3
Mark optional, use SetState from /aliases
AliceR Nov 27, 2024
16e1e17
Clean up styles: remove unspecific selectors
AliceR Dec 2, 2024
908edf9
Make styles match the designs
AliceR Dec 2, 2024
9bb3de7
Fix version tag to show 'beta version' instead of 'vundefined'
AliceR Dec 2, 2024
1dadbb3
add skip to main content a11y shortcut
sandrahoang686 Dec 3, 2024
36a9892
update font-weight of secondary link items
sandrahoang686 Dec 3, 2024
258dc82
Update secondary items divider height and text color
sandrahoang686 Dec 3, 2024
f72ed41
update customized chevron color request
sandrahoang686 Dec 3, 2024
7917fab
fix lint complaint of double quotes
sandrahoang686 Dec 3, 2024
204fa75
Add new USWDS components to the roll up file and update imports
AliceR Dec 4, 2024
7ebd241
Hide logo on small screen widths
AliceR Dec 4, 2024
7652f0b
change cta nav item a tag to button
sandrahoang686 Dec 4, 2024
71f3c22
add desktop uswds unit
sandrahoang686 Dec 4, 2024
f5510eb
fix accessibility shortcut to main content to be button and direct to…
sandrahoang686 Dec 4, 2024
0ce081a
fix lint errors
sandrahoang686 Dec 4, 2024
b7a59b1
fix conflict
sandrahoang686 Dec 4, 2024
12d936b
fix tabIndex value because of ts-check
sandrahoang686 Dec 4, 2024
c769492
Replace magic number with theme var
AliceR Dec 5, 2024
3dc5c54
Update font size references in themes file
sandrahoang686 Dec 5, 2024
3c85467
fix conflict
sandrahoang686 Dec 9, 2024
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
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ GOOGLE_FORM = 'https://docs.google.com/forms/d/e/1FAIpQLSfGcd3FDsM3kQIOVKjzdPn4f

SHOW_CONFIGURABLE_COLOR_MAP = 'TRUE'

# Enables the refactor page header component that uses the USWDS design system
ENABLE_USWDS_PAGE_HEADER = 'TRUE'
7 changes: 2 additions & 5 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{
"processors": [
"stylelint-processor-styled-components"
],
"extends": [
"stylelint-config-recommended",
"stylelint-config-styled-components"
"stylelint-config-recommended"
],
"customSyntax": "postcss-styled-syntax",
"rules": {
"font-family-no-missing-generic-family-keyword": null,
"no-descending-specificity": [
Expand Down
5 changes: 4 additions & 1 deletion .vscode/settings.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"javascriptreact",
"typescript",
"typescriptreact"
]
],
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}

49 changes: 2 additions & 47 deletions app/scripts/components/common/google-form.tsx
Original file line number Diff line number Diff line change
@@ -1,61 +1,16 @@
import React from 'react';
import styled from 'styled-components';
import { Button } from '@devseed-ui/button';
import { Modal } from '@devseed-ui/modal';
import { media, themeVal } from '@devseed-ui/theme-provider';

import { useFeedbackModal } from './layout-root';

import GlobalMenuLinkCSS from '$styles/menu-link';

const StyledGoogleForm = styled.iframe`
width: 100%;
`;

interface BtnMediaProps {
active?: boolean;
}

// Global menu link style
const ButtonAsNavLink = styled(Button)`
${media.mediumUp<BtnMediaProps>`
background-color: ${themeVal('color.primary-700')};

&:hover {
background-color: ${themeVal('color.primary-800')};
}

/* Print & when prop is passed */
${({ active }) => active && '&,'}
&:active,
&.active {
background-color: ${themeVal('color.primary-900')};
}

&:focus-visible {
background-color: ${themeVal('color.primary-200a')};
}
`}

${media.mediumDown`
${GlobalMenuLinkCSS}
`}
`;

const GoogleForm: React.FC<{ title: string, src: string }> = (props) => {
const { title, src } = props;
const { isRevealed, show, hide } = useFeedbackModal();
const GoogleForm: React.FC<{ src: string, isRevealed: boolean, hide: () => void }> = (props) => {
const { src, isRevealed, hide } = props;

return (
<>
<ButtonAsNavLink
type='button'
size='large'
onClick={show}
style={{ color: 'white' }}
>
{title}
</ButtonAsNavLink>
<Modal
id='modal'
size='large'
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/components/common/layout-root/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { LayoutRootContext } from './context';
import { setGoogleTagManager } from '$utils/use-google-tag-manager';

import NavWrapper from '$components/common/nav-wrapper';
import Logo from '$components/common/page-header/logo';
import Logo from '$components/common/page-header-legacy/logo';
import {
mainNavItems,
subNavItems
Expand Down
217 changes: 217 additions & 0 deletions app/scripts/components/common/nasa-logo-color.js

Large diffs are not rendered by default.

31 changes: 23 additions & 8 deletions app/scripts/components/common/nav-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ import React from 'react';
import styled, { css } from 'styled-components';
import { themeVal } from '@devseed-ui/theme-provider';
import { NavLink } from 'react-router-dom';
import { default as PageHeaderLegacy } from './page-header-legacy';
import PageHeader from './page-header';
import { useSlidingStickyHeaderProps } from './layout-root/useSlidingStickyHeaderProps';

import NasaLogoColor from './nasa-logo-color';
import {
HEADER_WRAPPER_ID,
HEADER_TRANSITION_DURATION
} from '$utils/use-sliding-sticky-header';
import { checkEnvFlag } from '$utils/utils';

const NavWrapper = styled.div`
const NavWrapperContainer = styled.div`
position: sticky;
top: 0;
width: 100%;
Expand All @@ -26,21 +28,34 @@ const NavWrapper = styled.div`
top: -${headerHeight}px;
`}
`;
// Hiding configurable map for now until Instances are ready to adapt it
const isUSWDSEnabled = checkEnvFlag(process.env.ENABLE_USWDS_PAGE_HEADER);
const appTitle = isUSWDSEnabled
? 'Earthdata VEDA Dashboard'
: process.env.APP_TITLE;

function PageNavWrapper(props) {
function NavWrapper(props) {
const { isHeaderHidden, headerHeight } = useSlidingStickyHeaderProps();
return (
<NavWrapper

return isUSWDSEnabled ? (
<PageHeader
{...props}
logoSvg={<NasaLogoColor />}
linkProperties={{ LinkElement: NavLink, pathAttributeKeyName: 'to' }}
title={appTitle}
/>
) : (
<NavWrapperContainer
id={HEADER_WRAPPER_ID}
shouldSlideHeader={isHeaderHidden}
headerHeight={headerHeight}
>
<PageHeader
<PageHeaderLegacy
{...props}
linkProperties={{ LinkElement: NavLink, pathAttributeKeyName: 'to' }}
/>
</NavWrapper>
</NavWrapperContainer>
);
}

export default PageNavWrapper;
export default NavWrapper;
Loading
Loading