Page MenuHomePhabricator

Minerva uses Codex css-icon mixin with custom icons in an unsupported way, causing bloated and invalid CSS
Open, In Progress, HighPublicBUG REPORT

Description

NOTE: Could lead to bugs on long run so we should fix sooner rather than later while fresh in our minds.

Documentation for how to correctly use custom icons with Codex is documented in https://doc.wikimedia.org/codex/latest/components/demos/icon.html#custom-icon

Minerva contains code that uses Codex's CSS icon mixin with a custom icon, as follows:

@minerva-icon-issue-severity-medium: '<path d="M10 0a10 10 0 1 0 10 10A10 10 0 0 0 10 0zm1 16H9v-2h2zm0-4H9V4h2z"/>';

.minerva-icon--issue-severity-medium-mediumColor {
	.cdx-mixin-css-icon( @minerva-icon-issue-severity-medium, #ff5d01 );
}

However, using this mixin with a custom icon is undocumented and is not supported in the way that it's being used here. Codex's built-in icon variables look like this:

@cdx-icon-add: '<path d="M11 9V4H9v5H4v2h5v5h2v-5h5V9z"/>', 'false', 'false', 'false', 'false';

The mixin implementation relies on the presence of these extra 'false' parameters. When they're missing, as they are in Minerva's custom icons, it behaves incorrectly. This causes Minerva's Less code to produce the following CSS in Codex v1.3.2:

minerva-icon--issue-severity-medium-mediumColor {
    background-position: center;
    background-repeat: no-repeat;
    background-size: calc(max(1.25em, 20px));
    min-width: 20px;
    min-height: 20px;
    width: 1.25em;
    height: 1.25em;
    display: inline-block;
    vertical-align: text-bottom;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"%23ff5d01\"><path d=\"M10 0a10 10 0 1 0 10 10A10 10 0 0 0 10 0zm1 16H9v-2h2zm0-4H9V4h2z\"/></svg>")
}

.minerva-icon--issue-severity-medium-mediumColor[dir='rtl'],
html[dir='rtl'] .minerva-icon--issue-severity-medium-mediumColor:not([dir='ltr']) {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 20 20" fill="%23ff5d01">extract(' <path d="M10 0a10 10 0 1 0 10 10A10 10 0 0 0 10 0zm1 16H9v-2h2zm0-4H9V4h2z" />',4)</svg>')
}

Note the unnecessary [dir='rtl'] block (the icon doesn't have a separate RTL variant) and note how the contents of the SVG image in that block are extract(' <path .... />',4), which is invalid.

(The output in Codex v1.3.3 is different and longer, but is broken in the same ways.)

Ideally Codex should document how to use the CSS-only icon mixin with custom icons, and perhaps adapt its mixin code to make custom icon usage easier (e.g. by handling the absence of 'false' more gracefully); see T358069. Until then, Minerva should conform its custom icon definition to Codex's style to avoid bugs.

QA

Event Timeline

Potential deploy blocker?

@Jdlrobson - could you expand on the task description to help clarify the blocker?

Jdlrobson lowered the priority of this task from High to Medium.Feb 23 2024, 10:18 PM

I checked this with Roan and it seems like while this a clear bug it generates an invalid CSS so doesnt apply to page.

So... Not a train blocker but something that we should fix and should be straightforward to fix.

Catrope renamed this task from Minerva uses Codex css-icon mixin with custom icons in an unsupported way, causing bugs and bloat to Minerva uses Codex css-icon mixin with custom icons in an unsupported way, causing bloated and invalid CSS.Feb 26 2024, 5:43 PM

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

[mediawiki/skins/MinervaNeue@master] Icons render consistently in night mode

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

Change #1038914 abandoned by Jdlrobson:

[mediawiki/skins/MinervaNeue@master] Icons render consistently in night mode

Reason:

Not working on - just wanted to update the associated tasks.

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

Jdlrobson raised the priority of this task from Medium to High.Tue, Dec 10, 9:23 PM
Jdlrobson updated the task description. (Show Details)
Jdlrobson moved this task from Backlog to Small isolated bugs on the Web-Team-Housekeeping board.
SToyofuku-WMF changed the task status from Open to In Progress.Wed, Dec 11, 7:05 PM
SToyofuku-WMF subscribed.

pending estimate

Seems relatively straightforward. All the non-standard usages are in the page issues feature in Minerva and easy to verify using existing Pixel setup. Would suggest 2 pointer just because some people may not be familiar with this part of code.