feat(nav): mobile sheet + shared bar control chrome (v3 mobile navigation)

MobileMenu.tsx: conditional-mounted glass sheet (94% + blur(12px)), three labelled groups, staggered rows, Mode/Language/Theme-color segmented rows, Connect tiles, safe-area padding, overscroll contain.

Navigation.tsx: honest dialog - Escape on document, inert on #main-content/.footer/.back-to-top, focus restore guarded by offsetParent, matchMedia close above 1024px, icon morph, navPaths from data; route-change close effect deleted.

SocialLinks: single data-driven renderer (src/data/social.ts + strings.social.aria); Hero and Footer cut over; mailto without target/rel; dead .social-link span rule removed; hero/footer centering scoped.

Bar: .nav-control shared chrome for mode/language/theme-color, icon-only 20px half-circle palette trigger at every width, <=420px bar guard; .nav glass 85% -> 94%.

Docs: spec-v3-mobile-navigation.md v0.5.0 (Q14 recorded, gates re-run 16/16 SSR), spec-ui-layout.md and AGENTS.md corrected.
This commit is contained in:
dong.nguyen committed 2026-10-17 10:27:36 +07:00
1 parent f2c920d6ad
commit d0aa9958c8
16 files changed
+1386 -311

No files matched your search

+144
View File
@@ -0,0 +1,144 @@
import { useRef } from 'react'
import { useLocation } from 'react-router'
import { AnimatePresence, motion, useReducedMotion } from 'motion/react'
import { navPaths } from '@/data/navigation'
import { paletteIds, paletteMeta } from '@/data/palettes'
import { useTheme } from '@/hooks/useTheme'
import { useLanguage } from '@/hooks/useLanguage'
import { strings } from '@/i18n/strings'
import { RollingTextLink } from '@/components/ui/RollingTextLink'
import { SocialLinks } from '@/components/ui/SocialLinks'
interface MobileMenuProps {
open: boolean
onClose: () => void
}
export function MobileMenu({ open, onClose }: MobileMenuProps) {
const { lang, setLang } = useLanguage()
const { resolvedTheme, setTheme, palette, setPalette } = useTheme()
const location = useLocation()
const reduceMotion = useReducedMotion()
const firstLinkRef = useRef<HTMLAnchorElement>(null)
return (
<AnimatePresence>
{open && (
<motion.div
id="mobile-menu"
className="mobile-menu"
role="dialog"
aria-modal="true"
aria-label={strings.nav.menuAria[lang]}
initial={{ opacity: 0, y: -12 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -12 }}
transition={{ duration: 0.22, ease: [0.25, 0.1, 0.25, 1] }}
onAnimationComplete={() => firstLinkRef.current?.focus()}
>
<div className="mobile-menu-inner">
<nav className="mobile-menu-group" aria-label={strings.nav.groupMenu[lang]}>
<span className="mobile-menu-heading">{strings.nav.groupMenu[lang]}</span>
<ul className="mobile-menu-list">
{navPaths.map((path, index) => {
const navKey = path === '/' ? 'home' : path.replace('/', '') as keyof typeof strings.nav
const active = path === location.pathname
return (
<motion.li
key={path}
initial={{ opacity: 0, y: 8 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.22, delay: reduceMotion ? 0 : 0.05 + index * 0.04 }}
>
<RollingTextLink
to={path}
ref={index === 0 ? firstLinkRef : undefined}
ariaCurrent={active ? 'page' : undefined}
className={active ? 'mobile-menu-link active' : 'mobile-menu-link'}
onClick={onClose}
>
{strings.nav[navKey][lang]}
</RollingTextLink>
</motion.li>
)
})}
</ul>
</nav>
<div className="mobile-menu-group">
<span className="mobile-menu-heading">{strings.nav.groupAppearance[lang]}</span>
<div className="mobile-menu-segment">
<span className="mobile-menu-segment-label">{strings.nav.themeGroup[lang]}</span>
<div className="mobile-menu-segment-options" role="group" aria-label={strings.nav.themeGroup[lang]}>
<button
type="button"
className={resolvedTheme === 'dark' ? 'mobile-menu-segment-option active' : 'mobile-menu-segment-option'}
aria-pressed={resolvedTheme === 'dark'}
onClick={() => setTheme('dark')}
>
{strings.nav.themeDark[lang]}
</button>
<button
type="button"
className={resolvedTheme === 'light' ? 'mobile-menu-segment-option active' : 'mobile-menu-segment-option'}
aria-pressed={resolvedTheme === 'light'}
onClick={() => setTheme('light')}
>
{strings.nav.themeLight[lang]}
</button>
</div>
</div>
<div className="mobile-menu-segment">
<span className="mobile-menu-segment-label">{strings.nav.langGroup[lang]}</span>
<div className="mobile-menu-segment-options" role="group" aria-label={strings.nav.langGroup[lang]}>
<button
type="button"
className={lang === 'en' ? 'mobile-menu-segment-option active' : 'mobile-menu-segment-option'}
aria-pressed={lang === 'en'}
onClick={() => setLang('en')}
>
{strings.nav.langEn[lang]}
</button>
<button
type="button"
className={lang === 'vi' ? 'mobile-menu-segment-option active' : 'mobile-menu-segment-option'}
aria-pressed={lang === 'vi'}
onClick={() => setLang('vi')}
>
{strings.nav.langVi[lang]}
</button>
</div>
</div>
<div className="mobile-menu-segment">
<span className="mobile-menu-segment-label">{strings.nav.palette[lang]}</span>
<div className="mobile-menu-segment-options" role="group" aria-label={strings.nav.palette[lang]}>
{paletteIds.map((id) => (
<button
key={id}
type="button"
className={palette === id ? 'mobile-menu-swatch-option active' : 'mobile-menu-swatch-option'}
aria-pressed={palette === id}
aria-label={paletteMeta[id].label[lang]}
title={paletteMeta[id].hint[lang]}
onClick={() => setPalette(id)}
>
<span className="nav-palette-preview" data-preview={id} aria-hidden="true" />
</button>
))}
</div>
</div>
</div>
<div className="mobile-menu-group">
<span className="mobile-menu-heading">{strings.social.heading[lang]}</span>
<SocialLinks />
</div>
</div>
</motion.div>
)}
</AnimatePresence>
)
}