Repository navigation
fix(theme): nearest theme wins for a seeded StyleScope three levels deep (3.1) - #589
Merged
Merged
Conversation
…ls deep (#558) A StyleScope with theme="dark" and a seed inside a light section of a dark page matched the light scheme block through its ancestors at the same specificity, and the light block comes later. Three-level selectors, as showIn already has, let the nearest theme win. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016gNJtx8NozwfTMFAJUwVuh
27 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.
Requested by Lorant · project thread
Fixes #558.
The bug.
html[data-theme="dark"]› adata-theme="light"wrapper › aStyleScopewiththeme="dark"and a seed gives one element withdata-theme="dark"anddata-accent="custom". That element matched the light scheme block ([dark] [light] :is([data-brand],[data-accent],[data-neutral])) through its ancestors, at the same specificity as the dark block's self-match, and the light block comes later, so it read light text tokens on a dark surface.The fix.
foundations/scss/tokens/theme.scss: each scheme block gets the three-level selectors ([light] [dark] [light]…for light,[dark] [light] [dark]…for dark), on the element itself and on a scheme element inside it. That is the patternshowInalready uses, so the nearest theme wins one level deeper. Two-level cases weigh the same as before.Test.
foundations/test/nested-theme-scope.test.tscompiles the tokens and picks the winning--neutral-on-background-strongthe way the cascade does (specificity, then order) for both three-level setups and the two-level ones. It fails onpreviewwithout the change and passes with it.Checks: foundations 72/72, core build and suite pass locally except the catalog-size cap, which #587 moves.
Tavilio works around this in Tavilio#266; that workaround can go once 3.1 is out.
Generated by Claude Code