Repository navigation
fix: select forced theme palettes by a data attribute - #60
Merged
Merged
Conversation
Follow-ups from the review of #58: - The theme matched forced palettes by substring tests on the inline style attribute, which depend on serialization and misfire on values like `color-scheme: light dark`. The element now sets html[data-color-scheme="light|dark"] and the theme matches it exactly. - Apply the theme before PDF.js initializes, so a forced palette is in place at first paint. - Keep --hover-filter and --button-disabled-opacity in step with the chosen theme instead of viewer.css's system-scheme switch. - Add the missing --sidebar-box-shadow to the neutral forced-dark block. - Document that LIGHT and DARK override the system color scheme. - Test: check data-color-scheme and --hover-filter per mode. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
alekswebnet
force-pushed
the
fix/theme-followups
branch
from
October 19, 2026 14:05
b32c78c to
a85dd4d
Compare
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-ups from the review of #58 (keep an explicit
LIGHTtheme light on a dark OS).[style*="color-scheme"][style*="dark"]and, since Respect explicit light theme #58, skipped the system dark rules with[style*="color-scheme: light"]. Both are substring tests on the wholestyleattribute, so they depend on how the browser serializes the inline style and misfire on values such ascolor-scheme: light darkor an unrelated--x: lightgray.applyViewerTheme()now also setshtml[data-color-scheme="light|dark"](removed forAUTOMATIC), and all 19 guards in the theme match that attribute exactly. The inlinecolor-schemeis still written, since PDF.js and the browser UI use it.applyViewerTheme()only ran afterinitializedPromise.LIGHTon a dark OS no longer gets PDF.js's dark hover and disabled styles.viewer.cssswitches--hover-filterand--button-disabled-opacityon the system scheme alone. The theme now sets both in its light base and its dark blocks, so they follow the chosen theme..sidebarblock gains the--sidebar-box-shadowits@mediatwin already had.:where()/&:rootpattern (no added specificity, so consumer overrides at:rootlevel still win) and cross-reference the second palette.LIGHTandDARKoverride the system color scheme, andAUTOMATIC(the default) follows it.Test
The theme test from #58 now also checks
data-color-schemeand--hover-filterfor every mode, drops a repeated loop iteration, and filters media rules byconditionTextinstead of a cross-realminstanceof. The dark-block count assertion is kept: it is the only assertion that touches the warm palette's@mediablock, since the neutral palette hides its colors.Full suite 21/21,
pnpm buildsucceeds, both attribute guards are present indist/paper-and-ink.css.Not included
Driving the theme from
color-schemewithlight-dark()would remove the duplicated dark palettes (a@mediablock plus a forced block per palette) and the guards altogether. That rewrites the theme file, so it belongs in its own PR.🤖 Generated with Claude Code