-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hey t3-oss/translators! This PR contains changes to your language. Please review the changes ❤️. THEMETEST.ASTRO: |
Running Lighthouse audit... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Change
Os Default
toSystem
- The system doesn't actually use the systems theme, you'll need to setup a media listener for that.
There was a problem hiding this 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)
CleanShot.2023-02-20.at.22.44.36.mp4 |
|
||
const themesOptions = [ | ||
{ | ||
name: "os default", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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:
-
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.
-
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
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(); | ||
} | ||
}); | ||
}, []); |
There was a problem hiding this comment.
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
Closing as stale so that others don't feel blocked to pick it up |
Closes #
✅ Checklist
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
💯