Skip to content

Add "Auto" theme selection which switches between default light and dark theme automatically #2576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 31, 2025

Conversation

tmandry
Copy link
Member

@tmandry tmandry commented Mar 8, 2025

The first commit is pretty uncontroversial. It takes the existing behavior for auto-detecting light/dark mode and improves it so that the page automatically changes when the preferred mode changes without a refresh. This is useful on systems which have a scheduled light/dark mode change, which is a built-in option on many OSes.

The problem is that this functionality can only be accessed if the user has never selected a theme before. To allow restoring the default behavior, we now add an "Auto" theme menu option in the second commit.

Since some people customize their index.hbs we make both changes resilient to that, falling back to the old behavior if the index changes are not applied. Thankfully this is pretty simple to do. (Longer term it'd be nice to remove the need to do this, e.g. for custom themes... that's #2594 or #2059.)

Fixes #1504

@rustbot rustbot added the S-waiting-on-review Status: waiting on a review label Mar 8, 2025
@tmandry tmandry force-pushed the default-auto-switch branch from 2cad73f to 78f5700 Compare March 9, 2025 04:41
@tmandry tmandry changed the title Add "Default" theme which switches between light and dark automatically Add "Auto" theme selection which switches between light and dark automatically Mar 9, 2025
@tmandry tmandry marked this pull request as ready for review March 9, 2025 04:43
@tmandry tmandry changed the title Add "Auto" theme selection which switches between light and dark automatically Add "Auto" theme selection which switches between default light and dark theme automatically Mar 9, 2025
tmandry and others added 3 commits March 31, 2025 11:34
This switches between light and dark based on the OS, and provides a way
to remove a saved preference.
This updates the ecmaVersion due to the ?? nullish coalescing operator.
@ehuss ehuss force-pushed the default-auto-switch branch from 78f5700 to 54d8d37 Compare March 31, 2025 18:50
Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ehuss ehuss enabled auto-merge March 31, 2025 18:51
@ehuss ehuss added this pull request to the merge queue Mar 31, 2025
Merged via the queue into rust-lang:master with commit 4946c78 Mar 31, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: waiting on a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature request] Add a theme option like "auto" to reset the theme to auto dark mode
3 participants