Skip to content

Add toggleable dark theme + reduced-motion guard (TraitMech site)#149

Merged
realmarcin merged 1 commit into
mainfrom
feat/dark-mode-toggle
Jul 5, 2026
Merged

Add toggleable dark theme + reduced-motion guard (TraitMech site)#149
realmarcin merged 1 commit into
mainfrom
feat/dark-mode-toggle

Conversation

@realmarcin

Copy link
Copy Markdown
Contributor

Adds a user-toggleable dark theme (OS `prefers-color-scheme` default plus a `data-theme` toggle persisted to `localStorage`) and a reduced-motion guard to every generated TraitMech page, without changing the light appearance.

Base is `fix/embedding-clickthrough-404` (not main) because that open PR also touches umap.html/graph.html. Do not merge until the base lands.

What changed

  • Vendored `pages/theme-toggle.js` — self-contained fixed ☾/☀ button; sets `data-theme` on `` before paint, themes from page tokens.
  • `style.css` (single source → `pages/assets/style.css`): dark token remap under both `@media (prefers-color-scheme: dark)` and `:root[data-theme="dark"]`, plus overrides for hard-coded light colors (site-header, hero gradient, `.stat`, buttons, pathograph container/legend, graph-warning, edge-evidence), d3 scatter SVG legend-text fill / hover halo, and a reduced-motion guard. Covers browse / category / trait / umap / graph pages.
  • `base.html`: includes `theme-toggle.js` at end of body → propagates to all base-derived pages on re-render.
  • `index.html` (standalone landing): inline dark block mapping `--pastel-b → --bg` and `--pastel-a → heroA` (page/footer ground goes dark, hero fades to dark), dimmed translucent `.stat`/footer surfaces, darkened `.btn` text, reduced-motion guard, and the include.
  • Re-rendered with `scripts/render_trait_pages.py` — 477/477 trait pages.

Palette (dark)

bg `#171417` · surface/card `#211d20` · ink `#efeaea` · muted `#ada4a6` · border `#332d30` · accent `#ef7377` · heroA `#33201f` · code-bg `#0d0b0d` · accent-soft `#2a1e1f`

Verification

  • `theme-toggle.js` present at web root; 490/490 HTML pages include it once.
  • `assets/style.css`: 2 `prefers-color-scheme: dark` blocks, 13 `:root[data-theme="dark"]` rules, 1 reduced-motion guard.
  • `index.html`: inline dark block (both selectors) + reduced-motion.
  • umap/graph SVG plot bg already uses `var(--card-bg)`; legend text fill + hover halo driven from tokens. HREF_BY_ID click-through fix left untouched.
  • Additive only — base `:root` token blocks unchanged, light look identical.

Additive-only; DO NOT MERGE (stacked on `fix/embedding-clickthrough-404`).

🤖 Generated with Claude Code

Adds a user-toggleable dark theme (OS prefers-color-scheme default, with a
data-theme toggle persisted to localStorage) and a reduced-motion guard to
every generated page, without changing the light appearance.

- Vendor theme-toggle.js at the web root (pages/theme-toggle.js), self-contained
  fixed ☾/☀ button that themes from the page tokens.
- style.css: append dark token remap (both @media prefers-color-scheme:dark and
  :root[data-theme="dark"]) + hard-coded-color overrides (site-header, hero,
  .stat, buttons, pathograph container/legend, graph-warning, edge-evidence) +
  d3 scatter SVG legend text fill / hover halo + reduced-motion guard. Covers
  browse/category/trait/umap/graph pages that link assets/style.css.
- base.html: include theme-toggle.js at end of body (propagates to all
  base-derived pages via re-render).
- index.html (standalone landing): inline dark block mapping --pastel-b→--bg and
  --pastel-a→heroA (page/footer ground goes dark, hero fades to dark), translucent
  .stat/footer surfaces dimmed, .btn text darkened, reduced-motion guard, include.
- Re-rendered with scripts/render_trait_pages.py (477/477 trait pages).

Additive only; the base :root token blocks are untouched so the light look is
identical. umap/graph SVG theming is handled entirely by the style.css dark
rules, leaving those templates' HREF_BY_ID click-through fix untouched.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 4, 2026 21:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@realmarcin

Copy link
Copy Markdown
Contributor Author

Reviewed the PR's own diff (base fix/embedding-clickthrough-404): base.html, index.html, style.css, vendored theme-toggle.js.

Clean — no issues, and correctly additive.

  • Light theme is untouched: base :root token blocks are unchanged; all new rules are gated behind @media (prefers-color-scheme: dark) :root:not([data-theme="light"]) and :root[data-theme="dark"], so the default light look is byte-for-byte the same.
  • theme-toggle.js applies data-theme before paint (no FOUC), persists to localStorage, and follows live OS changes only when no explicit choice is set.
  • Include path uses {{ root }}theme-toggle.js in base.html (inherited by umap/graph/trait/category, which all {% extends %} it) and in the standalone index.html — resolves correctly at every depth (../../theme-toggle.js on trait pages, theme-toggle.js at root).
  • Reduced-motion guard present in both style.css and index.html. HREF_BY_ID click-through untouched.

@realmarcin realmarcin changed the base branch from fix/embedding-clickthrough-404 to main July 5, 2026 07:26
@realmarcin realmarcin merged commit 7f1a42b into main Jul 5, 2026
1 check passed
@realmarcin realmarcin deleted the feat/dark-mode-toggle branch July 5, 2026 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants