Page MenuHomePhabricator

Vector 2022 should get night theme
Open, HighPublic3 Estimated Story Points

Description

The latest Codex build provides CSS variable support and a palette. Following T358059, we want to copy the approach in Minerva inside Vector 2022.

Changes to Codex in v1.5.0

Codex 1.5.0 will ship with a number of important updates for dark mode support. Some minor changes will need to be made to Vector and Minerva skins in order to integrate with these changes.

CSS Variables are used by default; "experimental" build has been removed

Codex 1.5.0 removes all references to an "experimental" build of the library (both styles and design tokens). Instead, the default build of Codex design tokens and styles are now aware of a set of publicly-exposed CSS custom properties (pertaining to color), and will respect any changes to those properties in the browser environment.

In @wikimedia/codex-design-tokens 1.5.0, the theme-wikimedia-ui.less file will include a number of variables that look like this:

@color-base: var( --color-base, #202122 );
@color-base--hover: var( --color-base--hover, #404244 ); // Aimed to be replaced by `color.gray600` in future.
@color-emphasized: var( --color-emphasized, #000 );
@color-subtle: var( --color-subtle, #54595d );
@color-placeholder: var( --color-placeholder, #72777d );
@color-disabled: var( --color-disabled, #72777d );
@color-inverted: var( --color-inverted, #fff );

All LESS variables which relate to color will get their value from a lookup of the corresponding CSS custom property: @color-base will look for the value of --color-base, etc. The CSS custom property names are *not* namespaced FWIW. LESS variables which do not relate to color are unchanged (they don't reference CSS custom props at this time).

For backwards-compatibility, we are also including the normal token value here as a fallback, so users of the design tokens who don't care about supporting alternate color modes can just keep using the tokens in the same way as before.

As of Codex 1.5.0, the @wikimedia/codex component styles are built using these updated design token values. So component styles will be aware of the CSS custom properties as well, and will respect the new values of these properties when they change. The "experimental" component styles have been removed, so please update any skin code accordingly.

New CSS root declaration files

Codex design tokens v1.5.0 will include a new file called theme-wikimedia-ui-root.css. This file is the "root declaration" that defines the CSS custom properties relevant to color along with their default (light mode) values. The file looks like this:

:root {
  --color-base: #202122;
  --color-base--hover: #404244; /* Aimed to be replaced by `color.gray600` in future. */
  --color-emphasized: #000;
  --color-subtle: #54595d;
  --color-placeholder: #72777d;
  --color-disabled: #72777d;
  --color-inverted: #fff;
  /* etc, full list ~110 color variables is included */
}

Similarly, there is a file called theme-wikimedia-ui-mode-dark.css which contains a set of variable overrides – these are the dark mode values which should override the above color variables when dark mode is active. Not every variable on the above list is overridden for various reasons.

:root {
  --color-base: #f8f9fa;
  --color-base--hover: #fff; /* Aimed to be replaced by `color.gray600` in future. */
  --color-emphasized: #fff;
  --color-subtle: #eaecf0;
  --color-placeholder: #c8ccd1;
  --color-inverted: #101418;
  /* ... etc, full list contains about 50 css vars */
};
Mode-specific LESS mixins

As a convenience, @wikimedia/codex-design-tokens 1.5.0 will also include some LESS mixins which can be used to load one of the above sets of variables into an arbitrary CSS selector. There are two files:

  • theme-wikimedai-ui-reset.less (a mixin which restores all CSS custom props to their light mode defaults, call it with .cdx-mode-reset())
  • theme-wikimedia-ui-mixin-dark.less (a mixin which provides just the dark mode variables – call it with .cdx-mode-dark() ).

Usage in skins

The general approach taken in T358059 is still valid, but please use the above-mentioned files going forward. All references to "experimental" Codex tokens and styles should be removed.

Acceptance criteria

  • Vector 2022 uses the Codex CSS build to get night mode
  • Vector 2022 has a light mode color palette using the LESS variables e.g. `--color-base: @color-base;`
  • Vector 2022 has a night mode color palette identical to Minerva's which is enabled when the .skin-theme-clientpref-night class is enabled on the HTML tag.

QA Steps

  • Visiting any URL with ?vectornightmode=1

Related Objects

StatusSubtypeAssignedTask
OpenJdrewniak
OpenJdrewniak
OpenNone
OpenNone
OpenNone
OpenNone
ResolvedJScherer-WMF
Resolvedovasileva
ResolvedSpikeSToyofuku-WMF
OpenNone
OpenNone
ResolvedJdlrobson
Resolvedovasileva
ResolvedBUG REPORTJdlrobson
ResolvedBUG REPORTJScherer-WMF
OpenNone
DuplicateFeatureNone
ResolvedSpikeJdlrobson
ResolvedJdlrobson
Resolvedovasileva
ResolvedFeatureJdlrobson
DuplicateNone
OpenBUG REPORTNone
ResolvedJdlrobson
Resolvedovasileva
DuplicateJdlrobson
Resolvedovasileva
In ProgressNone
DuplicateNone
ResolvedJdlrobson
ResolvedBUG REPORTovasileva
Resolvedovasileva
ResolvedVolker_E
InvalidNone
InvalidJdlrobson
DuplicateNone
DuplicateNone
StalledNone
DuplicateNone
Resolvedovasileva
OpenNone
ResolvedJdlrobson
ResolvedJdlrobson
ResolvedJdlrobson
DuplicateJdlrobson
ResolvedJdlrobson
ResolvedJdlrobson
ResolvedJdlrobson
ResolvedJdlrobson
ResolvedNone
DeclinedJdlrobson
ResolvedSToyofuku-WMF
ResolvedJdlrobson
OpenKSarabia-WMF
ResolvedNone
OpenNone
OpenEdtadros
ResolvedJdlrobson
ResolvedJdlrobson
OpenBUG REPORTNone
ResolvedBUG REPORTovasileva
Openovasileva
ResolvedBUG REPORTovasileva
ResolvedBUG REPORTabi_
ResolvedBUG REPORTNikerabbit
ResolvedBUG REPORTovasileva
Openovasileva
ResolvedBUG REPORTJdlrobson
Openovasileva
Resolvedovasileva
Resolvedovasileva
Resolvedovasileva
Resolvedovasileva
ResolvedFeatureNone
OpenNone
Resolvedovasileva
Resolvedovasileva
OpenNone
OpenNone
OpenJdrewniak
ResolvedJScherer-WMF

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
Jdlrobson changed the task status from Open to Stalled.Feb 28 2024, 6:37 PM
Jdlrobson added a subscriber: ovasileva.

@ovasileva this is blocked on T358059.

Jdlrobson renamed this task from Implement the dark mode color palette and switch LESS variables in Vector to use it to Vector 2022 should use the experimental Codex build.Feb 28 2024, 6:40 PM
Jdlrobson updated the task description. (Show Details)
Jdlrobson changed the task status from Stalled to Open.Mar 11 2024, 5:53 PM

Questions:

  • What steps will ensure the smooth integration of the experimental Codex build with Vector 2022?
  • How will the light and night mode colour palettes be implemented to maintain consistency across Vector themes?
  • Are there any potential impacts on performance or user experience to consider with this integration?

Context to add:
Considering the widespread use of Vector, should we consider waiting until the experimental Codex build stabilises before integrating it? This would ensure a smooth transition and maintain user experience quality.

Change 1009358 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/skins/Vector@master] [pOC] Night mode on Vector

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

What steps will ensure the smooth integration of the experimental Codex build with Vector 2022?

The change will impact the stable code, so it's essential that as part of this work, we run Pixel to flag any unexpected visual regressions. The approach we are taking is identical to Minerva so we should learn from the mistakes there (for example undefined CSS variables). https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/+/1009358 is a proof of concept of the work we need to do here. @Jdrewniak
should have a good handle on the changes required here - so make sure you talk to him before working on this ticket.

How will the light and night mode colour palettes be implemented to maintain consistency across Vector themes?

Currently Minerva maintains a local version of the night mode palette. The light and night mode palettes should be defined within Codex eventually but depending on our schedule we may need to maintain 2 palettes. The palettes should be relatively stable so I think this is okay if needed.

Are there any potential impacts on performance or user experience to consider with this integration?

Keep an eye on bundle sizes. We may need to adjust the budget as part of this change, which is okay, as on the long term we expect this to lead to less CSS> We should be concerned if we see an increase in more than 1kb.

The night mode palette is not available in Codex yet. Hopefully will land sprint 1. We have enough work already for switching to Vector so I think it's okay to delay this.

Jdlrobson lowered the priority of this task from High to Medium.Fri, Apr 5, 6:26 AM
Jdlrobson raised the priority of this task from Medium to High.EditedFri, Apr 5, 6:28 AM

Moving to sprint 2 as we haven't discussed this with the Design systems team yet (last time we talked to them they were not ready for this) and we still have more pieces of the jigsaw to put in place e.g. T361589 and T361717

Jdrewniak subscribed.
Jdlrobson added subscribers: CCiufo-WMF, egardner, Volker_E.

@Jdrewniak and I met with @egardner, @CCiufo-WMF and @Volker_E today. The next steps are as follows:

  • Design systems team will fold the experimental build into the main build
  • Design systems team will document the CSS variables that are available and their stability on https://mediawiki.org/wiki/Codex

Once that's done, this ticket can be ready for work on. In terms of timeline we should be able to work on it May 7th (sprint 3).

@CCiufo-WMF is there a ticket on your side for which we can track your work?

I don't think we have tickets set up for this yet but once we do I can share them here.

Change #1009358 abandoned by Jdlrobson:

[mediawiki/skins/Vector@master] [pOC] Night mode on Vector

Reason:

We will work on this in about 2-3 weeks time.

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

Change #1009358 restored by Jdlrobson:

[mediawiki/skins/Vector@master] [pOC] Night mode on Vector

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

Change #1009358 abandoned by Jdlrobson:

[mediawiki/skins/Vector@master] [pOC] Night mode on Vector

Reason:

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

Once the next release of Codex is out, there may be very small updates that are needed on the skin side (changes to some filenames, etc). We can help you all with this.

Change #1024515 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/skins/Vector@master] Prepare variables for night mode

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

Change #1009358 restored by Bernard Wang:

[mediawiki/skins/Vector@master] [pOC] Night mode on Vector

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

Change #1024515 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Prepare variables for night mode

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

Test wiki created on Patch demo by BWang (WMF) using patch(es) linked to this task:
https://patchdemo.wmflabs.org/wikis/abfa33da2d/w

@Jdlrobson Could you provide some more clarity on what the AC for this ticket is for, given that we dont want to ship the experimental build with Vector. Are we waiting on DST to make the experimental build the default build before merging this patch and closing this ticket?

bwang removed bwang as the assignee of this task.Fri, Apr 26, 8:04 PM
bwang subscribed.

Once the next release of Codex is out, there may be very small updates that are needed on the skin side (changes to some filenames, etc). We can help you all with this.

Is the next Codex release going to make the experimental build the default? We have a patch in Vector using the experimental build that is ready for review, just let us know when yall are ready on your end!

Jdlrobson renamed this task from Vector 2022 should use the experimental Codex build to Vector 2022 should get night theme.Mon, Apr 29, 5:18 PM
Jdlrobson updated the task description. (Show Details)
Jdlrobson updated the task description. (Show Details)

Change #1025868 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/skins/Vector@master] Prepare for night theme

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

Change #1025868 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Prepare for night theme

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

@bwang @Jdrewniak this is ready to go now.
https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/+/1009358

After running Pixel, please merge this. It would be great to have this in the beta cluster in time for the hackathon!