Skip to content
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

feat: Color scheme dropdown #1230

Closed
wants to merge 6 commits into from
Closed

feat: Color scheme dropdown #1230

wants to merge 6 commits into from

Conversation

AugustinSorel
Copy link

Closes #

✅ Checklist

  • I have followed every step in the contributing guide (updated 2022-10-06).
  • The PR title follows the convention we established conventional-commit
  • I performed a functional test on my final commit

Changelog

fixing this issue: #847

This pr changed the old theme toggle to a drop down with 3 options (os default, light and dark)

Screenshots

Screenshot from 2023-02-20 21-36-07

💯

@changeset-bot
Copy link

changeset-bot bot commented Feb 20, 2023

⚠️ No Changeset found

Latest commit: 4e4761d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Feb 20, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
create-t3-app ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 22, 2023 at 5:36PM (UTC)

@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2023

Hey t3-oss/translators!

This PR contains changes to your language. Please review the changes ❤️.

THEMETEST.ASTRO:

@github-actions github-actions bot added the 📚 documentation Improvements or additions to documentation label Feb 20, 2023
@github-actions
Copy link
Contributor

Running Lighthouse audit...

Copy link
Member

@juliusmarminge juliusmarminge left a comment

Choose a reason for hiding this comment

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

  1. Change Os Default to System
  2. The system doesn't actually use the systems theme, you'll need to setup a media listener for that.

Copy link
Member

@juliusmarminge juliusmarminge left a comment

Choose a reason for hiding this comment

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

(meant to press this xd)

@juliusmarminge
Copy link
Member

CleanShot.2023-02-20.at.22.44.36.mp4


const themesOptions = [
{
name: "os default",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
name: "os default",
name: "System",

To me, System sounds more in line with what others do, e.g.:

Screenshot 2023-02-21 at 05 12 04

Copy link
Member

@juliusmarminge juliusmarminge left a comment

Choose a reason for hiding this comment

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

Still some unexpected behaviors:

  1. The icon shouldn't change when i change my system preferences, it should be on the system icon as long as i haven't changed it.

  2. If i have changed it, the theme shouldn't change even if i change the system preferences.

demo showcasing these faults:

CleanShot.2023-02-23.at.18.37.45.mp4

Comment on lines +72 to +87
useLayoutEffect(() => {
const theme = localStorage.getItem("theme") as ThemesNames;
setSelectedTheme(theme || "system");

window
.matchMedia("(prefers-color-scheme: dark)")
.addEventListener("change", (e) => {
if (e.matches) {
findThemeByName("dark")?.clickHandler();
setSelectedTheme("dark");
} else {
setSelectedTheme("light");
findThemeByName("light")?.clickHandler();
}
});
}, []);
Copy link
Member

Choose a reason for hiding this comment

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

this event listener should only run when the system option is selected, we should also have a cleanup function

@juliusmarminge
Copy link
Member

Closing as stale so that others don't feel blocked to pick it up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants