This commit is contained in:
null 2026-05-26 13:04:57 -05:00
parent 335601b00e
commit f0f0cfd599
2 changed files with 71 additions and 39 deletions

View File

@ -6,6 +6,7 @@ import { Link, useLocation } from 'react-router-dom'
const Header = () => { const Header = () => {
const [isScrolled, setIsScrolled] = useState(false) const [isScrolled, setIsScrolled] = useState(false)
const [mobileMenuOpen, setMobileMenuOpen] = useState(false) const [mobileMenuOpen, setMobileMenuOpen] = useState(false)
const [openDropdown, setOpenDropdown] = useState(null)
const location = useLocation() const location = useLocation()
useEffect(() => { useEffect(() => {
@ -16,6 +17,10 @@ const Header = () => {
return () => window.removeEventListener('scroll', handleScroll) return () => window.removeEventListener('scroll', handleScroll)
}, []) }, [])
useEffect(() => {
setOpenDropdown(null)
}, [location.pathname])
const navLinks = [ const navLinks = [
{ name: 'Home', href: '/' }, { name: 'Home', href: '/' },
{ name: 'Services', href: '/services' }, { name: 'Services', href: '/services' },
@ -43,6 +48,7 @@ const Header = () => {
] ]
const closeMobileMenu = () => setMobileMenuOpen(false) const closeMobileMenu = () => setMobileMenuOpen(false)
const closeDropdown = () => setOpenDropdown(null)
const isActive = (href) => location.pathname === href const isActive = (href) => location.pathname === href
@ -64,22 +70,42 @@ const Header = () => {
{/* Desktop Nav */} {/* Desktop Nav */}
<nav className="hidden md:flex items-center gap-6" aria-label="Main navigation"> <nav className="hidden md:flex items-center gap-6" aria-label="Main navigation">
{navLinks.map((link) => ( {navLinks.map((link) => {
<div key={link.name} className="relative group"> const hasDropdown = link.name === 'Services' || link.name === 'Industries'
return (
<div
key={link.name}
className="relative"
onMouseEnter={() => hasDropdown && setOpenDropdown(link.name)}
onMouseLeave={closeDropdown}
onBlur={(event) => {
if (!event.currentTarget.contains(event.relatedTarget)) {
closeDropdown()
}
}}
onKeyDown={(event) => {
if (event.key === 'Escape') {
closeDropdown()
}
}}
>
<Link <Link
to={link.href} to={link.href}
onFocus={() => hasDropdown && setOpenDropdown(link.name)}
onClick={closeDropdown}
className={`text-sm font-medium transition-colors ${isActive(link.href) ? 'text-white underline underline-offset-4' : 'text-white/70 hover:text-white'}`} className={`text-sm font-medium transition-colors ${isActive(link.href) ? 'text-white underline underline-offset-4' : 'text-white/70 hover:text-white'}`}
> >
{link.name} {link.name}
</Link> </Link>
{/* Services Dropdown */} {/* Services Dropdown */}
{link.name === 'Services' && ( {link.name === 'Services' && (
<div className="absolute top-full left-0 w-64 bg-white rounded-md shadow-xl border border-gray-200 hidden group-hover:block pt-2"> <div className={`absolute top-full left-0 w-64 bg-white rounded-md shadow-xl border border-gray-200 pt-2 ${openDropdown === 'Services' ? 'block' : 'hidden'}`}>
<div className="p-2"> <div className="p-2">
{serviceLinks.map((service) => ( {serviceLinks.map((service) => (
<Link <Link
key={service.name} key={service.name}
to={service.href} to={service.href}
onClick={closeDropdown}
className="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 rounded-md transition-colors" className="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 rounded-md transition-colors"
> >
{service.name} {service.name}
@ -90,12 +116,13 @@ const Header = () => {
)} )}
{/* Industries Dropdown */} {/* Industries Dropdown */}
{link.name === 'Industries' && ( {link.name === 'Industries' && (
<div className="absolute top-full left-0 w-64 bg-white rounded-md shadow-xl border border-gray-200 hidden group-hover:block pt-2"> <div className={`absolute top-full left-0 w-64 bg-white rounded-md shadow-xl border border-gray-200 pt-2 ${openDropdown === 'Industries' ? 'block' : 'hidden'}`}>
<div className="p-2"> <div className="p-2">
{industryLinks.map((industry) => ( {industryLinks.map((industry) => (
<Link <Link
key={industry.name} key={industry.name}
to={industry.href} to={industry.href}
onClick={closeDropdown}
className="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 rounded-md transition-colors" className="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 rounded-md transition-colors"
> >
{industry.name} {industry.name}
@ -105,7 +132,8 @@ const Header = () => {
</div> </div>
)} )}
</div> </div>
))} )
})}
</nav> </nav>
{/* CTA Button */} {/* CTA Button */}

View File

@ -0,0 +1,4 @@
{
"status": "failed",
"failedTests": []
}