mirror of
https://github.com/dong-nz/cv.git
synced 2026-11-22 16:10:40 +07:00
feat(theme): red/blue palette switch with a nav + mobile-sheet color menu
Second axis on <html>: data-palette (Portfolio type Palette = 'red' | 'blue', localStorage key portfolio-palette, default red so existing visitors see no change). Both attributes are written before paint by the index.html init script and re-written during render in useTheme. - src/types/index.ts, src/data/palettes.ts: Palette + paletteIds/paletteMeta (Record<Language, string>, indexed inline - no lookup helper) - src/hooks/useTheme.tsx: palette state, data-palette write during render, persistence, setPalette; no cyclePalette - src/components/layout/ThemePaletteMenu.tsx: disclosure semantics (aria-expanded/aria-controls, aria-current), variant nav|sheet, panel ids derived from variant, Escape closes and refocuses the trigger - src/components/layout/Navigation.tsx: nav instance in .nav-actions, sheet instance after the mobile link list, remounted closed via key - src/index.css: blue dark/light blocks (0,3,0 selectors) + preview tokens; red --accent-soft/--accent-glow re-derived from the accent in force - src/App.css: .nav-palette* block (token-only), nav hidden at 1024px, sheet options inline - specs: palette-switch spec v0.3.0 with the implementation record; corrected the false AA claim in spec-v3-theme-colors.md (3.90:1, not ~4.8), the composite values in spec-v3-theme-palette-gasatrya.md, the Footer consumer claim in spec-v3-theme-switch.md; AGENTS.md Theming section documents the palette axis Verified: tsc exit 0; vite build green (CSS 31.80 kB); oxlint unchanged at 11 errors / 9 warnings; hex gate over src/App.css 0 matches; inline type styles 0; contrast minima 4.96 / 4.63 / 4.81 / 4.64 with zero AA failures.
This commit is contained in:
1 parent
5b4b301ef1
commit
f2c920d6ad
14 files changed
+1033
-34
No files matched your search
+183
@@ -181,6 +181,189 @@
|
||||
.mobile-menu-btn {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.nav-palette-nav {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* ===== Theme palette menu ===== */
|
||||
.nav-palette {
|
||||
position: relative;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.nav-palette-trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--text-muted);
|
||||
cursor: pointer;
|
||||
padding: 8px;
|
||||
border-radius: var(--radius-md);
|
||||
font-size: 14px;
|
||||
transition: color var(--transition-fast), background var(--transition-fast);
|
||||
}
|
||||
|
||||
.nav-palette-trigger:hover,
|
||||
.nav-palette-trigger.open {
|
||||
color: var(--text-primary);
|
||||
background: var(--bg-elevated);
|
||||
}
|
||||
|
||||
.nav-palette-trigger:focus-visible {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.nav-palette-swatch {
|
||||
flex: none;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border-radius: 50%;
|
||||
background: var(--accent);
|
||||
box-shadow: inset 0 0 0 1px var(--border-strong);
|
||||
}
|
||||
|
||||
/* The group name is redundant in the bar (the trigger is labelled) but needed in the sheet. */
|
||||
.nav-palette-group {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-palette-trigger .chevron {
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.nav-palette-trigger.open .chevron {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.nav-palette-panel {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: calc(100% + 4px);
|
||||
right: 0;
|
||||
width: max-content;
|
||||
min-width: 220px;
|
||||
padding: 4px;
|
||||
background: var(--bg-elevated);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: 0 4px 12px var(--shadow);
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.nav-palette-panel.open {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.nav-palette-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
min-height: 44px;
|
||||
padding: 8px 12px;
|
||||
background: none;
|
||||
border: none;
|
||||
border-left: 2px solid transparent;
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--text-primary);
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
}
|
||||
|
||||
.nav-palette-option.active {
|
||||
border-left-color: var(--accent);
|
||||
}
|
||||
|
||||
.nav-palette-option.active::after {
|
||||
content: '✓';
|
||||
margin-left: 8px;
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.nav-palette-option:hover {
|
||||
background: var(--accent);
|
||||
color: var(--text-on-accent);
|
||||
}
|
||||
|
||||
.nav-palette-option:hover .nav-palette-hint,
|
||||
.nav-palette-option.active:hover::after {
|
||||
color: var(--text-on-accent);
|
||||
opacity: 0.75;
|
||||
}
|
||||
|
||||
.nav-palette-option:focus-visible {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
.nav-palette-preview {
|
||||
flex: none;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-radius: 50%;
|
||||
border: 2px solid;
|
||||
}
|
||||
|
||||
.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 {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.nav-palette-hint {
|
||||
margin-left: auto;
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
/* Sheet variant: the options expand inline inside the mobile menu, never as a
|
||||
second overlay. .mobile-menu is display:none unless .open, so this block is
|
||||
already unreachable above 1024px. */
|
||||
.nav-palette-sheet {
|
||||
display: block;
|
||||
margin-top: 16px;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.nav-palette-sheet .nav-palette-trigger {
|
||||
width: 100%;
|
||||
min-height: 44px;
|
||||
padding: 12px 0;
|
||||
font-size: var(--text-body);
|
||||
}
|
||||
|
||||
.nav-palette-sheet .nav-palette-group {
|
||||
display: inline;
|
||||
font-size: var(--text-meta);
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.nav-palette-sheet .nav-palette-panel {
|
||||
position: static;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.nav-palette-sheet .nav-palette-option {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
/* ===== Buttons ===== */
|
||||
|
||||
Reference in new issue
Block a user