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.
Description
Details
Subject | Repo | Branch | Lines +/- | |
---|---|---|---|---|
Get rid of Icon.php | mediawiki/skins/Cosmos | master | +165 -37 | |
Remove unused icons from Icons.php | mediawiki/skins/Cosmos | master | +0 -66 |
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Declined | Universal_Omega | T264908 Convert Cosmos to use HTML templating | |||
Open | None | T265109 Cosmos skin: Work on getting rid of the nasty MediaWiki\Skin\Cosmos\Icon class |
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
Change 655677 merged by Universal Omega:
[mediawiki/skins/Cosmos@master] Remove unused icons from Icons.php
Change 655678 had a related patch set uploaded (by Universal Omega; owner: Universal Omega):
[mediawiki/skins/Cosmos@master] Get rid of Icon.php
Change 655678 abandoned by Universal Omega:
[mediawiki/skins/Cosmos@master] Get rid of Icon.php
Reason:
- 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.