[go: up one dir, main page]

Page MenuHomePhabricator

docs: Enable dark mode in Codex docs site (MVP)
Closed, ResolvedPublic2 Estimated Story Points

Description

Background

Now that we have a set of dark mode color tokens in Codex, we should update our documentation site to support color scheme switching, so that people can both take advantage of dark mode on the whole site, and see Codex components, design tokens, and icons in both color modes.

Implementation

The following is an MVP version of this. In the future, we could make further improvements, such as a better design for the color tokens page.

Enable color mode switching on the docs site

VitePress supports light and dark color modes out of the box (see VitePress's appearance docs). We need to enable it, and have it default to the user's preference.

We then need to set our dark mode color tokens when VitePress's .dark class is present on the <html> element.

Finally, we need to clean up any colors that don't look right in dark mode.

Show color tokens according to color mode

We need to show the dark mode color tokens on the color tokens demo page. For now, let's just show the correct token depending on the current color mode of the site, along with a message explaining to users what they're seeing, and that they should just use the color tokens rather than raw hex values in order to ensure they have the right value in both color modes.


Acceptance criteria

  • Color mode switching is enabled on the docs site, and defaults to your preference
  • The site and all its features look correct in dark mode
  • The color tokens page shows the correct token depending on the current color mode

Any future work will be documented as separate tasks.


Future tasks

Event Timeline

CCiufo-WMF triaged this task as Medium priority.Jul 10 2024, 5:28 PM
AnneT renamed this task from Enable dark mode in Codex docs site to docs: Enable dark mode in Codex docs site (MVP).Aug 12 2024, 7:44 PM
AnneT changed the task status from Open to In Progress.
AnneT updated the task description. (Show Details)

Change #1062422 had a related patch set uploaded (by Anne Tomasevich; author: Anne Tomasevich):

[design/codex@main] docs: Enable dark mode and mode switching

https://gerrit.wikimedia.org/r/1062422

Change #1062423 had a related patch set uploaded (by Anne Tomasevich; author: Anne Tomasevich):

[design/codex@main] docs: Show dark mode colors in the color tokens demo

https://gerrit.wikimedia.org/r/1062423

@bmartinezcalvo @DTorsani-WMF this is ready for design review! You can test it out here. I'm mostly looking for feedback on whether anything is broken enough to block moving forward with this, and ideas for future work.

This task is meant to be an MVP version of dark mode for the docs site. My goals for this task are:

  1. To enable dark mode/color mode switching
  2. To make sure nothing looks broken in dark mode
  3. To show dark mode colors on the color tokens page. I decided to show light mode colors in light mode and dark mode colors in dark mode for 2 reasons: it's easier than updating the UI to show both colors at once somehow, and IMO it's less confusing for users and encourages them to just use design tokens rather than raw color values to make sure they're using the right color in both modes (I put a note to this effect at the top of the page). I'm also aware of Derek's in-progress design updates for this page, so I didn't want to change much now.

Future goals, that we can note and open tasks for:

  1. To make the site look even better in dark mode
  2. To make improvements to the color tokens page
  3. To update any components that don't look quite right in dark mode

I've already noted a few component/token issues:

@AnneT This is great, thank you for putting this together. I'm noticing what feels like a bug. When I am in dark mode and navigate to /design-tokens/color the colors appear as their light mode values until I turn the mode back to light, then back to dark. One other interesting observation is that any images on the docs site are made in light mode and, obviously, this doesn't change when toggling to dark mode. We have discussed challenges with using images on the docs site and explored other options in the past. Maybe just something to keep thinking about.

Lastly, I briefly explored improvements to the color tokens page [shown below] that we could consider for this improvement or a a follow up task.

color-tokens.jpg (2×2 px, 950 KB)

@AnneT it looks really good. Thank you for working on this. My only observation, apart from the issues commented above, is about the ToggleSwitch to turn on the Light/Dark modes:

  1. The ToggleSwitch is a bit small and difficult to find within the content of the screen. Would it be possible to make it bigger? Maybe 32px height.
  2. On mobile screens, you need to open the menu in the top-right corner to find the ToggleSwitch. However, on tablet screens, the ToggleSwitch is not visible because the navigation menu does not include it. Is it possible to make the ToggleSwitch visible in the navigation bar on all screen sizes?
Captura de pantalla 2024-08-19 a las 16.14.42.png (1×688 px, 107 KB)
Captura de pantalla 2024-08-19 a las 16.19.10.png (1×1 px, 170 KB)
MobileTablet

@DTorsani-WMF @bmartinezcalvo thanks for your comments!

I've updated the patches to fix the following:

  • The bug that Derek pointed out, where the colors might initially be shown in the wrong mode on page load, is now resolved
  • The bug that Bárbara pointed out, where the color mode toggle switch is missing on tablet, has been fixed (good catch! we previously caused this by hiding the menu it was supposed to be in 😬)

I'd like to propose that we open future tasks for the following:

  • Updating the color tokens page with Derek's new design
  • Making the color mode toggle switch bigger - this is actually a significant undertaking, since this component comes from VitePress and is a bit tricky to style, and as we've seen, sometimes when we customize VitePress's CSS it can come back to bite us later!
El T365178#10075741, @AnneT escribió:

@DTorsani-WMF @bmartinezcalvo thanks for your comments!

I've updated the patches to fix the following:

  • The bug that Derek pointed out, where the colors might initially be shown in the wrong mode on page load, is now resolved
  • The bug that Bárbara pointed out, where the color mode toggle switch is missing on tablet, has been fixed (good catch! we previously caused this by hiding the menu it was supposed to be in 😬)

@AnneT the toggle switch is still hidden when the screen becomes smaller in this patch. Since the dark mode is a main action that should be visible for users, would it be possible to leave it always visible in the navigation bar on top?

Grabaciondepantalla2024-08-20alas11.41.26-ezgif.com-video-to-gif-converter.gif (304×600 px, 1 MB)

El T365178#10075741, @AnneT escribió:

I'd like to propose that we open future tasks for the following:

  • Updating the color tokens page with Derek's new design
  • Making the color mode toggle switch bigger - this is actually a significant undertaking, since this component comes from VitePress and is a bit tricky to style, and as we've seen, sometimes when we customize VitePress's CSS it can come back to bite us later!

I've created these new tasks:

@AnneT the toggle switch is still hidden when the screen becomes smaller in this patch. Since the dark mode is a main action that should be visible for users, would it be possible to leave it always visible in the navigation bar on top?

Yes, but I'd recommend we open a new task for that as well. Making it visible on tablet-size screens may be tricky as we will eventually run out of space in the header for all of the main nav items, so we'd have to account for that.

Change #1062422 merged by jenkins-bot:

[design/codex@main] docs: Enable dark mode and mode switching

https://gerrit.wikimedia.org/r/1062422

Change #1062423 merged by jenkins-bot:

[design/codex@main] docs: Show dark mode colors in the color tokens demo

https://gerrit.wikimedia.org/r/1062423

Change #1064134 had a related patch set uploaded (by Catrope; author: Catrope):

[mediawiki/core@master] Update Codex from v1.11.0 to v1.11.1

https://gerrit.wikimedia.org/r/1064134

Change #1064134 merged by jenkins-bot:

[mediawiki/core@master] Update Codex from v1.11.0 to v1.11.1

https://gerrit.wikimedia.org/r/1064134