Skip to content

Honor theme="light" over prefers-color-scheme: dark#3000

Draft
reteps wants to merge 11 commits intoarnog:masterfrom
reteps:color-theme-fix
Draft

Honor theme="light" over prefers-color-scheme: dark#3000
reteps wants to merge 11 commits intoarnog:masterfrom
reteps:color-theme-fix

Conversation

@reteps
Copy link
Copy Markdown

@reteps reteps commented Apr 20, 2026

Summary

Fixes #2999: theme="light" on <math-field> had no effect when the OS reports prefers-color-scheme: dark

Alternatives considered:

Testing

Test suite added to verify fix.

🤖 Generated with Claude Code

reteps and others added 9 commits April 20, 2026 18:59
Scope the `@media (prefers-color-scheme: dark)` blocks under
`:host(:not([theme='light']))` so an author-set `theme="light"` on a
`<math-field>` takes precedence over the OS-level dark preference.
Previously, only `[theme='dark']` had an explicit CSS counterpart; a
`theme="light"` attribute was a no-op on dark systems because the dark
media query kept matching the bare `:host`/`.ML__container` selectors.

Fixes arnog#2999.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace the mirrored dark-theme blocks with a `color-scheme: light dark`
default on :host and `light-dark()` per variable. `:host([theme='light'])`
and `:host([theme='dark'])` pin the computed color-scheme so the attribute
wins over `prefers-color-scheme` without duplicate declarations or
double-negative selectors.

The sole remaining attribute+media-query override is `--_smart-fence-opacity`,
which is a <number> and therefore can't ride light-dark().

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
A review pass revealed several variables in the master dark-mode block
that used different user-override names than their light-mode counterparts,
or that had no user-override hook at all in dark mode. The first light-dark()
draft silently consolidated these, which would change observable behavior
for consumers setting the affected custom properties.

- --_text-highlight-background-color: preserve dual hooks
  (--highlight-text in light, --text-highlight-background-color in dark)
- --_latex-color: preserve dark's --primary-only hook
  (don't upgrade --latex-color to higher priority in dark)
- --_placeholder-color, --_composition-background-color,
  --_composition-text-color: preserve hardcoded dark values (no user hook)

Also restore a trailing-space diff artifact in ui/style.less.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…churn

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Restores specificity headroom for the forced-colors block in mathfield.less
and the :lang/:dir overrides in ui/style.less. The earlier selector-list
form (`.ML__container, :host([theme='light']) .ML__container`) raised the
base rule above those later overrides, so theme='light' + forced-colors or
theme='light' + :lang(ja)/:dir(rtl) stopped reaching their overrides.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Unifies the theme='light' escape hatch across all three theme stylesheets
so the codebase has one pattern, not two. Also drops issue-number
references from the accompanying comments.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@reteps reteps changed the title fix: honor theme="light" when prefers-color-scheme is dark Honor theme="light" over prefers-color-scheme: dark Apr 21, 2026
reteps and others added 2 commits April 21, 2026 01:16
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

theme="light" attribute does not override prefers-color-scheme: dark

1 participant