Resolve a theme token under dark: to its dark value - #350
Open
sadiqk2 wants to merge 1 commit into
Open
Conversation
`dark:bg-theme-surface` rendered the LIGHT colour in dark mode.
A theme token resolves its own dark companion, so the value returned for
`bg-theme-surface` already looks like `['bg' => light, 'dark' => ['bg' => dark]]`.
The `dark:` prefix then wrapped that whole thing in another `dark` layer:
dark:bg-theme-surface
was ['dark' => ['bg' => '#FFF', 'dark' => ['bg' => '#000']]]
now ['dark' => ['bg' => '#000']]
parse() merges one `dark` level, so the buried companion was never lifted and the
light hex sat in the dark slot — while the nested key travelled to the renderers
as an unknown prop.
Asking for a theme token under `dark:` can only mean that token's dark-mode form,
so the companion is promoted rather than nested. A token with no dark companion
keeps its single colour, which is the only sensible reading of the request.
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.
The bug
dark:bg-theme-surfacerenders the light colour in dark mode.A theme token resolves its own dark companion, so
bg-theme-surfacealready returns['bg' => light, 'dark' => ['bg' => dark]]. Thedark:prefix then wrapped that entire result in a seconddarklayer:parse()merges onedarklevel, so the buried companion is never lifted: the light hex ends up in the dark slot, and the nesteddarkkey travels to the renderers as a prop they know nothing about.The fix
Asking for a theme token under
dark:can only mean that token's dark-mode form, so the companion is promoted instead of nested. A token whose resolver answers light-only keeps its single colour — the only sensible reading of the request, and the same thing the unprefixed form does.The unprefixed path is untouched.
Verification
tests/Unit/Edge/ThemeClassTokensTest.php: the dark-companion case, the light-only case, and the unprefixed shape staying exactly as it was.mainand passes with this change.vendor/bin/pest tests/Unit/Edge/: 276 passed. Full-suite failures matchmain's baseline (Android splash-screen and release-build tests, unrelated).vendor/bin/pint --testclean on both touched files.