Major changes: Add System Theme Mode, Color Preferences, Accessibility and more!#48
Major changes: Add System Theme Mode, Color Preferences, Accessibility and more!#48mobeigi wants to merge 39 commits intoJoseRFelix:masterfrom
Conversation
…er dependency versions. Update failing build, tests.
…alf to mention moon
|
@JoseRFelix Hey mate, any chance of this getting merged? I know its a lot of changes. Thanks! |
|
I've been using this on my personal website (mobeigi.com) for some time now and it works very well. I'm not sure if the original author of this repo (@JoseRFelix) has any plans on merging this PR or maintaining it. I may otherwise fork it with these changes so I can pull in the library myself from a centralised package manager (because to date I've been using it as a local packed file which is not ideal). |
|
@JoseRFelix Can we please get this merged? |
|
@mobeigi Perhaps it is time to fork this? Your changes look compelling and this package is tethered to React 18, it could use some updating |
|
Thank you very much for this PR, @mobeigi! Apologies for the delay in reviewing. I got caught up with other responsibilities. I've started working on this package again and have some version and performance updates coming soon. This PR includes some great stuff, but it's doing quite a lot all at once. Would you be able to break it down into smaller, focused PRs, each with a specific feature or improvement? I'm particularly interested in the color blending functionality. Thanks again for your time and contribution! |
|
@JoseRFelix Howdy, unfortunately I don't have any spare time to spend on breaking this PR into multiple ones. The PR provided is of high quality in both code, testing and it does solve all those linked issues. I agree its a large PR doing a lot at once but I didn't receive any feedback on the PR for a very long time so I'm not receptive now to spending more time splitting it up. For the possible benefit of others hopefully you can fix it and merge it in. Feel free to take any code from any of commits and add it to your own PRs to fix various issues. Personally I'll continue to use the locally version I have which was has been running well for me. 👍 |
Intro
Thanks for the great component @JoseRFelix ! I've been using it on all my projects and I really like the design and animations of this toggle. In particular, the fact its a single icon with no background clutter.
I have been making various edits to the component for my own needs and decided to contribute the changes back to the community. I am happy to take in feedback and make further changes to address any concerns.
Overview
This PR is huge and lots of changes have been made in one go.
2.0.0(due to lots of breaking changes that are not backwards compatible)18, Node20, react-spring9.7.4) (partially addresses Deprecated packages #45)demo.gifDemo (Examples)
chrome_t7rjBv21yd.mp4
Changes
System ThemeMode
There is a new third state in the 'toggle' for the System (or Auto) mode!

The design chosen was a half sun and half moon. This design was choses as it looks good and is easily understood. It can also animate well with the other existing sun and moon designs.
Color customisation
One common issue with the component was it was hard to customise the colors easily beyond the now removed
sunColorandmoonColor.We now have the following optional
colorsprops:This allows you to style each different theme mode however you like.
You can provide partial overrides or specify each color option.
If this prop is not provided, the default styling will be used.
API changes
There are breaking changes in the API that are not-backwards compatible.
Changes include:
ThemeModeand not a booleanisSystemThemeModeEnabledis new prop that can control if the system theme mode is being used or not (defaults totrue)themeModeis now the prop to bind (replaceschecked)colorsprovides more configurationisSystemThemeModeEnabledThis prop is new prop that can control if the system theme mode is being used or not (defaults to
true).If this is set to false, it results in the classic 2-state dark/light mode toggle with same animations as before (except with the janky overshoot removed).
Theme switch direction
The theme switch direction is:
System->Dark->LightI found this cycle path to look the best animation wise.
The choice was made NOT to allow this to be configurable because the animations depend on the ordering. Maybe this can be changed in future PR if there is a need for it.
Single Color Mode
If using single color scheme (i.e. black), the system design and light mode design are identical and not distinguishable.
My recommendation is to not support this (and encourage using fills and/or strokes to try and distinguish the system theme mode). This is solved if you instead use 2 colors (black/white).
Issues
High prio
Low prio
yarn startin examples does not watch for changes in main package. Requires restart to detect changes.Manual tests
Test on all browsers
Pre-merge TODOs