Page MenuHomePhabricator

Skins should add their name as a class in <body>
Closed, ResolvedPublic

Description

Each skin should add its name (or ID or whatever) as a class in <body>. The reason I request this is that it would enable gadgets to change the CSS of a page in different ways depending on what skin is used.

For an example, turn on the "Dynamic menus" gadget on Meta; it is only intended for Modern, and will look awful in other skins like Monobook or Standard. With a CSS identifier for each skin, it could be adapted (or disabled) for other skins than Modern, and avoid making a mess.


Version: unspecified
Severity: enhancement

Details

Reference
bz15052

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:19 PM
bzimport set Reference to bz15052.
bzimport added a subscriber: Unknown Object (MLST).

Any particular reason the skin name provided with the javascript vars can't be used?

Reverted in r38677:
The commit was clearly not thought through and is poorly implemented.

It simply tacked the skin name onto the end of the body's class attribute. The idea of a skin className inside of the body tag has been discussed many times before. But one common agreement is that the class should be prefixed with 'skin-' as we prefix all the other stuff.

Additionally this code likely was not tested. It made use of "get_class( $this );" to find the 'skin name', this is a poor and unreliable method of doing this. Not only should the case of the skin name to output (lowercase id like 'monobook', or normal form 'MonoBook'), it's highly likely for the class to NOT be the name of the skin.


Discussion on this 'feature' is something that should be continued. Though, before WONTFIX'ing it as has been done in the past Splarka does note that this will be useful when [[MediaWiki:Print.css]] and [[Special:MyPage/print.css]] are implemented. That'll allow skin-specific print rules without a separate file for each one.

Personally, I'd also note that it would allow for minor skin-specific tweaks in Common.css
ie: A large body of code such as Titleicons code is inside of Common.css, and some minor location tweaks can be made for different skins, without resorting to separating the Titleicons code into multiple css files. (Actually, it would also allow for customizing something to work in multiple similar skins at the same time without duplicating the code)

ayg wrote:

I'd like to see some more concrete use-cases for this before spamming another class onto the body element.

Use cases include user common CSS, site common CSS, browser user stylesheet / greasemonkey CSS, extension CSS, gadget CSS, etc which might want to tweak for specific skins.

I would recommend the classname being skin-{$skinname}. SkinTemplate provides a 'skinname' thingy already... though it should probably be whatever name is used in the prefs, $wgValidSkins, $wgDefaultSkin bla bla that we grabbed globally.

sxwiki wrote:

Fixed again in r39058 .