mirror of
https://github.com/dong-nz/cv.git
synced 2026-11-23 00:20: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
@@ -289,12 +289,14 @@ export function ThemeProvider({ children }: { children: React.ReactNode }) {
|
||||
|
||||
### Step 5: Verify No Other Consumers Need Changes
|
||||
|
||||
Check all files that import `useTheme` or reference `Theme` type. Current consumers:
|
||||
- `src/App.tsx` — uses `useTheme().theme`, `useTheme().resolvedTheme`, `useTheme().cycleTheme`, `useTheme().setTheme`
|
||||
- `src/components/layout/Navigation.tsx` — uses `useTheme().theme`, `useTheme().cycleTheme`
|
||||
- `src/components/layout/Footer.tsx` — uses `useTheme().theme`, `useTheme().cycleTheme`
|
||||
Check all files that import `useTheme` or reference the `Theme` type. Consumers, verified with `grep -rn "useTheme" src` on 2026-10-17:
|
||||
- `src/App.tsx:3` — imports `ThemeProvider` only; calls no hook method
|
||||
- `src/components/layout/Navigation.tsx:10` — `const { cycleTheme, resolvedTheme } = useTheme()`
|
||||
- `src/components/layout/ThemePaletteMenu.tsx:13` — `const { palette, setPalette } = useTheme()`, added later by `spec-v3-theme-palette-switch.md`
|
||||
|
||||
All consumers only read `theme` and `resolvedTheme` values (`'dark' | 'light'`), no pattern matching on `'system'`. No changes needed.
|
||||
`src/components/layout/Footer.tsx` does **not** import `useTheme` and has no theme control — earlier revisions of this section claimed it did; corrected 2026-10-17.
|
||||
|
||||
All consumers read the resolved values directly and nothing pattern-matches on `'system'`, so no consumer needed changes when `system` was removed.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in new issue
Block a user