Skip to content

Commit

Permalink
Updated hero of main page (#51)
Browse files Browse the repository at this point in the history
* Updated hero of main page
  • Loading branch information
nickbristow authored Nov 19, 2024
1 parent 27f7c81 commit c99e0d7
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 29 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
},
"cSpell.words": ["USWDS"]
}
Binary file added public/images/homepage-hero-bg.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions src/app/components/Header/Header.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,50 @@
font-size: 13px;
}
}

.homepage-hero {
position: relative;
overflow: hidden;

&::before {
content: '';
position: absolute;
inset: -20% -10% 0;
background: linear-gradient(
90deg,
rgba(76, 43, 100, 0.85) 12%,
rgba(0, 94, 162, 0.85) 50%,
rgba(0, 129, 161, 0.85) 98%
),
url('/images/homepage-hero-bg.jpeg');
background-size: cover;
background-position: center 40%;
transform: scale(1.2);
z-index: 0;
}

:global {
.usa-navbar,
.usa-hero {
position: relative;
z-index: 1;
}
}
section h1,
section p {
color: white;
z-index: 1;
}
}

.navbarLogoText {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
94 changes: 72 additions & 22 deletions src/app/components/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,84 @@
'use client';
import { useState } from 'react';
import { Header as USWDSHeader, PrimaryNav } from '@trussworks/react-uswds';
import Image from 'next/image';
import React from 'react';
import { usePathname } from 'next/navigation';
import classNames from 'classnames';
import styles from './Header.module.scss';
import { basePath } from '../../utils/constants';
import { NavigationLink } from '../NavigationLink/NavigationLink';
import styles from './Header.module.scss';
import Hero from '../Hero/Hero';

interface HeroContent {
heroClass?: string;
heroHeader: string;
heroSubheader: string;
}

type SpecialContent = Record<string, HeroContent | undefined>;

const specialContent: SpecialContent = {
'/': {
heroClass: 'homepage-hero',
heroHeader: `Improve the way your jurisdiction collects, processes, and
views public health data`,
heroSubheader: `Turn your jurisdiction's data into meaningful intelligence that drives
timely public health action using CDC's free, cloud-based products built
from Data Integration Building Blocks, or DIBBs.`,
},
};

const navigationItems = [
{
key: 'products',
href: '/our-products',
text: 'Our products',
},
{
key: 'case-studies',
href: '/case-studies',
text: 'Case studies',
},
{
key: 'engage',
href: '/engage-with-us',
text: 'Engage with us',
},
];

export default function Header() {
const [expanded, setExpanded] = React.useState(false);
const onClick = () => {
if (window.innerWidth < 1024) setExpanded((prvExpanded) => !prvExpanded);
const pathname = usePathname();
const customContent = specialContent[pathname];
const [expanded, setExpanded] = useState(false);

const handleClick = () => {
if (window.innerWidth < 1024) {
setExpanded((prev) => !prev);
}
};

const testItemsMenu = [
<NavigationLink key="one" href="/our-products" onClick={onClick}>
Our products
</NavigationLink>,
<NavigationLink key="two" href="/case-studies" onClick={onClick}>
Case studies
</NavigationLink>,
<NavigationLink key="three" href="/engage-with-us" onClick={onClick}>
Engage with us
</NavigationLink>,
];
const navigationLinks = navigationItems.map(({ key, href, text }) => (
<NavigationLink key={key} href={href} onClick={handleClick}>
{text}
</NavigationLink>
));

return (
<>
<div
className={classNames(
customContent?.heroClass && styles[customContent.heroClass],
)}
>
<a className="usa-skipnav" href="#main-content">
Skip to main content
</a>

<USWDSHeader basic={true} className="bg-background-teal">
<USWDSHeader basic className="bg-background-teal">
<div className="usa-nav-container flex-vertical-center">
<div className="usa-navbar">
<div className="usa-logo">
<em className="usa-logo__text">
<a href={`${basePath}/`} title="<Project title>">
<a href={`${basePath}/`} title="DIBBs">
<span
className={classNames('sr-only', styles.navbarLogoText)}
>
Expand All @@ -48,6 +90,7 @@ export default function Header() {
alt=""
className="margin-x-0"
src={`${basePath}/images/dibbs-logo.svg`}
priority
/>
</a>
</em>
Expand All @@ -57,12 +100,19 @@ export default function Header() {
</button>
</div>
<PrimaryNav
items={testItemsMenu}
items={navigationLinks}
mobileExpanded={expanded}
onToggleMobileNav={onClick}
onToggleMobileNav={handleClick}
/>
</div>
</USWDSHeader>
</>

{customContent && (
<Hero
header={customContent.heroHeader}
subheader={customContent.heroSubheader}
/>
)}
</div>
);
}
6 changes: 0 additions & 6 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Grid, GridContainer } from '@trussworks/react-uswds';
import Image from 'next/image';
import { basePath } from './utils/constants';
import Carousel from './components/Carousel/Carousel';
import Hero from './components/Hero/Hero';
import { ContentContainer } from './components/ContentContainer/ContentContainer';
import { LinkButton } from './components/LinkButton/LinkButton';

Expand Down Expand Up @@ -49,11 +48,6 @@ const homeContent = {
export default async function Home() {
return (
<>
<Hero
header={homeContent.hero.header}
subheader={homeContent.hero.subheader}
/>

<DibbsSection />
<ValueSection />
<JurisdictionSection />
Expand Down

0 comments on commit c99e0d7

Please sign in to comment.