feat(nav): theme-aware palette previews, left-side hamburger, home icon brand

Preview chips now mirror the bar swatch: --preview-*-accent is declared per theme (dark #f87171/#60a5fa, light #b04138/#2563eb, repeated in the prefers-color-scheme bridge) and the two [data-palette=blue] blocks declare nothing, since a chip names its own palette through data-preview. --preview-*-bg is deleted; chips take the shared --border-strong hairline. Dark-mode dots move from 2.53/3.13 to 5.24/6.36 against their panel.

The hamburger leads the bar in a new .nav-brand group (trigger then brand), and the wordmark becomes a 24px stroke home icon in a 44px target with a :focus-visible ring, still a <Link to="/">. .logo-bracket/.logo-text are removed and the <=420px guard drops its brand-gap override: the row measures 252px inside 288px.

Docs: new specs/v3/spec-v3-nav-swatch-and-hamburger.md plus supersession notes in spec-v3-mobile-navigation, spec-v3-theme-palette-switch and spec-v3-ui-enhancements; AGENTS.md, spec-ui-layout and spec-ui-navigation updated. Gates: tsc+vite build exit 0, oxlint 15 findings (11 rules-of-hooks, unchanged baseline), zero hex in App.css, 12/12 SSR bar-order assertions.
This commit is contained in:
dong.nguyen committed 2026-10-17 22:33:42 +07:00
1 parent 4387f889f5
commit c95f7b09d1
10 files changed
+513 -74

No files matched your search

+33 -19
View File
@@ -22,27 +22,36 @@
justify-content: space-between;
}
/* Icon brand: a 24px stroke house in a 44px target, matching the hamburger's icon language.
It is a <Link to="/"> — same behaviour the {CV} wordmark had. */
.nav-logo {
font-size: 20px;
font-weight: 700;
display: flex;
align-items: center;
justify-content: center;
width: 44px;
height: 44px;
border-radius: var(--radius-md);
color: var(--text-primary);
text-decoration: none;
}
/* The hamburger and the brand travel together on the left of the bar so the sheet's trigger
sits where a left-handed thumb reaches it. Above 1024px the button is display:none, so this
group renders as the home icon alone. */
.nav-brand {
display: flex;
align-items: center;
gap: 12px;
}
.nav-logo:hover {
color: var(--accent);
}
.logo-bracket {
color: var(--accent);
font-family: var(--mono);
font-size: 1.2rem;
font-weight: 700;
}
.logo-text {
color: var(--text-primary);
font-weight: 700;
font-size: 1.1rem;
/* An icon-only control needs a ring: colour alone is not a focus indicator. */
.nav-logo:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
.nav-menu {
@@ -307,8 +316,9 @@
}
}
/* Four controls share the bar at ≤1024px. At 320px: {CV} (~70px) + 44×4 controls + 12×3 gaps
= 262px inside 288px of content, so the row keeps 26px of slack. */
/* Four controls share the bar at ≤1024px. At 320px: hamburger 40 + 12 + home icon 44 + 44×3
controls + 12×2 gaps = 252px inside 288px of content, so the row keeps 36px of slack — the
wordmark's 8px brand-gap tightening is no longer needed. */
@media (max-width: 420px) {
.nav-container {
padding: 0 16px;
@@ -335,8 +345,11 @@
icon, and its accessible name lives in `aria-label`. The class stays as the hook that ties
the trigger to the `#palette-menu` panel it expands. */
/* The palette icon: left half is the active palette's accent, right half the constant empty
half (--swatch-empty). The hairline keeps the white half visible on a light surface. */
/* The palette icon: left half is the live --accent of the active palette, right half the
constant --swatch-empty; the hairline keeps the white half visible on a light surface. The
submenu dots read --preview-*-accent, which mirror the same per-theme accent values, so a
dot and this swatch half are the same colour in the same theme.
Spec: docs/design/specs/v3/spec-v3-nav-swatch-and-hamburger.md */
.nav-palette-swatch {
flex: none;
width: 20px;
@@ -408,22 +421,23 @@
outline-offset: -2px;
}
/* One ring style for every colour chip: the same 1px --border-strong hairline the swatch
above uses. --preview-red-bg and --preview-blue-bg are gone — their light-mode values drew
a near-white halo (13.30–16.21) around the dot in dark mode. */
.nav-palette-preview {
flex: none;
width: 18px;
height: 18px;
border-radius: 50%;
border: 2px solid;
border: 1px solid var(--border-strong);
}
.nav-palette-preview[data-preview='red'] {
background: var(--preview-red-accent);
border-color: var(--preview-red-bg);
}
.nav-palette-preview[data-preview='blue'] {
background: var(--preview-blue-accent);
border-color: var(--preview-blue-bg);
}
.nav-palette-name {
+49 -40
View File
@@ -56,11 +56,55 @@ export function Navigation() {
<>
<nav className="nav" role="navigation" aria-label="Main navigation">
<div className="nav-container">
<Link to="/" className="nav-logo">
<span className="logo-bracket">&#123;</span>
<span className="logo-text">CV</span>
<span className="logo-bracket">&#125;</span>
</Link>
<div className="nav-brand">
{/* Trigger first, brand next: the hamburger is the sheet's own control and sits at
the bar's left edge, where a left-handed thumb reaches it. The three appearance
controls stay in .nav-actions at the right end. */}
<button
ref={triggerRef}
className="mobile-menu-btn"
onClick={() => setMobileOpen((prev) => !prev)}
aria-label={mobileOpen ? strings.nav.closeMenu[lang] : strings.nav.openMenu[lang]}
aria-expanded={mobileOpen}
aria-controls="mobile-menu"
>
<AnimatePresence mode="wait" initial={false}>
{mobileOpen ? (
<motion.svg
key="close"
width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"
initial={{ opacity: 0, rotate: -90 }}
animate={{ opacity: 1, rotate: 0 }}
exit={{ opacity: 0, rotate: 90 }}
transition={{ duration: 0.18 }}
>
<path d="M18 6L6 18M6 6l12 12" />
</motion.svg>
) : (
<motion.svg
key="menu"
width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"
initial={{ opacity: 0, rotate: 90 }}
animate={{ opacity: 1, rotate: 0 }}
exit={{ opacity: 0, rotate: -90 }}
transition={{ duration: 0.18 }}
>
<path d="M3 12h18M3 6h18M3 18h18" />
</motion.svg>
)}
</AnimatePresence>
</button>
{/* Brand is a home icon: the same 24px stroke language as the hamburger, and the same
<Link to="/"> target the {CV} wordmark always had. The accessible name is the
translated Home label; the icon itself is decorative. The current-page marker stays
on the nav link and the sheet's Home row. */}
<Link to="/" className="nav-logo" aria-label={strings.nav.home[lang]}>
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" />
<polyline points="9 22 9 12 15 12 15 22" />
</svg>
</Link>
</div>
<ul className="nav-menu">
{navPaths.map((path) => {
@@ -109,41 +153,6 @@ export function Navigation() {
</button>
<ThemePaletteMenu />
<button
ref={triggerRef}
className="mobile-menu-btn"
onClick={() => setMobileOpen((prev) => !prev)}
aria-label={mobileOpen ? strings.nav.closeMenu[lang] : strings.nav.openMenu[lang]}
aria-expanded={mobileOpen}
aria-controls="mobile-menu"
>
<AnimatePresence mode="wait" initial={false}>
{mobileOpen ? (
<motion.svg
key="close"
width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"
initial={{ opacity: 0, rotate: -90 }}
animate={{ opacity: 1, rotate: 0 }}
exit={{ opacity: 0, rotate: 90 }}
transition={{ duration: 0.18 }}
>
<path d="M18 6L6 18M6 6l12 12" />
</motion.svg>
) : (
<motion.svg
key="menu"
width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"
initial={{ opacity: 0, rotate: 90 }}
animate={{ opacity: 1, rotate: 0 }}
exit={{ opacity: 0, rotate: -90 }}
transition={{ duration: 0.18 }}
>
<path d="M3 12h18M3 6h18M3 18h18" />
</motion.svg>
)}
</AnimatePresence>
</button>
</div>
</div>
</nav>
+11 -11
View File
@@ -21,6 +21,13 @@
--accent-soft: rgba(248, 113, 113, 0.12);
--accent-tint: #2f1e1a;
--accent-glow: rgba(248, 113, 113, 0.3);
/* Picker previews: each row previews its own palette, never the active one — the token is
keyed by palette name, not by --accent. The values mirror this block's --accent so a
submenu dot and the bar swatch's accent half are the same colour in the same theme.
The two [data-palette='blue'] blocks declare nothing for the same reason. */
--preview-red-accent: #f87171;
--preview-blue-accent: #60a5fa;
--swatch-empty: #ffffff;
--border: #2a3028;
--border-strong: #3a403a;
--shadow: rgba(0, 0, 0, 0.45);
@@ -85,6 +92,8 @@
--accent-soft: rgba(176, 65, 56, 0.1);
--accent-tint: #f5e3e1;
--accent-glow: rgba(176, 65, 56, 0.22);
--preview-red-accent: #b04138;
--preview-blue-accent: #2563eb;
--border: #e3e1dc;
--border-strong: #d9d6d0;
--shadow: rgba(21, 25, 20, 0.1);
@@ -165,17 +174,6 @@
color-scheme: light;
}
/* Fixed identity colours: a picker row previews its own palette rather than the active one,
and the bar's palette icon keeps a constant "empty" half in both themes. Referenced only by
`.nav-palette-preview` (previews) and `.nav-palette-swatch` (the empty half). */
:root {
--preview-red-accent: #b04138;
--preview-red-bg: #f6f5f2;
--preview-blue-accent: #2563eb;
--preview-blue-bg: #f4f6f9;
--swatch-empty: #ffffff;
}
/* Pre-hydration / no-JS: honour an OS light preference */
@media (prefers-color-scheme: light) {
:root:not([data-theme='dark']) {
@@ -197,6 +195,8 @@
--accent-soft: rgba(176, 65, 56, 0.1);
--accent-tint: #f5e3e1;
--accent-glow: rgba(176, 65, 56, 0.22);
--preview-red-accent: #b04138;
--preview-blue-accent: #2563eb;
--border: #e3e1dc;
--border-strong: #d9d6d0;
--shadow: rgba(21, 25, 20, 0.1);