-
Notifications
You must be signed in to change notification settings - Fork 352
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
Light and dark mode switch #974
Comments
It would be even better if the website just automatically changed its palette to light mode via the standard CSS |
@TrialDragon , I was looking into this, and I wanted your thoughts: This can be done, and the best way to do it would be using CSS variables (which can respond dynamically to @media prefers-color-scheme), instead of SCSS variables (which are pre-processed into CSS). To be specific, the Bevy website currently uses SCSS variables (see https://github.com/bevyengine/bevy-website/blob/main/sass/_vars.scss) which are pre-processed into CSS variables. E.g. $subtitle-color: #999; Because SCSS is only a pre-processor, these variables can't respond dynamically to :root {
@media (prefers-color-scheme: dark) {
--subtitle-color: #999;
}
@media (prefers-color-scheme: light) {
--subtitle-color: #777;
}
} I currently use CSS variables inside SCSS on my Zola-based blog to get auto light mode / dark mode (example: https://github.com/lynnpepin/lynndotpy_xyz/blob/main/sass/color/auto.scss). It works like a charm :D Proposal: I was going to go through and replace the SCSS color variables with CSS variables, to respect |
I, personally, don't have any issue with using CSS variables instead of SCSS variables to be honest; I'm not even entirely sure why we used SCSS variables to begin with beyond we were writing SCSS, ergo, use SCSS variables. |
Awesome, happy to hear that :) I was able to spend a good few hours on this. Re: SCSS variables, the only place SCSS variables were used were in a few So, I pre-calculated the My fork is here: https://github.com/lynnpepin/bevy-website There are a few outstanding issues though:
Also, I kept the variable naming the same, but that means we have examples like |
I'm not so deft at manipulating SVGs. Gonna take a crack at making inverted versions of the SVGs (i.e. a |
A temporary work-around if logo images take too much time is to draw a box around all bright images. Here’s how that looks with my custom CSS: (Well, it ain’t pretty, but iunno how much man power’s available for image editing.) Probably the best solution is to edit the SVGs into having a thick black border around all shapes. In dark mode you just don’t see the borders, in light mode it’ll look outlined like many sprite-based games do for foreground objects. |
I like this! I was able to figure out two workarounds:
In the interest of getting feedback, I have a WIP build of the site with the new theme here! https://bevydocs.lynndotpy.dev/ Each image needs to be addressed individually, so I'm working on that bit by bit :) |
Working on the images and whatnot right now! Don't want to run into any duplication of work. Going to try and finish them up today and get the site updated for it |
Update: I have the light theme complete! But I'll also be creating a Javascript toggle, which will be another Whole Thing (tm) of work :) For now, please please check out the preview here, and @ me if there's anything that looks ugly or bad or otherwise improvable :) https://bevydocs.lynndotpy.dev/ |
For anyone coming to this, there is now a more recent PR by doup, building upon the previously linked PR, and looking very very good: #1771 |
It would be a useful QoL feature for our users to be able to change from the dark mode to a light mode integrated into the site.
Origin: #3 (comment)
The text was updated successfully, but these errors were encountered: