forked from CDCgov/dibbs-site
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNavbarUSWDS.js
More file actions
65 lines (57 loc) · 2.57 KB
/
NavbarUSWDS.js
File metadata and controls
65 lines (57 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { Banner, Header, NavMenuButton, PrimaryNav, Title } from "@trussworks/react-uswds";
import Link from "next/link";
import { useRouter } from "next/router";
import React from "react";
import styles from '../../styles/Home.module.scss'
export default function Navbar({ }) {
const [expanded, setExpanded] = React.useState(false)
const router = useRouter();
const onClick = () => { if (window.innerWidth < 1024) setExpanded((prvExpanded) => !prvExpanded) }
const testItemsMenu = [
<Link
href='/'
key="one"
className={`usa-nav__link ${styles.homeNavItem}`}
onClick={onClick}>
<span className={styles.navbarItemText}>Home</span>
</Link>,
<NavigationLink key="two" href='/about' text='About' router={router} onClick={onClick} />,
<NavigationLink key="three" href='/products' text='Products' router={router} onClick={onClick} />,
<NavigationLink key="four" href='/engage-with-us' text='Engage with us' router={router} onClick={onClick} />,
]
return <>
<a className="usa-skipnav" href="#main-content">Skip to main content</a>
<div className={`usa-overlay ${expanded ? 'is-visible' : ''}`}></div>
<Header basic={true} className='bg-primary-darker'>
<div className="desktop:padding-bottom-2 usa-nav-container max-w-full">
<div className="w-full usa-navbar">
<Title className='text-base-lightest'>
<Link href='/' className="desktop:padding-1">
<span className={styles.navbarLogoText} href='/dibbs-site'>
Data Integration Building Blocks
</span>
</Link>
</Title>
<NavMenuButton onClick={onClick} label="Menu" />
</div>
<PrimaryNav
items={testItemsMenu}
mobileExpanded={expanded}
onToggleMobileNav={onClick}
>
</PrimaryNav>
</div>
<div className="usa-banner padding-2">
<p className="usa-banner__header-text"></p>
</div>
</Header>
</>;
}
function NavigationLink({ href, text, router, onClick }) {
const isActive = router.asPath === (href);
return (
(<Link href={href} passHref className={`usa-nav__link`} onClick={onClick}>
<span className={(isActive && "navbar-item-active") + ' ' + styles.navbarItemText}>{text}</span>
</Link>)
);
}