Skip to content

Commit

Permalink
Refactor Navigation Bar: Add Menu Folders for Improved Organization a…
Browse files Browse the repository at this point in the history
…nd Include CTA (#3596)

# Description and Motivation
This pull request refactors the existing navigation bar by introducing
menu folders (dropdowns) to better organize the menu options and enhance
user navigation. The restructured menu allows for grouping related links
under expandable sections, improving the overall user experience by
reducing visual clutter and providing a more intuitive navigation
structure. Additionally, addresses issue #1127

In addition to the menu folders, a Call to Action (CTA) has been added
to the navigation bar, providing users with quick access to our data
landing page. This enhancement aims to increase user engagement by
making key actions more prominent and accessible.

## Has this been tested? How?
Tests passing

## Screenshots (if appropriate)

> ### Previous version at 1279px
> <img width="1312" alt="Screenshot 2024-08-26 at 9 43 27 PM"
src="https://github.com/user-attachments/assets/16250c80-f780-4a43-8d04-17a05c17cdf4">

> ### New version at 1279px
> <img width="1490" alt="Screenshot 2024-08-26 at 9 41 42 PM"
src="https://github.com/user-attachments/assets/eabc03aa-9801-4c0e-a33e-884b20ca3dfa">
> 

> ### Previous version at 969px to 768px
> <img width="1312" alt="Screenshot 2024-08-26 at 9 43 45 PM"
src="https://github.com/user-attachments/assets/c21a5dfe-e66b-4f18-b61b-f3441a536d3c">
> <img width="1312" alt="Screenshot 2024-08-26 at 9 44 19 PM"
src="https://github.com/user-attachments/assets/cc8463ea-158c-412e-8572-0c2dfb39fdd2">

> ### New version at 969px
> <img width="1490" alt="Screenshot 2024-08-26 at 9 42 00 PM"
src="https://github.com/user-attachments/assets/7dc2f5b7-0542-493d-9ad9-7ab83152f3f5">

> ### Previous version - mobile
> <img width="210" alt="Screenshot 2024-08-26 at 9 44 37 PM"
src="https://github.com/user-attachments/assets/b58c73e9-f3d9-4d35-9578-6d8e8adf440d">

> ### New version - mobile
> <img width="260" alt="Screenshot 2024-08-26 at 9 42 26 PM"
src="https://github.com/user-attachments/assets/83519fef-e642-4d34-afcc-7b7771127c17">

> ### New version - desktop folders

> <img width="1490" alt="Screenshot 2024-08-26 at 9 40 50 PM"
src="https://github.com/user-attachments/assets/14e40c18-63d9-452a-8e44-49c8a79c98f4">
> <img width="1490" alt="Screenshot 2024-08-26 at 9 40 56 PM"
src="https://github.com/user-attachments/assets/72222117-80fe-4997-b6c0-0aadfe0741a2">
> <img width="1490" alt="Screenshot 2024-08-26 at 9 41 01 PM"
src="https://github.com/user-attachments/assets/87b73729-167f-40a3-9361-b8fa92d172d1">


## Types of changes
- New content or feature
- Refactor / chore

## New frontend preview link is below in the Netlify comment 😎
  • Loading branch information
kccrtv authored Aug 27, 2024
1 parent e4f4843 commit 2ac5c14
Show file tree
Hide file tree
Showing 16 changed files with 326 additions and 137 deletions.
8 changes: 4 additions & 4 deletions frontend/src/pages/DataCatalog/DataCatalogPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import {
type DataSourceId,
dataSourceMetadataMap,
} from '../../data/config/MetadataMap'
import { type DataSourceMetadata } from '../../data/utils/DatasetTypes'
import type { DataSourceMetadata } from '../../data/utils/DatasetTypes'
import {
DATA_CATALOG_PAGE_LINK,
EXPLORE_DATA_PAGE_LINK,
} from '../../utils/internalRoutes'
import { WithMetadata } from '../../data/react/WithLoadingOrErrorUI'
import { Helmet, HelmetProvider } from 'react-helmet-async'
import { DATA_SOURCE_PRE_FILTERS, useSearchParams } from '../../utils/urlutils'
import HetBigCTA from '../../styles/HetComponents/HetBigCTA'
import HetCTABig from '../../styles/HetComponents/HetCTABig'

// Map of filter id to list of datasets selected by that filter, or empty list
// for filters that don't have anything selected.
Expand Down Expand Up @@ -100,9 +100,9 @@ export default function DataCatalogPage() {
</li>
))}
{viewingSubsetOfSources && (
<HetBigCTA href={DATA_CATALOG_PAGE_LINK} className='mt-10'>
<HetCTABig href={DATA_CATALOG_PAGE_LINK} className='mt-10'>
View All Datasets
</HetBigCTA>
</HetCTABig>
)}
</>
)
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/pages/Landing/LandingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import NewsPreviewCard from '../News/NewsPreviewCard'
import { useQuery } from 'react-query'
import type { Article } from '../News/NewsPage'
import { usePrefersReducedMotion } from '../../utils/hooks/usePrefersReducedMotion'
import HetBigCTA from '../../styles/HetComponents/HetBigCTA'
import HetCTABig from '../../styles/HetComponents/HetCTABig'
import { useIsBreakpointAndUp } from '../../utils/hooks/useIsBreakpointAndUp'
import HetPostsLoading from '../../styles/HetComponents/HetPostsLoading'
import HetTextArrowLink from '../../styles/HetComponents/HetTextArrowLink'
Expand Down Expand Up @@ -125,9 +125,9 @@ function LandingPage() {
<span className='text-altGreen'>Health Equity Tracker</span>
<br /> take you?
</h1>
<HetBigCTA id='landingPageCTA' href={EXPLORE_DATA_PAGE_LINK}>
<HetCTABig id='landingPageCTA' href={EXPLORE_DATA_PAGE_LINK}>
Explore the data
</HetBigCTA>
</HetCTABig>
<div className='border-solid border-timberwolf border-l-2 border-0 py-0 pl-2 z-1'>
<p className='py-0 my-0 z-1'>
Data sourced from major public health agencies
Expand Down Expand Up @@ -274,7 +274,7 @@ function LandingPage() {
</div>
</div>
<div className='my-0 py-0 xs:py-0'>
<HetBigCTA href={EXPLORE_DATA_PAGE_LINK}>Explore the data</HetBigCTA>
<HetCTABig href={EXPLORE_DATA_PAGE_LINK}>Explore the data</HetCTABig>
</div>
</section>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function MethodologyPage() {

<section className='flex flex-col justify-end grow mx-8 lg:mx-12 my-0'>
{activeRoute?.visible && (
<h1 className='font-sansTitle text-bigHeader font-bold my-0 leading-tight'>
<h1 className='font-sansTitle text-bigHeader font-bold my-0 leading-lhNormal mb-8'>
{activeRoute?.label}
</h1>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Link } from 'react-router-dom'
import KeyTermsAccordion from '../methodologyComponents/KeyTermsAccordion'
import Resources from '../methodologyComponents/Resources'
import HetNotice from '../../../styles/HetComponents/HetNotice'
import HetBigCTA from '../../../styles/HetComponents/HetBigCTA'
import HetCTABig from '../../../styles/HetComponents/HetCTABig'
import HetTerm from '../../../styles/HetComponents/HetTerm'
import FormulaFormat from '../methodologyComponents/FormulaFormat'
import { metricDefinitions } from '../methodologyContent/MetricsDefinitions'
Expand Down Expand Up @@ -884,12 +884,12 @@ const AgeAdjustmentLink = () => {
</table>

<div className='mb-12 mt-24 flex w-full justify-center'>
<HetBigCTA
<HetCTABig
href={EXPLORE_DATA_PAGE_LINK + AGE_ADJUST_HIV_DEATHS_US_SETTING}
id='#age-adjustment-explore'
>
<span>Explore age-adjusted ratios →</span>
</HetBigCTA>
</HetCTABig>
</div>
</div>
</article>
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/pages/News/ShareYourStory.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import HetBigCTA from '../../styles/HetComponents/HetBigCTA'
import HetCTABig from '../../styles/HetComponents/HetCTABig'

export default function ShareYourStory() {
return (
Expand Down Expand Up @@ -128,9 +128,9 @@ export default function ShareYourStory() {
more inclusive and informed community.
</p>
<div className='mt-20 flex justify-center'>
<HetBigCTA href='mailto:[email protected]'>
<HetCTABig href='mailto:[email protected]'>
Share your story
</HetBigCTA>
</HetCTABig>
</div>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/pages/News/SinglePost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import { NEWS_PAGE_LINK } from '../../utils/internalRoutes'
import { Helmet } from 'react-helmet-async'
import { useQuery } from 'react-query'
import OpenInNewIcon from '@mui/icons-material/OpenInNew'
import { type Article } from './NewsPage'
import type { Article } from './NewsPage'
import hetLogo from '../../assets/AppbarLogo.png'
import SignupSection from '../ui/SignupSection'
import ShareButtons, {
ARTICLE_DESCRIPTION,
} from '../../reports/ui/ShareButtons'
import HetLinkButton from '../../styles/HetComponents/HetLinkButton'
import HetPaginationButton from '../../styles/HetComponents/HetPaginationButton'
import HetBigCTA from '../../styles/HetComponents/HetBigCTA'
import HetCTABig from '../../styles/HetComponents/HetCTABig'

function prettyDate(dateString: string) {
const options = { year: 'numeric', month: 'long', day: 'numeric' }
Expand Down Expand Up @@ -290,7 +290,7 @@ export default function SinglePost(props: SinglePostProps) {
{/* OPTIONALLY RENDER CONTINUE READING BUTTON */}
{fullArticle?.acf?.full_article_url && (
<div>
<HetBigCTA
<HetCTABig
href={fullArticle.acf.full_article_url}
className='mt-10'
>
Expand All @@ -299,7 +299,7 @@ export default function SinglePost(props: SinglePostProps) {
? ` on ${fullArticle.acf.friendly_site_name}`
: ''}{' '}
<OpenInNewIcon />
</HetBigCTA>
</HetCTABig>
</div>
)}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Policy/policyComponents/PolicyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function PolicyPage() {

<section className='flex flex-col justify-end grow mx-8 lg:mx-12 my-0'>
{activeRoute?.visible && (
<h1 className='font-sansTitle text-bigHeader font-bold my-0 leading-tight'>
<h1 className='font-sansTitle text-bigHeader font-bold my-0 leading-lhNormal'>
{activeRoute?.label}
</h1>
)}
Expand Down
81 changes: 35 additions & 46 deletions frontend/src/reports/ui/Banner.tsx
Original file line number Diff line number Diff line change
@@ -1,78 +1,67 @@
import React, { useState, useEffect } from 'react';
import FlagIcon from '@mui/icons-material/Flag';
import { METHODOLOGY_PAGE_LINK } from '../../utils/internalRoutes';
import { IconButton } from '@mui/material';
import HetTextArrowLink from '../../styles/HetComponents/HetTextArrowLink';
import type React from 'react'
import { useState, useEffect } from 'react'
import FlagIcon from '@mui/icons-material/Flag'
import { METHODOLOGY_PAGE_LINK } from '../../utils/internalRoutes'
import { IconButton } from '@mui/material'
import HetTextArrowLink from '../../styles/HetComponents/HetTextArrowLink'
import { Close } from '@mui/icons-material'

const Banner: React.FC = () => {
const [isVisible, setIsVisible] = useState(false);
const [isVisible, setIsVisible] = useState(false)

useEffect(() => {
const currentPath = window.location.pathname;
const currentSearch = window.location.search;
const bannerClosed = sessionStorage.getItem('bannerClosed');
const currentPath = window.location.pathname
const currentSearch = window.location.search
const bannerClosed = sessionStorage.getItem('bannerClosed')

if (currentPath === '/exploredata' && currentSearch === '' && !bannerClosed) {
setIsVisible(true);
setIsVisible(true)
} else {
setIsVisible(false);
setIsVisible(false)
}
}, [window.location.pathname, window.location.search]);
}, [window.location.pathname, window.location.search])

const handleClose = () => {
setIsVisible(false);
sessionStorage.setItem('bannerClosed', 'true');
};
setIsVisible(false)
sessionStorage.setItem('bannerClosed', 'true')
}

if (!isVisible) {
return null;
return null
}

return (
<section className="bg-infobarColor text-center p-4" aria-labelledby="banner-heading">
<div className="flex justify-between">
<div className="flex lg:flex-row flex-wrap items-center justify-start md:items-center lg:justify-start m-0 px-2">
<section className='bg-infobarColor text-center p-4' aria-labelledby='banner-heading'>
<div className='flex justify-between'>
<div className='flex lg:flex-row flex-wrap items-center justify-start md:items-center lg:justify-start m-0 px-2'>
<FlagIcon
className="lg:visible hidden mr-2 text-alertColor"
aria-hidden="true"
className='lg:visible hidden mr-2 text-alertColor'
aria-hidden='true'
/>
<p className="text-small p-0 my-0 text-left lg:mr-8" id="banner-heading">
<span className="font-sansTitle text-small lg:text-text font-bold m-0 p-0">
<p className='text-small p-0 my-0 text-left lg:mr-8' id='banner-heading'>
<span className='font-sansTitle text-small lg:text-text font-bold m-0 p-0'>
Major gaps in the data:
</span>{' '}
Structural racism causes health inequities. We’re closing these gaps to improve U.S. health policies.
</p>
<HetTextArrowLink
link={`${METHODOLOGY_PAGE_LINK}/limitations#missing-data`}
linkText="Learn more"
containerClassName="block md:mx-2 md:my-0 mx-0 my-4"
linkClassName="text-black"
linkText='Learn more'
containerClassName='block md:mx-2 md:my-0 mx-0 my-4'
linkClassName='text-black'
/>
</div>
<IconButton
onClick={handleClose}
className="banner-close-button p-2.5 md:my-auto mb-auto xs:mt-[2px]"
aria-label="Close banner"
className='banner-close-button p-2.5 md:my-auto mb-auto'
aria-label='Close banner'
sx={{ borderRadius: 1 }}
>
<div className="icon-small w-embed">
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 16 16"
fill="none"
aria-hidden="true"
>
<path
d="M12.2 3.80667C11.94 3.54667 11.52 3.54667 11.26 3.80667L7.99998 7.06L4.73998 3.8C4.47998 3.54 4.05998 3.54 3.79998 3.8C3.53998 4.06 3.53998 4.48 3.79998 4.74L7.05998 8L3.79998 11.26C3.53998 11.52 3.53998 11.94 3.79998 12.2C4.05998 12.46 4.47998 12.46 4.73998 12.2L7.99998 8.94L11.26 12.2C11.52 12.46 11.94 12.46 12.2 12.2C12.46 11.94 12.46 11.52 12.2 11.26L8.93998 8L12.2 4.74C12.4533 4.48667 12.4533 4.06 12.2 3.80667Z"
fill="currentColor"
></path>
</svg>
</div>
<Close/>
</IconButton>
</div>
</section>
);
};
)
}

export default Banner;
export default Banner
4 changes: 2 additions & 2 deletions frontend/src/styles/HetComponents/HetAppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import HetMobileToolbar from './HetMobileToolbar'
export default function HetAppBar() {
return (
<AppBar position='static' elevation={0} className='sticky top-0 z-top'>
<div className='smMd:hidden'>
<div className='md:hidden'>
<HetMobileToolbar />
</div>
<div className='hidden smMd:block'>
<div className='hidden md:block'>
<HetDesktopToolbar />
</div>
</AppBar>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Button } from '@mui/material'
import { type ReactNode } from 'react'
import type { ReactNode } from 'react'
import { useHistory } from 'react-router-dom'

interface HetBigCTAProps {
interface HetCTABigProps {
children: ReactNode
href: string
id?: string
className?: string
}

export default function HetBigCTA(props: HetBigCTAProps) {
export default function HetCTABig(props: HetCTABigProps) {
const history = useHistory()

let handleClick = () => {
Expand Down
37 changes: 37 additions & 0 deletions frontend/src/styles/HetComponents/HetCTASmall.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Button } from '@mui/material'
import type { ReactNode } from 'react'
import { useHistory } from 'react-router-dom'

interface HetCTASmallProps {
children: ReactNode
href: string
id?: string
className?: string
}

export default function HetCTASmall({ children, href, id, className }: HetCTASmallProps) {
const history = useHistory()

const handleClick = () => {
if (!href.startsWith('mailto:')) {
history.push(href)
}
}

const isMailTo = href.startsWith('mailto:')
const optionalMailTo = isMailTo ? href : undefined

return (
<Button
id={id}
variant='outlined'
className={`rounded-2xl my-2 px-8 py-2 w-auto bg-altGreen ${className ?? ''}`}
href={optionalMailTo}
onClick={isMailTo ? undefined : handleClick}
>
<span className='text-small text-white font-bold'>
{children}
</span>
</Button>
)
}
Loading

0 comments on commit 2ac5c14

Please sign in to comment.