-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for prefers-color-scheme, simplify vars
- Loading branch information
Showing
8 changed files
with
118 additions
and
61 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
c3c114c
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.
hi friend,
this commit causes a flicker on loading when set dark mode, it will show light mode loading animation then correct animation, like this
reproduce:
c3c114c
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.
Hi @baddate, Thanks for pointing this out.
The flicker is caused due to the delay in the javascript fetching the values from localstorage and then applying them to the DOM. When the page loads initially, the CSS with inital HTML makes it render the page in the
auto
theme first, which would be light/dark depending on the user preference. And just after the css variable changes are applied and the theme reverts to the user set theme.I consider this a limitation with static-only theming. This is because the html being served has no idea of the preference of the user, so the first paint (before localstorage values are applied) will always be the
auto
theme.Moreover the flicker, from light to dark and not between colors, is noticeable only when the user chooses the mode opposite to their preferred system preferences.
If this seems like a unworthy compromise, one can implement saving themes to backend storage and tieing them to the user session/account, and then prefilling the css variables from the server so the initial html already has the user preferred theme.
Due to the complexity of implementing a server just to manage themes for the users was not something I was looking forward to with a personal static html website. I do recommend the theme storage on server for web apps and SPAs etc.
For me I found the slight flicker acceptable as the loader masks this somewhat.
PS: Yeah I hate the occasional flicker if something in dark mode flickers white but this should not occur when the user's preferred color scheme is dark.