fix(nav): replace translucent mobile menu with solid opaque drawer to eliminate text collision on iOS

This commit is contained in:
2026-11-05 12:32:38 +05:30
parent 03b8924267
commit ec1f5c5c6a
+115 -41
View File
@@ -3,7 +3,18 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import Link from 'next/link'; import Link from 'next/link';
import { usePathname } from 'next/navigation'; import { usePathname } from 'next/navigation';
import { Menu, X, Smartphone, Layers, ArrowUpRight, Home } from 'lucide-react'; import {
Menu,
X,
Smartphone,
Layers,
ArrowUpRight,
Home,
ChevronRight,
Wrench,
Sparkles,
ShieldCheck
} from 'lucide-react';
import { SiteConfig, resolveLocalised } from '@/types'; import { SiteConfig, resolveLocalised } from '@/types';
import { BrandLogo } from './BrandLogo'; import { BrandLogo } from './BrandLogo';
@@ -25,6 +36,7 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
return () => window.removeEventListener('scroll', handleScroll); return () => window.removeEventListener('scroll', handleScroll);
}, []); }, []);
// Close mobile menu on Escape key
useEffect(() => { useEffect(() => {
if (!mobileMenuOpen) return; if (!mobileMenuOpen) return;
const closeOnEscape = (event: KeyboardEvent) => { const closeOnEscape = (event: KeyboardEvent) => {
@@ -34,27 +46,49 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
return () => document.removeEventListener('keydown', closeOnEscape); return () => document.removeEventListener('keydown', closeOnEscape);
}, [mobileMenuOpen]); }, [mobileMenuOpen]);
return ( // Lock body scroll on iOS/Mobile when mobile menu is open to prevent background bleed/scroll
<header className="fixed top-0 left-0 right-0 w-full z-50 pointer-events-none"> useEffect(() => {
{/* 1. Ultra-Smooth High-Performance Gradient Blur Canopy (Zero lag, locks at 60/120fps) */} if (mobileMenuOpen) {
<div className="absolute top-0 inset-x-0 h-28 sm:h-32 pointer-events-none overflow-hidden select-none"> document.body.style.overflow = 'hidden';
{/* Single hardware-accelerated progressive blur */} document.body.style.touchAction = 'none';
<div } else {
className="absolute inset-0 backdrop-blur-md" document.body.style.overflow = '';
style={{ document.body.style.touchAction = '';
maskImage: 'linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 45%, rgba(0,0,0,0) 100%)', }
WebkitMaskImage: 'linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 45%, rgba(0,0,0,0) 100%)', return () => {
}} document.body.style.overflow = '';
/> document.body.style.touchAction = '';
};
}, [mobileMenuOpen]);
{/* Seamless Color Melt into warm canvas background (#FAF8F5) */} return (
<div <header
className="absolute inset-0 bg-gradient-to-b from-[#FAF8F5] via-[#FAF8F5]/85 to-transparent pointer-events-none" className={`fixed top-0 left-0 right-0 w-full z-50 transition-colors duration-200 ${
/> mobileMenuOpen
</div> ? 'bg-[#FAF8F5] pointer-events-auto border-b border-slate-200/90 shadow-sm'
: 'pointer-events-none'
}`}
>
{/* 1. Ultra-Smooth High-Performance Gradient Blur Canopy (Active only when menu is closed) */}
{!mobileMenuOpen && (
<div className="absolute top-0 inset-x-0 h-28 sm:h-32 pointer-events-none overflow-hidden select-none">
<div
className="absolute inset-0 backdrop-blur-md"
style={{
maskImage: 'linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 45%, rgba(0,0,0,0) 100%)',
WebkitMaskImage: 'linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 45%, rgba(0,0,0,0) 100%)',
}}
/>
<div
className="absolute inset-0 bg-gradient-to-b from-[#FAF8F5] via-[#FAF8F5]/85 to-transparent pointer-events-none"
/>
</div>
)}
{/* 2. Top Prismatic Micro-Highlight */} {/* 2. Top Prismatic Micro-Highlight */}
<div className="absolute top-0 inset-x-0 h-[1px] bg-gradient-to-r from-transparent via-white/80 to-transparent pointer-events-none z-30" /> {!mobileMenuOpen && (
<div className="absolute top-0 inset-x-0 h-[1px] bg-gradient-to-r from-transparent via-white/80 to-transparent pointer-events-none z-30" />
)}
{/* 3. Main Aligned Edge-to-Edge Navigation Bar */} {/* 3. Main Aligned Edge-to-Edge Navigation Bar */}
<div className="relative z-30 pointer-events-auto py-3 sm:py-3.5"> <div className="relative z-30 pointer-events-auto py-3 sm:py-3.5">
@@ -64,7 +98,7 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
<BrandLogo size="md" /> <BrandLogo size="md" />
</div> </div>
{/* Center Navigation Links - Protected Optical Floating Pill */} {/* Center Navigation Links - Protected Optical Floating Pill (Desktop only) */}
<nav className="hidden md:flex items-center gap-1 px-2 py-1 rounded-full bg-white/60 backdrop-blur-md border border-white/80 shadow-sm relative z-20"> <nav className="hidden md:flex items-center gap-1 px-2 py-1 rounded-full bg-white/60 backdrop-blur-md border border-white/80 shadow-sm relative z-20">
{/* Dedicated Top Home Button */} {/* Dedicated Top Home Button */}
<Link <Link
@@ -108,7 +142,7 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
</Link> </Link>
</nav> </nav>
{/* Right CTA Button */} {/* Right CTA Button (Desktop only) */}
<div className="hidden md:flex items-center space-x-3 relative z-20 flex-shrink-0"> <div className="hidden md:flex items-center space-x-3 relative z-20 flex-shrink-0">
<Link <Link
href={config.nav.cta.href} href={config.nav.cta.href}
@@ -124,7 +158,7 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
<div className="flex md:hidden items-center space-x-2 relative z-20"> <div className="flex md:hidden items-center space-x-2 relative z-20">
<button <button
onClick={() => setMobileMenuOpen(!mobileMenuOpen)} 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" className="p-2.5 rounded-xl text-slate-800 bg-white hover:bg-slate-50 border border-slate-200/90 shadow-sm transition-colors active:scale-95"
aria-label={mobileMenuOpen ? 'Close navigation menu' : 'Open navigation menu'} aria-label={mobileMenuOpen ? 'Close navigation menu' : 'Open navigation menu'}
aria-expanded={mobileMenuOpen} aria-expanded={mobileMenuOpen}
aria-controls="mobile-navigation" aria-controls="mobile-navigation"
@@ -135,68 +169,108 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
</div> </div>
</div> </div>
{/* Mobile Drawer (Full width dropdown) */} {/* Mobile Solid Opaque Drawer (100% Solid Warm Canvas - Zero Transparency Bleed or Text Collision) */}
{mobileMenuOpen && ( {mobileMenuOpen && (
<nav <nav
id="mobile-navigation" id="mobile-navigation"
aria-label="Mobile navigation" aria-label="Mobile navigation"
className="md:hidden mt-1 pointer-events-auto border-t border-slate-900/[0.08] bg-[#FAF8F5]/98 backdrop-blur-2xl p-5 space-y-3 shadow-2xl animate-in slide-in-from-top-2 duration-200" className="md:hidden fixed inset-x-0 top-[60px] sm:top-[68px] bottom-0 z-50 bg-[#FAF8F5] overflow-y-auto px-4 py-5 flex flex-col justify-between pointer-events-auto border-t border-slate-200/90 animate-in fade-in duration-200"
> >
<div className="max-w-7xl mx-auto space-y-1"> <div className="w-full max-w-md mx-auto space-y-2.5">
{/* Home Card */}
<Link <Link
href="/" href="/"
onClick={() => setMobileMenuOpen(false)} onClick={() => setMobileMenuOpen(false)}
aria-current={pathname === '/' ? 'page' : undefined} aria-current={pathname === '/' ? 'page' : undefined}
className={`flex items-center gap-2.5 px-4 py-3 rounded-xl text-sm font-semibold transition-colors ${ className={`flex items-center justify-between px-4 py-3.5 rounded-2xl text-sm font-semibold transition-all border ${
pathname === '/' pathname === '/'
? 'text-blue-700 bg-white shadow-sm border border-slate-900/[0.06]' ? 'text-blue-700 bg-white border-blue-200 shadow-sm'
: 'text-slate-800 hover:bg-white/60' : 'text-slate-800 bg-white hover:bg-slate-50 border-slate-200/80 shadow-xs'
}`} }`}
> >
<Home className="w-4 h-4 text-blue-600" /> <div className="flex items-center gap-3">
<span>Home</span> <div className="w-9 h-9 rounded-xl bg-blue-50 flex items-center justify-center text-blue-600">
<Home className="w-4 h-4" />
</div>
<span className="text-sm font-bold">Home</span>
</div>
<ChevronRight className="w-4 h-4 text-slate-400" />
</Link> </Link>
{/* Header Navigation Cards */}
{config.nav.header.map((item) => { {config.nav.header.map((item) => {
const active = pathname === item.href || (item.href !== '/' && pathname.startsWith(`${item.href}/`)); const active = pathname === item.href || (item.href !== '/' && pathname.startsWith(`${item.href}/`));
let Icon = Wrench;
let iconColor = 'text-indigo-600';
let iconBg = 'bg-indigo-50';
if (item.href.includes('app')) {
Icon = Smartphone;
iconColor = 'text-sky-600';
iconBg = 'bg-sky-50';
} else if (item.href.includes('pricing')) {
Icon = Sparkles;
iconColor = 'text-amber-600';
iconBg = 'bg-amber-50';
} else if (item.href.includes('trust')) {
Icon = ShieldCheck;
iconColor = 'text-emerald-600';
iconBg = 'bg-emerald-50';
}
return ( return (
<Link <Link
key={item.href} key={item.href}
href={item.href} href={item.href}
onClick={() => setMobileMenuOpen(false)} onClick={() => setMobileMenuOpen(false)}
aria-current={active ? 'page' : undefined} aria-current={active ? 'page' : undefined}
className={`flex items-center justify-between px-4 py-3 rounded-xl text-sm font-semibold transition-colors ${ className={`flex items-center justify-between px-4 py-3.5 rounded-2xl text-sm font-semibold transition-all border ${
active active
? 'text-blue-700 bg-white shadow-sm border border-slate-900/[0.06]' ? 'text-blue-700 bg-white border-blue-200 shadow-sm'
: 'text-slate-800 hover:bg-white/60' : 'text-slate-800 bg-white hover:bg-slate-50 border-slate-200/80 shadow-xs'
}`} }`}
> >
<span>{resolveLocalised(item.label, currentLocale)}</span> <div className="flex items-center gap-3">
<div className={`w-9 h-9 rounded-xl ${iconBg} flex items-center justify-center ${iconColor}`}>
<Icon className="w-4 h-4" />
</div>
<span className="text-sm font-bold">{resolveLocalised(item.label, currentLocale)}</span>
</div>
<ChevronRight className="w-4 h-4 text-slate-400" />
</Link> </Link>
); );
})} })}
{/* Creative Suite Card */}
<Link <Link
href="/#studio-suite" href="/#studio-suite"
onClick={() => setMobileMenuOpen(false)} onClick={() => setMobileMenuOpen(false)}
className="flex items-center justify-between px-4 py-3 rounded-xl text-sm font-semibold text-blue-700 bg-blue-50/70 hover:bg-blue-100/70" className="flex items-center justify-between px-4 py-3.5 rounded-2xl text-sm font-semibold text-blue-700 bg-blue-50/90 hover:bg-blue-100/90 border border-blue-200 transition-colors shadow-xs"
> >
<span className="flex items-center gap-2"> <div className="flex items-center gap-3">
<Layers className="w-4 h-4 text-blue-600" /> <div className="w-9 h-9 rounded-xl bg-blue-600 text-white flex items-center justify-center shadow-xs">
Creative Suite <Layers className="w-4 h-4" />
</span> </div>
<span className="text-sm font-bold">Creative Suite</span>
</div>
<ChevronRight className="w-4 h-4 text-blue-400" />
</Link> </Link>
</div> </div>
<div className="pt-3 border-t border-slate-900/[0.06] max-w-7xl mx-auto"> {/* Bottom Primary Handoff Card */}
<div className="w-full max-w-md mx-auto pt-5 pb-3 border-t border-slate-200/90 mt-4 space-y-3">
<Link <Link
href={config.nav.cta.href} href={config.nav.cta.href}
onClick={() => setMobileMenuOpen(false)} onClick={() => setMobileMenuOpen(false)}
className="flex items-center justify-center gap-2 w-full py-3.5 rounded-xl text-sm font-bold text-white bg-gradient-to-r from-blue-600 to-indigo-600 shadow-md shadow-blue-500/25" className="flex items-center justify-center gap-2 w-full py-4 rounded-2xl text-sm font-bold text-white bg-gradient-to-r from-blue-600 via-indigo-600 to-blue-600 shadow-lg shadow-blue-500/25 active:scale-[0.98] transition-transform"
> >
<Smartphone className="w-4 h-4" /> <Smartphone className="w-4 h-4" />
<span>{resolveLocalised(config.nav.cta.label, currentLocale)}</span> <span>{resolveLocalised(config.nav.cta.label, currentLocale)}</span>
<ArrowUpRight className="w-4 h-4 opacity-80" />
</Link> </Link>
<p className="text-center text-[11px] font-medium text-slate-500">
Zero Photo Retention • 100% Client-Side Privacy
</p>
</div> </div>
</nav> </nav>
)} )}