feat(theme): add system color mode to the theme toggle - #4675
Open
thetaPC wants to merge 1 commit into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Issue URL: internal
What is the current behavior?
The theme toggle only offers light and dark. Docusaurus 3.10 already ships a third system option, but two things hid it:
respectPrefersColorSchemewas never enabled, so the toggle stayed two-state_theme-toggle.scsspainted an opaque::beforeover the button and drew our own icons with::after, so upstream's icons (including the system one) could never showThat stylesheet also keyed the icons on
data-theme, the effective color, rather thandata-theme-choice, the chosen mode. Light mode rendered a moon.What is the new behavior?
Icon/LightModeandIcon/DarkModerather than CSS pseudo-elementsIcon/SystemColorModeis left untouched, so the system state uses upstream's half-filled circle_theme-toggle.scssare goneMost of that stylesheet was already dead:
[class^='toggleTrack']andinput[type='checkbox']target a toggle Docusaurus no longer renders. Upstream's own stylesheet supplies the sizing, centering, and state switching, so nothing needed replacing.Does this introduce a breaking change?
Other information
Two intentional visual changes worth a look in the preview:
::beforemask exposes upstream's hover background on the toggle.