-
Notifications
You must be signed in to change notification settings - Fork 343
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 mode for Bevy website -- draft PR #1603
Conversation
Rather than inverting the dark mode logo could you use the light logo? |
Hi all-- sorry for being so late to come back to this. While the style update is mostly done, I haven't been able to make progress on the three-state toggle. If someone else wants to take that on, I'd appreciate it.
Thank you for the feedback! Good idea regarding the borders-- they should have less contrast.
I originally used the light logo, controlled with |
Hi! Thanks for the immense effort! I've started to review the PR and while I like the general approach, I don't like this at all: 😅 If it's OK I'll prepare a PR with a layer of proper semantic variables (+ I'll also try to define some color palettes). Maybe I'll move also the CSS vars near their usage when it makes sense, something like: .layout {
@media (prefers-color-scheme: dark) {
--header-bg-color: var(--color-neutral-800);
--header-border-color: #2c2c2d;
--content-bg-color: var(--color-neutral-700);
}
@media (prefers-color-scheme: light) {
--header-bg-color: var(--color-neutral-100);
--header-border-color: var(--color-neutral-200);
--content-bg-color: var(--color-neutral-50);
}
min-height: 100vh;
display: flex;
flex-direction: column;
&__header {
position: fixed;
top: 0px;
width: 100%;
height: var(--header-height);
background-color: var(--header-bg-color);
border-bottom: 2px solid var(--header-border-color);
z-index: $z-layout-header;
}
&__content {
width: 100%;
padding-top: var(--header-height);
padding-bottom: 64px;
flex-grow: 1;
background-color: var(--content-bg-color);
}
}
@include state-checked("mobile-menu") {
// Disable scroll on main content
.layout {
height: 100%;
overflow: hidden;
}
} |
I've prepared a couple of PRs:
|
No qualms at all from my end, this is awesome and I appreciate this :D 👍🏻👍🏻👍🏻 |
Closing to keep this tracked cleanly in #1771 :) |
Background: Light mode as an accessibility necessity.
Hi! I'm an enthusiastic new user to this Bevy, but I've hit a small roadblock: The docs are light-on-dark! (I.e. dark mode).
I have astigmatism, which is making it difficult to read and use the docs (e.g. https://bevyengine.org/learn/quick-start/introduction/ ) because of its dark theme. Here's a relevant StackOverflow post regarding the merits of dark vs light theme.
Readers don't have good options to mitigate this. Readers can use this client-side with a "Reader" tool, but not all browsers have this. Readers can also use a theming extension, but these are a security concern for requiring permissions on all websites, and not all browsers have an extension system.
Referenced in issue 974 and duplicates, I hope adding light mode can bring more birds into the Bevy :)
New work: Light mode theme
So, I modified the Bevy website theme (rather extensively), with two primary changes:
@media (prefers-color-scheme: ...)
such that the theme will respond to system light/dark mode settings, and@media (prefers-color-scheme
.filter
and backgrounds creatively, with the intention of not requiring maintainers to double their work (e.g. when creating header images.)One outstanding piece of work for lightmode is rewriting the syntax-highlighting. I didn't touch this, instead opting to keep all the code as dark-on-light. This might be worth another PR down the line.
I'm hosting my fork of the themes on my site, at bevydocs.lynndotpy.dev/. Turn your system to light mode and visit the site to see the new theme!
Outstanding task: Theme toggler
There is one change I have not made yet, but was requested before merging: Putting light mode behind a toggle. This makes an outstanding task, which will have two parts:
Regarding implementation, this will be a bit difficult because, as it turns out, JavaScript can't toggle
prefers-color-scheme
on the webpage. (Woops! Would save time if I thought ahead to check this.)The intention is for the toggler to mostly follow the behavior of the docs.rs theme toggler, with the exception of defaulting to dark-mode. (Docs.rs defaults to system preference.)
For branding / consistency, the Bevy instead would like dark mode to be the default. In order to allow the Bevy to enjoy full functionality even without Javascript, that means an implementation detail: The true default will still be "follow system preferences", but that will be overwritten by Javascript on load, which will set it to dark mode (unless the user has already set a preference).
Functionally, most users in the Bevy will see this as dark-mode-by-default.
So, the toggle will need these specifications:
localStorage
.This sounds obvious, but it is possible to make a mistake with this in implementation.
I've done no work on the toggler yet, so, there will be a lot of that before this PR.
Screenshots and preview:
I host a preview of this lightmode at
bevydocs.lynndotpy.dev
! Please check it out, please critique vociferously :)