Skip to content

Fix dark mode: raise specificity of variable-defining dark blocks#190

Merged
oyvindberg merged 2 commits intomainfrom
fix-dark-mode-cascade
May 3, 2026
Merged

Fix dark mode: raise specificity of variable-defining dark blocks#190
oyvindberg merged 2 commits intomainfrom
fix-dark-mode-cascade

Conversation

@oyvindberg
Copy link
Copy Markdown
Collaborator

Summary

  • The CSS minimizer was reordering :root and [data-theme="dark"] blocks in the production bundle so that :root ended up after [data-theme="dark"]. Both have specificity (0,1,0), so source order wins — the light --typr-paper clobbered the dark one even when data-theme="dark" was set.
  • Result on the deployed site: docs page didn't flip to dark at all, and the landing navbar stayed light.
  • Bumping the three variable-defining dark blocks in custom.css to html[data-theme="dark"] (specificity 0,1,1) makes them beat :root regardless of bundler reordering.
  • Also commits related theme-config tweaks that were sitting uncommitted: explicit colorMode config and announcement bar repainted in editorial ink/cream instead of legacy purple.

Test plan

  • npm run build succeeds; new bundle hash confirmed
  • Local prod build (npx serve build) toggles dark mode on / and /typr/ correctly
  • Verify on deployed site after merge + auto-deploy

oyvindberg and others added 2 commits May 3, 2026 13:54
The CSS minimizer was reordering rules so that `:root` ended up *after*
`[data-theme="dark"]` in the bundled output. With matching specificity
(0,1,0), source order wins — so the light `--typr-paper` value clobbered
the dark one even when `data-theme="dark"` was set on `<html>`. Result:
docs page didn't flip to dark mode at all, and the navbar stayed light.

Fix: change the three variable-defining dark blocks to
`html[data-theme="dark"]` (0,1,1). That beats `:root` regardless of how
the bundler reorders.

Also commit related theme-config tweaks that were sitting uncommitted:
explicit colorMode config and announcement bar repainted in editorial
ink/cream instead of the legacy purple.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@oyvindberg oyvindberg merged commit 3e13771 into main May 3, 2026
12 checks passed
@oyvindberg oyvindberg deleted the fix-dark-mode-cascade branch May 3, 2026 12:05
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.

1 participant