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
+71
-6
@@ -10,9 +10,9 @@
|
||||
--accent-hover: #fca5a5;
|
||||
--accent-active: #f06060;
|
||||
--text-on-accent: #151914;
|
||||
--accent-soft: rgba(239, 68, 68, 0.12);
|
||||
--accent-soft: rgba(248, 113, 113, 0.12);
|
||||
--accent-tint: #2f1e1a;
|
||||
--accent-glow: rgba(239, 68, 68, 0.3);
|
||||
--accent-glow: rgba(248, 113, 113, 0.3);
|
||||
--border: #2a3028;
|
||||
--border-strong: #3a403a;
|
||||
--shadow: rgba(0, 0, 0, 0.45);
|
||||
@@ -68,9 +68,9 @@
|
||||
--accent-hover: #a8382f;
|
||||
--accent-active: #9b3229;
|
||||
--text-on-accent: #ffffff;
|
||||
--accent-soft: rgba(239, 68, 68, 0.1);
|
||||
--accent-soft: rgba(176, 65, 56, 0.1);
|
||||
--accent-tint: #f5e3e1;
|
||||
--accent-glow: rgba(239, 68, 68, 0.22);
|
||||
--accent-glow: rgba(176, 65, 56, 0.22);
|
||||
--border: #e3e1dc;
|
||||
--border-strong: #d9d6d0;
|
||||
--shadow: rgba(21, 25, 20, 0.1);
|
||||
@@ -84,6 +84,71 @@
|
||||
color-scheme: light;
|
||||
}
|
||||
|
||||
/* Blue palette. Both selectors carry two attributes (0,3,0), so they beat
|
||||
:root (0,1,0) and :root[data-theme='light'] (0,2,0) regardless of block order. */
|
||||
:root[data-theme='dark'][data-palette='blue'] {
|
||||
--bg-primary: #0f1117;
|
||||
--bg-surface: #161922;
|
||||
--bg-elevated: #1c2030;
|
||||
--text-primary: #e8eaed;
|
||||
--text-secondary: #9aa0a6;
|
||||
--text-muted: #828d9e;
|
||||
--accent: #60a5fa;
|
||||
--accent-hover: #93c5fd;
|
||||
--accent-active: #3b82f6;
|
||||
--text-on-accent: #0f1117;
|
||||
--accent-soft: rgba(96, 165, 250, 0.12);
|
||||
--accent-tint: #182338;
|
||||
--accent-glow: rgba(96, 165, 250, 0.3);
|
||||
--border: #2a3040;
|
||||
--border-strong: #39415a;
|
||||
--shadow: rgba(0, 0, 0, 0.45);
|
||||
--inset-highlight: rgba(255, 255, 255, 0.05);
|
||||
--code-bg: #1a1e2e;
|
||||
--success: #34d399;
|
||||
--success-glow: rgba(52, 211, 153, 0.35);
|
||||
--error: #f87171;
|
||||
--warning: #fbbf24;
|
||||
--grid-color: rgba(232, 234, 237, 0.06);
|
||||
color-scheme: dark;
|
||||
}
|
||||
|
||||
:root[data-theme='light'][data-palette='blue'] {
|
||||
--bg-primary: #f4f6f9;
|
||||
--bg-surface: #fbfcfe;
|
||||
--bg-elevated: #ffffff;
|
||||
--text-primary: #111827;
|
||||
--text-secondary: #4b5563;
|
||||
--text-muted: #5c6b82;
|
||||
--accent: #2563eb;
|
||||
--accent-hover: #1d4ed8;
|
||||
--accent-active: #1e40af;
|
||||
--text-on-accent: #ffffff;
|
||||
--accent-soft: rgba(37, 99, 235, 0.1);
|
||||
--accent-tint: #eef3fc;
|
||||
--accent-glow: rgba(37, 99, 235, 0.22);
|
||||
--border: #dfe3ea;
|
||||
--border-strong: #d3d8e1;
|
||||
--shadow: rgba(17, 24, 39, 0.1);
|
||||
--inset-highlight: rgba(255, 255, 255, 0.9);
|
||||
--code-bg: #eceff5;
|
||||
--success: #15803d;
|
||||
--success-glow: rgba(21, 128, 61, 0.35);
|
||||
--error: #991b1b;
|
||||
--warning: #b45309;
|
||||
--grid-color: rgba(17, 24, 39, 0.07);
|
||||
color-scheme: light;
|
||||
}
|
||||
|
||||
/* Picker previews: fixed identity colors so a row previews its own palette,
|
||||
not the one currently active. Never referenced outside .nav-palette-preview. */
|
||||
:root {
|
||||
--preview-red-accent: #b04138;
|
||||
--preview-red-bg: #f6f5f2;
|
||||
--preview-blue-accent: #2563eb;
|
||||
--preview-blue-bg: #f4f6f9;
|
||||
}
|
||||
|
||||
/* Pre-hydration / no-JS: honour an OS light preference */
|
||||
@media (prefers-color-scheme: light) {
|
||||
:root:not([data-theme='dark']) {
|
||||
@@ -97,9 +162,9 @@
|
||||
--accent-hover: #a8382f;
|
||||
--accent-active: #9b3229;
|
||||
--text-on-accent: #ffffff;
|
||||
--accent-soft: rgba(239, 68, 68, 0.1);
|
||||
--accent-soft: rgba(176, 65, 56, 0.1);
|
||||
--accent-tint: #f5e3e1;
|
||||
--accent-glow: rgba(239, 68, 68, 0.22);
|
||||
--accent-glow: rgba(176, 65, 56, 0.22);
|
||||
--border: #e3e1dc;
|
||||
--border-strong: #d9d6d0;
|
||||
--shadow: rgba(21, 25, 20, 0.1);
|
||||
|
||||
Reference in new issue
Block a user