Page MenuHomePhabricator

[OOUI] Make WikimediaUI theme compatible with 'rem' units and future versions Codex Design Tokens
Open, HighPublic5 Estimated Story PointsFeature

Description

Background

As of v.1.3.6 of Codex, the legacy build of Codex design tokens uses rems for size values. i.e:

@font-size-base: 1rem;

In order for OOUI to be compatible with this update, it has to be modified to support rem values.
Currently, if v.1.3.6 of Codex is used (and the CSS variable issues outlined in T363849 have been resolved) the following error prevents the build from generating:

Running "less:wikimediaui" (less) task
>> src/styles/elements/ButtonElement.less: [L40:C1] Incompatible units. Change the units or use the unit function. Bad units: 'em' and 'rem'.
Warning: Error compiling src/styles/elements/ButtonElement.less Use --force to continue.

Aborted due to warnings.

This error stems from somewhere in the .theme-oo-ui-buttonElement() mixin.

It was generated by using this POC patch and upgrading the version of Codex to 1.3.6.

User story

  • As a Wikimedia developer/maintainer, I strive to maintain consistency across interfaces by ensuring the same underlying design token values are used across interfaces.

Requirements

NOTE: This task is about enabling OOUI to use a newer version of Codex design tokens, but that version should not be changed yet.

The OOUI build should pass without error when using Codex v1.3.6.
Whether that means changing one instance of an em+rem unit addition or switch to rems in OOUI more broadly remains to be seen.

Design

  • No visual changes are expected from this change, however switching to rem's might have unintended consequences with regards to accessibility and font-sizes.

Acceptance criteria

  • The OOUI WikimediaUI theme is capable with successfully compiling using Codex v.1.3.6

Communication criteria - does this need an announcement or discussion?

  • N/A

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change #1032083 had a related patch set uploaded (by Eric Gardner; author: Eric Gardner):

[oojs/ui@master] Update Codex to 1.4.0 and use rem units

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

So I was able to get OOUI to build successfully using Codex design tokens v1.4.0 (the first to include rem units) by updating the common.less file for the WikimediaUI theme as follows (the snippet is from the top of the file):

// WikimediaUI theme variables

@ooui-default-image-path: 'themes/wikimediaui/images';
@ooui-font-size-browser: 16; // assumed browser default of `16px`
@ooui-font-size-base: ( 0.875 / 1rem ); // equals `14px` at browser default of `16px`
@ooui-unit: rem;

I changed @ooui-font-size-base and @ooui-unit to use rem values, specifically.

I also had to change some inline unit calculations in the WikimediaUI widgets.less file.

This produces some visual changes on the demo page, so we may need to adjust some styles a little bit before this can move forward. I'll dig a bit deeper tomorrow.