diff --git a/src/components/layout/Nav.tsx b/src/components/layout/Nav.tsx index 6c28808..b21c4aa 100644 --- a/src/components/layout/Nav.tsx +++ b/src/components/layout/Nav.tsx @@ -115,11 +115,20 @@ export default function Nav() { } }, [pathname]) - const otherLocale = locales.find((l) => l !== currentLocale) ?? 'fr' + const [localeMenuOpen, setLocaleMenuOpen] = useState(false) + + const LOCALE_DISPLAY: Record = { + en: { flag: '🇬🇧', label: 'English', short: 'EN' }, + fr: { flag: '🇫🇷', label: 'Français', short: 'FR' }, + it: { flag: '🇮🇹', label: 'Italiano', short: 'IT' }, + es: { flag: '🇪🇸', label: 'Español', short: 'ES' }, + } + const isHomePage = pathname === '/' - function handleLocaleSwitch() { - router.replace(pathname as any, { locale: otherLocale as any }) + function handleLocaleSwitch(targetLocale: string) { + router.replace(pathname as any, { locale: targetLocale as any }) + setLocaleMenuOpen(false) } // Prevent body scroll when mobile menu is open @@ -183,14 +192,58 @@ export default function Nav() { {/* ── Desktop right controls ── */}
- {/* Language toggle */} - + {/* Language dropdown */} +
+ + + {/* Transparent overlay to close on outside click */} + {localeMenuOpen && ( + {/* Start a Project CTA */} setMobileOpen(true)} + onClick={() => { setMobileOpen(true); setLocaleMenuOpen(false) }} aria-label="Open navigation menu" aria-expanded={mobileOpen} aria-controls="mobile-menu" @@ -300,16 +353,27 @@ export default function Nav() { {/* Bottom controls */}
- {/* Language toggle */} - + {/* Language options */} +
+ {locales + .filter((l) => l !== currentLocale) + .map((l) => { + const display = LOCALE_DISPLAY[l] + return ( + + ) + })} +
{/* CTA */}