Page MenuHomePhabricator

Support Codex design tokens in TemplateStyles
Open, Needs TriagePublicFeature

Description

As a template developer, I would like to be able to re-use Codex design tokens, so that templates have a style consistent with the rest of the MediaWiki interface.

Once T360562 is done, this task would just be about making the rest of Codex design tokens available as CSS variables (T360726).

Related Objects

Event Timeline

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

This would probably require adding LESS support to TemplateStyles, but I'm not 100% sure.

Related: T320322. Dont know this task is parent or sub :)

Izno changed the subtype of this task from "Task" to "Feature Request".Jan 17 2024, 7:38 PM
Izno moved this task from Backlog to External on the TemplateStyles board.
Izno moved this task from External to Backlog on the TemplateStyles board.

Are Codex variables available also as CSS variables, or only as Less variables? If the latter (which I suspect), I don’t see how T320322 would help.

The point of T296689 was to consider whether they should be available as CSS or Less.

Codex design tokens are available as CSS, Less, Sass, and soon as JS variables (T324688). I think the question is more about being able to access these tokens in some way in TemplateStyles so I agree with T320322 being one approach (and appropriate as a subtask).

CCiufo-WMF moved this task from Triaging to Backlog on the Design-System-Team board.

Moving to the backlog for now as this isn't on our radar. We can come back to this once some of the child tasks become prioritized.

Less support in TemplateStyles is very unlikely to happen. Either we'd need to write a secure Less sanitizer, and not only is that an implausibly large task, but also unlike CSS (which comes with exact parser specifications) Less isn't a very well-defined, robust and stable language. Or we'd have to transform first and then sanitize, and then you'd get error messages that are disconnected from the source text.

CSS variables are not impossible but hard to do safely (as explained in the second half of T200632#4623300). MW Platform might do some work on TemplateStyles in the next quarters, but the low-hanging fruit there is adding support for all the straightforward properties that didn't exist or weren't widely supported at the time of the last major update to it in 2018, so (absent a volunteer picking up this fairly complex task) I wouldn't expect CSS variable support soon.

For now I think the best workaround is to write your CSS code in Less, pull in Codex variables, and have a build step before putting it into the template.

Re-opening as it was mistakenly closed as a duplicate instead of T320322.

CCiufo-WMF renamed this task from Make Codex variables available to TemplateStyles to Support Codex design tokens in TemplateStyles.Mar 21 2024, 9:56 PM
CCiufo-WMF updated the task description. (Show Details)

I checked, and it seems that Codex tokens are available on every skin (with mediawiki.skin.default.less) ? Or have I misunderstood? I wouldn't mind a hint as to where the ResourceLoader comes in to load the tokens, and for the default autoloaded modules. I really need to dig the ResourceLoader, cause I'm lost about the chaining, don't know where to ask.

In my opinion, this task is very important both in the long term and in the short term for the night mode:

  • Wikis could follow the design system decisions by using CSS variables without having to stupidly copy CSS values (and static, ewh)
  • Wikis could use the Codex design tokens to mimic the Codex CSS-only components (unless you can find a way to load component styles with the ResourceLoader "on the fly"?)

Without it, wikis would have to keep using Commons.css instead of TemplateStyles subpages for wiki templates if they want to keep sync with Codex.

Edit: guess I'm again late with the progress of T360562.