v6: Mirror the active theme to data-theme on <html>#4293
Merged
Conversation
`tokens.css` gates its v6 OKLCH cascade on `[data-theme='light']` / `[data-theme='dark']` selectors, but the only place theme state was applied was a `graphiql-light` / `graphiql-dark` class on `<body>`. With no `data-theme` attribute anywhere, the cascade always fell through to the `@media (prefers-color-scheme)` fallback, so v6 components followed the OS preference instead of the GraphiQL toggle. Mirror the active theme to `document.documentElement` as a `data-theme` attribute so the selectors light up. The body classes remain for any consumer CSS that depends on them.
🦋 Changeset detectedLatest commit: 74c8018 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
The latest changes of this PR are not available as canary, since there are no linked |
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
tokens.cssscopes the v6 OKLCH cascade to[data-theme='light']/[data-theme='dark']selectors, butsetThemewas only writinggraphiql-light/graphiql-darkclasses onto<body>. With nodata-themeattribute set, v6 components fell through to the OSprefers-color-schememedia-query fallback regardless of the in-app toggle. This PR mirrors the active theme ontodocument.documentElementasdata-themeso the selectors actually match; the existing body classes are preserved for any consumer CSS that depends on them.Test plan
<html>has nodata-themeattribute and v6 chrome follows your OS preference.<html>gainsdata-theme="light"and v6 components (TopBar,StatusBar,ActivityRail, etc., once those PRs land) all switch to light tokens.<html>gainsdata-theme="dark"and v6 components switch to dark tokens.data-themeis removed and the v6 components revert to following the OS preference.Refs: #4219