'use client'; import React, { useState, useEffect } from 'react'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; import { Menu, X, Smartphone, Layers, ArrowUpRight, Home, ChevronRight, Wrench, Sparkles, ShieldCheck } from 'lucide-react'; import { SiteConfig, resolveLocalised } from '@/types'; import { BrandLogo } from './BrandLogo'; interface NavbarProps { config: SiteConfig; currentLocale: string; } export function Navbar({ config, currentLocale }: NavbarProps) { const [isScrolled, setIsScrolled] = useState(false); const [mobileMenuOpen, setMobileMenuOpen] = useState(false); const pathname = usePathname(); useEffect(() => { let lastScrolled = window.scrollY > 20; if (lastScrolled !== isScrolled) { setIsScrolled(lastScrolled); } const handleScroll = () => { const nextScrolled = window.scrollY > 20; if (nextScrolled !== lastScrolled) { lastScrolled = nextScrolled; setIsScrolled(nextScrolled); } }; window.addEventListener('scroll', handleScroll, { passive: true }); return () => window.removeEventListener('scroll', handleScroll); }, []); // Close mobile menu on Escape key useEffect(() => { if (!mobileMenuOpen) return; const closeOnEscape = (event: KeyboardEvent) => { if (event.key === 'Escape') setMobileMenuOpen(false); }; document.addEventListener('keydown', closeOnEscape); return () => document.removeEventListener('keydown', closeOnEscape); }, [mobileMenuOpen]); // Lock body scroll on iOS/Mobile when mobile menu is open to prevent background bleed/scroll useEffect(() => { if (mobileMenuOpen) { document.body.style.overflow = 'hidden'; document.body.style.touchAction = 'none'; } else { document.body.style.overflow = ''; document.body.style.touchAction = ''; } return () => { document.body.style.overflow = ''; document.body.style.touchAction = ''; }; }, [mobileMenuOpen]); return (
{/* 1. Ultra-Smooth High-Performance Gradient Blur Canopy (Active only when menu is closed) */} {!mobileMenuOpen && (
)} {/* 2. Top Prismatic Micro-Highlight */} {!mobileMenuOpen && (
)} {/* 3. Main Aligned Edge-to-Edge Navigation Bar */}
{/* Brand Logo */}
{/* Center Navigation Links - Protected Optical Floating Pill (Desktop only) */} {/* Right CTA Button (Desktop only) */}
{resolveLocalised(config.nav.cta.label, currentLocale)}
{/* Mobile Menu Trigger */}
{/* Mobile Solid Opaque Drawer (100% Solid Warm Canvas - Zero Transparency Bleed or Text Collision) */} {mobileMenuOpen && ( )}
); }