bevyengine / bevy-website

The source files for the official Bevy website
https://bevyengine.org
MIT License
193 stars 332 forks source link

Light mode for Bevy website -- draft PR #1603

Open lynnpepin opened 1 month ago

lynnpepin commented 1 month ago

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:

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:

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 :)

image

image

image

image

image

image

image

ariofrio commented 1 month ago

This looks great! Honestly, it might personally become my preferred way of viewing the Bevy website.

Some design nitpicks:

I think the dark gray borders and the gray item backgrounds in light mode should be lighter. Compare the contrast:


And I'm sure you've noticed this already, the Assets item titles should have a white text, or a white (translucent) background. I would also change the borders and backgrounds the same way as above. Compare: