Skip to content

Fix theme picker text when unspecified theme#42671

Merged
avatus merged 3 commits intomasterfrom
avatus/fix_theme
Jun 18, 2024
Merged

Fix theme picker text when unspecified theme#42671
avatus merged 3 commits intomasterfrom
avatus/fix_theme

Conversation

@avatus
Copy link
Copy Markdown
Contributor

@avatus avatus commented Jun 9, 2024

Fixes #42395
Currently, we work under the assumption that the theme is a binary decision between light/dark. The default user theme is now UNSPECIFIED which will default to the system theme. This PR adds a few utility options to get the current/next theme with this unspecified in mind. We can remove them once we add the user settings page to make "use system theme" a valid option to select.

To test, you can create a new user in an incognito window. The theme should be whatever your system theme is. Also, the theme selector should know which theme is being used a properly show text for what the next theme should be.

@avatus avatus added backport-required no-changelog Indicates that a PR does not require a changelog entry backport/branch/v16 labels Jun 9, 2024
@avatus avatus requested review from kimlisa, rudream and ryanclark and removed request for ibeckermayer and ravicious June 9, 2024 16:45
Copy link
Copy Markdown
Member

@ryanclark ryanclark left a comment

Choose a reason for hiding this comment

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

Can you add some tests for your new helper methods?

return themePreference === Theme.LIGHT ? lightTheme : darkTheme;
}

// because unspecific can exist but only used as a fallback and not an option,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// because unspecific can exist but only used as a fallback and not an option,
// because unspecified can exist but only used as a fallback and not an option,

if (currentTheme === Theme.UNSPECIFIED) {
return getPrefersDark() ? Theme.DARK : Theme.LIGHT;
}
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are you intentionally not returning anything if currentTheme !== Theme.UNSPECIFIED?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No. Thanks!

Comment on lines +55 to +58
if (currentTheme === Theme.UNSPECIFIED) {
return getPrefersDark() ? Theme.LIGHT : Theme.DARK;
}
return currentTheme === Theme.LIGHT ? Theme.DARK : Theme.LIGHT;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can this be

Suggested change
if (currentTheme === Theme.UNSPECIFIED) {
return getPrefersDark() ? Theme.LIGHT : Theme.DARK;
}
return currentTheme === Theme.LIGHT ? Theme.DARK : Theme.LIGHT;
return getCurrentTheme(currentTheme) === Theme.LIGHT ? Theme.DARK : Theme.LIGHT;

@avatus avatus requested a review from ryanclark June 11, 2024 16:26
@avatus
Copy link
Copy Markdown
Contributor Author

avatus commented Jun 14, 2024

friendly ping @ryanclark @kimlisa @rudream

// and remove the checks for unspecified
export function getCurrentTheme(currentTheme: Theme): Theme {
if (currentTheme === Theme.UNSPECIFIED) {
return getPrefersDark() ? Theme.DARK : Theme.LIGHT;
Copy link
Copy Markdown
Contributor

@kimlisa kimlisa Jun 17, 2024

Choose a reason for hiding this comment

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

how do i test this? i created a new user, and it defaulted to light theme (using brave)

nvm it worked, not sure what happened before lol.

when i do this flow:

new user -> login -> switch theme

the first click did not work, i had to click a second time to switch the theme

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wasn't able to reproduce this first click not working in incognito or normal mode

Copy link
Copy Markdown
Contributor

@kimlisa kimlisa left a comment

Choose a reason for hiding this comment

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

just a minor comment, otherwise lgtm

@avatus
Copy link
Copy Markdown
Contributor Author

avatus commented Jun 18, 2024

friendly ping @ryanclark

Copy link
Copy Markdown
Member

@ryanclark ryanclark left a comment

Choose a reason for hiding this comment

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

Sorry, was waiting for the reply to Lisa's comment 🙂

@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from rudream June 18, 2024 18:44
@avatus avatus added this pull request to the merge queue Jun 18, 2024
Merged via the queue into master with commit 46ba197 Jun 18, 2024
@avatus avatus deleted the avatus/fix_theme branch June 18, 2024 19:35
@public-teleport-github-review-bot
Copy link
Copy Markdown

@avatus See the table below for backport results.

Branch Result
branch/v16 Create PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-required no-changelog Indicates that a PR does not require a changelog entry size/sm ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Theme picker text is incorrect by default

4 participants