feat(ui): refine homepage and improve core interactions
This commit is contained in:
@@ -27,6 +27,15 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
return () => window.removeEventListener('scroll', handleScroll);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!mobileMenuOpen) return;
|
||||
const closeOnEscape = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape') setMobileMenuOpen(false);
|
||||
};
|
||||
document.addEventListener('keydown', closeOnEscape);
|
||||
return () => document.removeEventListener('keydown', closeOnEscape);
|
||||
}, [mobileMenuOpen]);
|
||||
|
||||
const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!glintRef.current) return;
|
||||
const rect = e.currentTarget.getBoundingClientRect();
|
||||
@@ -71,11 +80,12 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
{/* Center Navigation Links - Protected Optical Floating Pill */}
|
||||
<nav className="hidden md:flex items-center gap-1 px-2 py-1 rounded-full bg-white/55 backdrop-blur-md border border-white/70 shadow-sm relative z-20">
|
||||
{config.nav.header.map((item) => {
|
||||
const active = pathname === item.href;
|
||||
const active = pathname === item.href || (item.href !== '/' && pathname.startsWith(`${item.href}/`));
|
||||
return (
|
||||
<Link
|
||||
key={item.href}
|
||||
href={item.href}
|
||||
aria-current={active ? 'page' : undefined}
|
||||
className={`relative px-4 py-2 rounded-full text-xs font-bold tracking-wide transition-all duration-200 ${
|
||||
active
|
||||
? 'text-blue-700 bg-white shadow-sm border border-slate-900/[0.06]'
|
||||
@@ -114,7 +124,9 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
<button
|
||||
onClick={() => setMobileMenuOpen(!mobileMenuOpen)}
|
||||
className="p-2 rounded-xl text-slate-800 bg-white/80 hover:bg-white border border-white/90 shadow-sm transition-colors"
|
||||
aria-label="Open menu"
|
||||
aria-label={mobileMenuOpen ? 'Close navigation menu' : 'Open navigation menu'}
|
||||
aria-expanded={mobileMenuOpen}
|
||||
aria-controls="mobile-navigation"
|
||||
>
|
||||
{mobileMenuOpen ? <X className="w-5 h-5 text-blue-600" /> : <Menu className="w-5 h-5" />}
|
||||
</button>
|
||||
@@ -124,15 +136,16 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
|
||||
{/* Mobile Drawer (Matching Liquid Glass Card) */}
|
||||
{mobileMenuOpen && (
|
||||
<div className="max-w-6xl mx-auto md:hidden mt-2 rounded-2xl liquid-glass-dropdown p-5 space-y-3 pointer-events-auto shadow-2xl animate-in slide-in-from-top-3 duration-200">
|
||||
<nav id="mobile-navigation" aria-label="Mobile navigation" className="max-w-6xl mx-auto md:hidden mt-2 rounded-2xl liquid-glass-dropdown p-5 space-y-3 pointer-events-auto shadow-2xl animate-in slide-in-from-top-3 duration-200">
|
||||
<div className="space-y-1">
|
||||
{config.nav.header.map((item) => {
|
||||
const active = pathname === item.href;
|
||||
const active = pathname === item.href || (item.href !== '/' && pathname.startsWith(`${item.href}/`));
|
||||
return (
|
||||
<Link
|
||||
key={item.href}
|
||||
href={item.href}
|
||||
onClick={() => setMobileMenuOpen(false)}
|
||||
aria-current={active ? 'page' : undefined}
|
||||
className={`flex items-center justify-between px-4 py-3 rounded-xl text-sm font-semibold transition-colors ${
|
||||
active
|
||||
? 'text-blue-700 bg-white shadow-sm border border-slate-900/[0.06]'
|
||||
@@ -166,7 +179,7 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
<span>{resolveLocalised(config.nav.cta.label, currentLocale)}</span>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
)}
|
||||
</header>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user