Files
next-web/src/components/Navbar.tsx
T

177 lines
5.5 KiB
TypeScript
Raw Normal View History

2025-06-30 15:54:10 -04:00
"use client";
import React, { useState, useEffect } from 'react';
import classnames from 'classnames';
import Link from 'next/link';
import Button from './Button';
import Image from 'next/image';
2025-07-02 16:39:16 -04:00
import Dropdown from "./Dropdown";
export interface MenuItem {
2025-07-03 13:35:22 -04:00
id: string;
2025-07-02 16:39:16 -04:00
title: string;
route?: string;
children?: MenuItem[];
}
const menuItems: MenuItem[] = [
2025-07-08 14:57:06 -04:00
{
id: "members",
title: "Members",
children: [
{
id: "findMedicalProvider",
title: "Find a Medical Provider",
route: "",
},
{
id: "obtainRxInformation",
title: "Obtain Rx Information",
route: "",
},
],
},
2025-07-02 16:39:16 -04:00
{
2025-07-03 13:35:22 -04:00
id: "employers",
2025-07-02 16:39:16 -04:00
title: "Employers",
children: [
{
2025-07-03 13:35:22 -04:00
id: "employerServices",
2025-07-02 16:39:16 -04:00
title: "Employer Services",
route: "",
},
{
2025-07-03 13:35:22 -04:00
id: "selfFundedPlans",
2025-07-02 16:39:16 -04:00
title: "Self-Funded Plans",
route: "",
},
{
2025-07-03 13:35:22 -04:00
id: "controlHealthCareCosts",
2025-07-02 16:39:16 -04:00
title: "Control Health Care Costs",
route: "",
},
],
},
{
2025-07-03 13:35:22 -04:00
id: "providers",
2025-07-02 16:39:16 -04:00
title: "Providers",
children: [
{
2025-07-03 13:35:22 -04:00
id: "eligibilityLookup",
2025-07-02 16:39:16 -04:00
title: "Eligibility Lookup",
route: "",
},
{
2025-07-03 13:35:22 -04:00
id: "contactBbs",
2025-07-02 16:39:16 -04:00
title: "Contact BBS",
route: "",
},
],
},
{
2025-07-03 13:35:22 -04:00
id: "brokers",
2025-07-02 16:39:16 -04:00
title: "Brokers",
route: "",
},
];
2025-06-30 15:54:10 -04:00
const Navbar = () => {
const [isScrolled, setIsScrolled] = useState(false);
useEffect(() => {
const handleScroll = () => {
2025-07-08 14:57:06 -04:00
// const viewportHeight = window.innerHeight;
const subtractedHeight = window.innerHeight - 80;
// Find pixels from top to bottom of "tag line" div
2025-07-08 14:57:06 -04:00
if (window.scrollY > subtractedHeight) {
2025-06-30 15:54:10 -04:00
setIsScrolled(true);
} else {
setIsScrolled(false);
}
};
window.addEventListener('scroll', handleScroll);
return () => {
window.removeEventListener('scroll', handleScroll);
};
}, []);
return (
2025-07-08 14:57:06 -04:00
<nav className="sticky top-0 left-0 z-50 hidden lg:flex h-[85px] justify-center bg-transparent">
2025-06-30 15:54:10 -04:00
<div className={classnames(
"w-11/12 bg-britton-neutral px-1 text-britton-dark rounded-b-3xl", {
2025-07-08 14:57:06 -04:00
"h-13 pb-1 border-b-2 border-x-2 border-black" : isScrolled,
"h-full pb-4" : !isScrolled
2025-06-30 15:54:10 -04:00
}
)}
>
<div className="container mx-auto justify-between items-center flex">
2025-07-08 14:57:06 -04:00
<div className={classnames('rounded-b-2xl bg-britton-dark w-72', {"hidden" : isScrolled})}>
2025-06-30 15:54:10 -04:00
<Image
src="/images/bbstpa-forsite.png"
alt="Britton Logo"
2025-07-03 13:35:22 -04:00
width={205}
height={60}
2025-06-30 15:54:10 -04:00
/>
</div>
2025-07-08 14:57:06 -04:00
<div className={classnames('rounded-b-2xl py-2 mb-1 bg-britton-dark font-semibold text-britton-neutral text-center text-lg uppercase w-72', {"hidden" : !isScrolled})}>
<Link href="/">
Britton Benefit Services
</Link>
</div>
2025-07-02 16:39:16 -04:00
{/* <ul className={classnames("flex space-x-4 font-semibold text-lg uppercase", {"pl-2" : isScrolled})}>
2025-06-30 15:54:10 -04:00
<li>
<Link href="/services" className="hover:text-britton-light">
Employers
</Link>
</li>
<li>
<Link href="/contact" className="hover:text-britton-light">
Members
</Link>
</li>
<li>
<Link href="/contact" className="hover:text-britton-light">
Providers
</Link>
</li>
<li>
<Link href="/contact" className="hover:text-britton-light">
Brokers
</Link>
</li>
<li>
<Link href="/contact" className="hover:text-britton-light">
Contact Us
</Link>
</li>
2025-07-02 16:39:16 -04:00
</ul> */}
2025-07-03 13:35:22 -04:00
<div className={classnames("flex space-x-4 font-semibold text-lg", {"pl-2" : isScrolled})}>
2025-07-02 16:39:16 -04:00
{menuItems.map((item) => {
return item.hasOwnProperty("children") ?
(
<Dropdown item={item} />
) : (
<Link className="hover:text-britton-light" href={item?.route || ""}>
{item.title}
</Link>
);
})}
</div>
<div className={classnames("flex space-x-2 font-semibold", {"pt-1" : isScrolled})}>
<Button className="bg-britton-neutral text-britton-accent2 hover:text-britton-accent py-1 px-4 rounded border-1 border-britton-accent2 hover:border-britton-accent">
2025-06-30 15:54:10 -04:00
Sign In
</Button>
<Button className="bg-britton-dark hover:bg-britton-medium text-britton-light py-1 px-4 rounded">
Get a Quote
</Button>
</div>
</div>
</div>
</nav>
);
};
export default Navbar;