Page MenuHomePhabricator

Cosmos skin: Work on getting rid of the nasty MediaWiki\Skin\Cosmos\Icon class
Open, MediumPublic

Description

The MediaWiki\Skin\Cosmos\Icon class does some nasty work and quite a hack. We should work on using OOUI icons to replace these other icons, to fit the MediaWiki conventions.

Event Timeline

Ultimately the goal should be that we can just store plain SVG files under resources and load them through ResourceLoader. Currently the icon SVG data is stored in a nested associative array, but that's not very nice to have. See https://www.mediawiki.org/wiki/Manual:ResourceLoaderImageModule.php

(We also don't need to necessarily use OOUI icons and is actually more out of scope for this task, but could be something to consider in the future)

Switching to ResourceLoaderImageModule would slightly change behavior as they would have to be applied as a background image via the CSS background-image property.

To ensure we can keep the same behavior (for now), we should keep outputting the SVG files into the HTML DOM. We can parse an SVG string to a DOM tree, and then modify the attributes that way.

Change 655677 had a related patch set uploaded (by Universal Omega; owner: Universal Omega):
[mediawiki/skins/Cosmos@master] Remove unused icons from Icons.php

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

Change 655677 merged by Universal Omega:
[mediawiki/skins/Cosmos@master] Remove unused icons from Icons.php

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

Change 655678 had a related patch set uploaded (by Universal Omega; owner: Universal Omega):
[mediawiki/skins/Cosmos@master] Get rid of Icon.php

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

Change 655678 abandoned by Universal Omega:
[mediawiki/skins/Cosmos@master] Get rid of Icon.php

Reason:

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

  • Step 1) Set up a function to extract Metadata from svg files to parse them directly on page to maintain current behavior. This function can be created in either a new class, or in SkinCosmos.php.
  • Step 2) Generate SVG files from all the icons in Icon.php and upload them to resources/icons.
  • Step 3) Replace usages of Icon::getIcon with new function created in step 1.
  • Step 4) Delete Icon.php.
Universal_Omega renamed this task from Cosmos skin: Work on getting rid of the nasty Cosmos\Icon class to Cosmos skin: Work on getting rid of the nasty MediaWiki\Skin\Cosmos\Icon class.Jan 21 2021, 4:21 PM
Universal_Omega updated the task description. (Show Details)