-
Notifications
You must be signed in to change notification settings - Fork 16
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
Major changes: Add System Theme Mode, Color Preferences, Accessibility and more! #48
Open
mobeigi
wants to merge
39
commits into
JoseRFelix:master
Choose a base branch
from
mobeigi:add-system-toggle
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…er dependency versions. Update failing build, tests.
…alf to mention moon
mobeigi
changed the title
[WIP] Major changes: Add System Theme Mode, Color Preferences, Accessibility and more!
Major changes: Add System Theme Mode, Color Preferences, Accessibility and more!
Aug 27, 2024
@JoseRFelix Hey mate, any chance of this getting merged? I know its a lot of changes. Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.gif
Demo (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
sunColor
andmoonColor
.We now have the following optional
colors
props: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:
ThemeMode
and not a booleanisSystemThemeModeEnabled
is new prop that can control if the system theme mode is being used or not (defaults totrue
)themeMode
is now the prop to bind (replaceschecked
)colors
provides more configurationisSystemThemeModeEnabled
This 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
->Light
I 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 start
in examples does not watch for changes in main package. Requires restart to detect changes.Manual tests
Test on all browsers
Pre-merge TODOs