Align theme toggle with system preference and react to prefers-color-scheme changes#186
Align theme toggle with system preference and react to prefers-color-scheme changes#186Copilot wants to merge 6 commits into
prefers-color-scheme changes#186Conversation
prefers-color-scheme changesgetPreferredTheme to getSystemTheme
getPreferredTheme to getSystemThemeprefers-color-scheme changes
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0ed123f91a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return localStorage.getItem('theme'); | ||
| } | ||
| function getTheme() { | ||
| return getStoredTheme() || getSystemTheme(); |
There was a problem hiding this comment.
stored theme (if different from system) wins
It always wins?
There was a problem hiding this comment.
yes, please note we clear it when user changes the theme to the same as system
nothing changes for users that use always light theme or always dark
things change for those who use auto aka follow-the-sun
if you set to light during night, you'll have light in stored, therefore always light
but if you set to dark during night, the theme will start to be auto/follow-the-sun as your OS does (technically we will clear the stored theme, and then || getSystemTheme() will be used)
Theme selection now treats browser/OS preference as the default mode instead of always persisting manual toggles. When a user-selected theme matches
prefers-color-scheme, the override is removed so future system changes are reflected automatically.Behavior model
stored theme(if different from system) winsToggle semantics
localStorage.themeis removed (return to system-following mode).Live system theme updates
matchMedia('(prefers-color-scheme: dark)')change listener.Reference: #174 (comment)
📊 Dashboard preview 📊: https://python-docs-translations.github.io/dashboard/186/merge/