Page MenuHomePhabricator

Allow projects to define helper classes/mixins e.g. nomobile-narrow across all templates
Closed, ResolvedPublic

Description

Introduce something linke

class="nomobile-narrow"

That may be applied to informative elements, like icons, which are basically helpful, e.g. as additional eye-catcher on navigation, but consuming too much space on narrow devices.

  • It is expected that the same information condensed within an icon is presented as textual explanation in detail anyway.
  • The same consideration is made on accessibility: A redundant icon shall be suppressed by screenreaders if just drawing attention and does not provide more information than the subsequent textual element is telling.

Nowadays, mobile devices with rather wide screen but still not desktop are disseminating.

  • The old handhelds of first generation had ony a few 100 pixels.
  • A tablet may be run with a desktop skin, not using mobile.
  • Now we find intermediate devices; too small for a desktop skin, requiring MinervaNeue, but wide enough to show eye-catching icons.

While

class="nomobile"

will suppress everything, even not deliver elements via network,

class="nomobile-narrow"

may be implemented by CSS

@media
only screen and (max-width:720px)  {
   .nomobile-narrow {
      display:none !important;
	  }
}

While dedicated to mobile the same consideration goes for desktop, but small windows are not frequently expected there.

Event Timeline

Jdlrobson subscribed.

My opinion is utility classes like this in software for content are ever a good idea. In MobileFrontend we've been trying to move away from such styles and encourage TemplateStyles adoption. The removal of elements marked "nomobile" is a feature. ".nomobile-narrow" would require adoption by editors in content and if not adopted would just add additional unnecessary bloat to pages.

MobileFrontend did add an "hlist" utility class to share styles with templates but this was very poorly received as it took control away from editors over styling.

NOTE: On desktop domain Minerva .nomobile behaves exactly like the proposed .nomobile-narrow - it is never removed from the HTML - this is because MobileFrontend does that not the Minerva skin. In future maybe we should consider not removing such markup from the HTML. I would therefore advise that you can create Template:Utility/mobile.css with this rule and then use it inside any template using template styles if you wish.

In my home wiki I could help myself: Template:WikiLayout/styles@dewiki

  • However, that goes for my own wiki only.
  • I am heading for a global solution for 1000 WMF wikis and outer space.
  • That is what Phabricator is for.

“encourage TemplateStyles adoption”

  • That is putting quite a lot of efforts on source editors.

Please compare:

[[File:note.png|class=nomobile-narrow|16px]] NOTE:

with

<templatestyles src="WikiLayout/styles.css" />
[[File:note.png|class=deviceProperty-not-narrow|16px]] NOTE:

The latter is local only, my proposal could be exchanged among wikis.

Right now, T231160 would probably cause some trouble if we were to call such a class nomobile-narrow. But I hope that will be fixed in the near future...

I think there's a case to be made for such a class and for styles that can be used across all wikis that apply to templates but it's out of scope for MobileFrontend. It could work in a similar way to how WikimediaMessages provides message customisations for Wikimedia sites. e.g. WikimediaStyles might be the name of the extension. I also wonder if TemplateStyles would be a good place to provide those details.

Such an extension would also allow us to offload the existing Minerva hacks and associated config flag https://github.com/wikimedia/mediawiki-skins-MinervaNeue/blob/master/README.md#wgminervaapplyknowntemplatehacks.

Jdlrobson renamed this task from Introduce class for narrow (mobile) devices to Allow projects to define global helper classes e.g. nomobile-narrow across all templates.Jun 23 2020, 9:32 PM
Jdlrobson renamed this task from Allow projects to define global helper classes e.g. nomobile-narrow across all templates to Allow projects to define helper classes/mixins e.g. nomobile-narrow across all templates.

I would personally like if it were easier to target mobile-friendly skins like Minerva and Timeless with one selector rather than two in TemplateStyles, so a body.skin-mobile-friendly might be nice, or something like that. See also Main page template styles. I don't think that's what PC is looking for, but would still make my life easier. :)

At least there should be a global dictionary for selectors, even if no CSS implementation is delivered.

  • German Wikikipedia calls that thing .deviceProperty-not-narrow, another Wiki might define .nohandheld and a third one is using .nosmallmobile as selector.
  • This is affecting exchangeability of templates, gadgets and page programming components.
  • If there is no global CSS implementation distributed on all pages, every project which likes to use that can specify an implementation by site CSS (MediaWiki:Mobile.css or via MediaWiki:Minerva.css) or TemplateStyles on pages where such elements occur.
  • The target is to focus on the main track of the story, if there is a lack of space on a small device. Decorative nice images, the joke of the day and distracting gimmicks shall be omitted. Looking at https://www.mediawiki.org/wiki/MediaWiki the photo is superfluous and does not solve the problem of the visitor, show it on desktop and tablet, but do not fill the entire first screen of a handheld.

@Izno: Regarding en:WP:Main Page/styles.css – At a first glance I wonder how that will work:

body.skin-minerva #mp-welcomecount,

All things are supposed to be descendants of .mw-parser-output but I am afraid <body> is not. That has been taken from some site CSS recently, where it works. It does not go for TemplateStyles.

However, the proposal would make your life easier since you may equip elements in page which are less important with the class in question.

@Izno: Regarding en:WP:Main Page/styles.css – At a first glance I wonder how that will work:

body.skin-minerva #mp-welcomecount,

All things are supposed to be descendants of .mw-parser-output but I am afraid <body> is not. That has been taken from some site CSS recently, where it works. It does not go for TemplateStyles.

Incorrect. Please review the extension documentation:

To target styles based on skins, use a selector such as body.skin-vector .myClass; specification of the body element is required and must be followed by a descendant combinator (i.e. the space). Other classes on the body or html elements may be targeted in the same manner. 1.32+

This was specifically implemented in T197617: TemplateStyles should be able to add skin-specific CSS. You are welcome to test that it does in fact work on the main page in Minerva or Timeless.

Anyway, I think your request is declined T203967: TemplateStyles should allow for "mobile-only" styles and I think this should be declined accordingly.

I would personally like if it were easier to target mobile-friendly skins like Minerva and Timeless with one selector rather than two in TemplateStyles, so a body.skin-mobile-friendly might be nice, or something like that. See also Main page template styles. I don't think that's what PC is looking for, but would still make my life easier. :)

Both these skins add <meta name="viewport" content="initial-scale=1.0, user-scalable=yes, minimum-scale=0.25, maximum-scale=5.0, width=device-width"/> which means the skin adapts to the viewport - which I think is what you need - i wonder if a class skin-responsive could be added along with that to solve this particular issue.

i wonder if a class skin-responsive could be added along with that to solve this particular issue.

In case I wasn't clear,

so a body.skin-mobile-friendly might be nice

Was that proposal. :D

@Izno sorry I misunderstood that bit. Created T258290 to capture that. I think that is pretty actionable.

Jdlrobson claimed this task.

@Izno from next week the class body.skin--responsive can be used to target all responsive skins (Minerva, Timeless and Monobook running in responsive mode!)