Page MenuHomePhabricator

Follow up work for infoboxes / hatnotes
Open, MediumPublic

Description

Background

In T113101 we enabled responsive image behaviour in Vector 2022. This also enabled styling rules for infoboxes and hatnotes that was intended to improve responsive behaviour of the Vector 2022 skin with new font sizes and smaller breakpoints by applying existing styles on Minerva that we later reverted in T367462. These styles mix visual changes and behavioural changes, so we'll want to more carefully through the lens of the feedback provided by the community and the goals we need to meet.

User story

As a reader using larger font sizes and/or lower screen resolutions, I want infoboxes and hatnotes to adapt to my browser.

Requirements (TODO)

TODO

BDD

  • For QA engineer to fill out

Test Steps

  • For QA engineer to fill out

Design

NOTE: This list defines the current behaviour of the styles. It should be revised to reflect what we actually want to deploy and why :-)

Infobox

  • Apply a max width of 320px to infoboxes
  • At lower resolutions the infobox should take up the full width of the page and have no margins by switching the table to use flex box. Note: We discovered this causes some issues with infoboxes that have class infobox-table
  • Changes font size from 88% to 90%
  • Adjusts border color and background color (that can be overriden on wiki)
  • Adjusts padding of captions
  • table column and heading columns get increased padding and bottom border to separate lines
  • text is aligned to the left (right in RTL)
  • disables floating at lower resolutions
BeforeAfter
Screenshot 2024-06-14 at 7.31.46 AM.png (1×992 px, 388 KB)
Screenshot 2024-06-14 at 7.32.06 AM.png (1×998 px, 244 KB)
Screenshot 2024-06-14 at 7.31.29 AM.png (1×2 px, 900 KB)
Screenshot 2024-06-14 at 7.31.01 AM.png (1×2 px, 932 KB)

Related and relevant feedback

  • "What just happened? Infoboxes and Hatnotes on Vector 2022 looks similar to that on Minerva"
  • Just my 2¢ I'm working on Præsidenten fra Nordvest and the infobox looks so strange with the width being the size of the image. It looks inconsistent with other films like Batman (1989 film) (which I presume the width maxes out when there's a line break in one of the cells
  • "Perhaps, although the infoboxes seem thinner altogether, like there is simply less room for text overall."
  • "Are the borders suppose to be missing? When I first saw it, I thought the change was to improve ascetics"
  • "dividers can be either gaps or lines – there is absolutely no need to use both approaches together, as this consumes valuable space and adds visual noise at the same time without producing any benefits."

Some problems to consider as exposed by roll out

Hatnote

  • Takes up full screen
  • Has a background to distinguish it from other elements in the page.
  • Sets font size in rems so it doesn't scale with font size
  • Makes all links inside hatnotes blue
BeforeAfter
Screenshot 2024-06-14 at 7.29.40 AM.png (532×972 px, 83 KB)
Screenshot 2024-06-14 at 7.34.54 AM.png (668×1 px, 167 KB)
Screenshot 2024-06-14 at 7.29.59 AM.png (454×2 px, 136 KB)
Screenshot 2024-06-14 at 7.30.13 AM.png (424×2 px, 130 KB)

Examples: https://en.wikipedia.org/wiki/Special:WhatLinksHere/Template:Hatnote

Related and relevant feedback

  • "The text size does not increase with selecting larger text from the appearance menu. "
  • "Combination of tiny font and pale blue background is making section hatlinks almost illegible and major eyestrain on my laptop."
  • "Not keen on the new look at all, this is something that should have been agreed."

Acceptance criteria

  • Any styles restricted to skin-minerva should be moved to skinStyles e.g. we should add support for skin styles in WikimediaMessages.

Communication criteria - does this need an announcement or discussion?

This will need to be communicated to editors to avoid a repeat of T367462.

Rollback plan

  • What is the rollback plan in production for this task if something goes wrong?

This task was created by Version 1.0.0 of the Web team task template using phabulous

Note about container queries

Something like this is likely needed for making our content responsive:

.mw-body-content {
  container-name: article-content;
    container-type: inline-size;
}

@container article-content (inline-size < 700px) {
  .infobox { 
    float: none !important;
    margin: auto;
  }
}

Event Timeline

Jdlrobson updated the task description. (Show Details)

Regarding hatnotes:

  • I had started a discussion on wiki about what to do about the the mobile styles a few months ago which also did some history digging for motivations and actual original design (to whit, aesthetics mostly). https://en.wikipedia.org/wiki/Module_talk:Hatnote#Mobile_styling There is a response there, but otherwise more crickets than not. There are more delta(s) listed there between original intent and currently displayed hatnotes on en.wp.
  • I didn't capture specific comments from this deployment (yet?).
  • Font size setting here seemed like one of the biggest problems.

Regarding infoboxes:

  • As @TheDJ noted elsewhere, the current infobox.less mixes aesthetic choices with the necessities of mobile design (namely, full width infobox + overriding floats and things). Someone should probably research the basis for the aesthetics.
  • I do not know if it is worth splitting things. I think supporting a deployment again would require a bifurcation here, but at a minimum the infobox widths and such probably need to be behind a max-width query.
  • Which would also make the /* Tablet specific styling */ block unnecessary (well, it would, after either making Common.css load everywhere or addition to Minerva.css depending on the relevant config option, which is a fairly mechanical fix...). This block should probably also have a max-width and let natural styles etc. work above that.
  • Timeless pokes at these things and shouldn't but at least is (not|a lot less opinionated) about the aesthetic.
  • I do know that I don't quite get why we think flex is necessary. Table rows don't need wrapping and the flex on the cells is marked as nowrap. So what is this doing here? (Answering this question is research.)

(I'm still working on Common.css on mobile, which is marginally relevant at least for en.wp for infobox things since we'll need to contend with the width set in Common.css in what is likely to be a width query.)

  • I do know that I don't quite get why we think flex is necessary. Table rows don't need wrapping and the flex on the cells is marked as nowrap. So what is this doing here? (Answering this question is research.)

If i remember correctly, the flex dealt with multi columns (3 or 4 column layouts are quite common in certain infoboxes (military conflict stats?)) in rows, where the cells were too wide to fit their contents.

Changes font size from 88% to 90%

I would strongly suggest, instead of hard-coding arbitrarily chosen numbers for various elements, to pick several distinct font sizes, define CSS classes for them (the standard "..., small, normal, large, ..." should be preferred and probably sufficient), and use them throughout. Besides producing a more consistent (and easily user-modifiable) look, this will also help avoid problems with nested templates, where each of them tries to set its font size relative to its parent, eventually producing quite randomly sized fonts and requiring dirty hacks to bring them to something reasonable and avoid violating accessibility guidelines (I remember at least two cases where this was causing problems in infoboxes, so it's exactly on-topic and not hypothetical).

And to change margins and paddings to font units (preferably also through global classes) instead of hard-coding arbitrary values in pixels, again for consistency and maintainability.

Regarding the before/after comparison, I see that the infobox has just lost 1.5 lines without any gain in readability, plus all (for narrow screen) or some (for wide) article text has been lost. Not an improvement from any perspective.

Instead of breaking usability for everyone, it would be more productive to suggest mobile users to use their devices in landscape orientation. (Really. Even reading regular texts on e-ink books is more comfortable in landscape mode, as this makes its width similar to a normal paper book. And webpages are anyway scrolled vertically, so for viewing them, a reduced screen height is much less important than the screen width.)

I considered writing a patch, but instead i'm leaving some comments about my insights so that team can take that into account and make their own decisions.

// FIXME: [T367519] This is temporarily restricted to .skin-minerva to provide a short term fix for T367462.
// The expectation is that this CSS will be revised to exclude the .skin-minerva class in future,
// or limited to the Minerva skin via a skinStyle.
body.skin--responsive.skin-minerva .mw-parser-output {
	.hatnote,
	.dablink,
	.rellink {
		padding: 5px 7px;
		color: @color-subtle;
		font-size: unit( 13 / 16, rem );
		background-color: @background-color-interactive-subtle;
		margin-bottom: 1px;
		overflow: hidden;
		a {
			color: @color-progressive;
		}
	}
}

I'd consider all of the above as stylistic choices.. As such I do not see why we would apply this to skins other than minerva (at this time), but we can easily do so in the future

@import 'mediawiki.skin.variables.less';

// FIXME [T367519] This is temporarily restricted to .skin-minerva to provide a short term fix for T367462
// The expectation is that this CSS will be revised to exclude the .skin-minerva class in future,
// and/or appropriate bits limited to the Minerva skin via a skinStyle.
body.skin--responsive.skin-minerva .mw-parser-output {
	.infobox {
		
		// this block, scope to: max-width: @max-width-breakpoint-mobile
		// Unfloat tables and infoboxes
		// A lot of templates introduce floating and horizontal margins as inline styles
		// Some of this is also already set for table elements, but not all .infobox are table elements !
		// This is an **aggressive** override of the table layout of the <table> element to avoid them overflowing the viewport
		// (tables size to content, instead of sizing to parent)
		float: none !important; // often an inline style, so important
		margin-left: 0 !important; // often an inline style
		margin-right: 0 !important; // often an inline style
		width: 100% !important; //  this is often set as inline style
		max-width: 100% !important; // this is sometimes set as inline style
		// If we want (some of) this for tablet/desktop situations, i'd consider making a second scoped block where these are set without !important (esp initially)
		// Esp. the max-width:320px from all the way below might be useful in such a block


                // this block is stylistic. separate it out and possibly initially limit to minerva
		font-size: 90%; // stylistic
		position: relative; // unsure ??
		border: @border-width-base @border-style-base @border-color-muted; //stylistic
		margin-bottom: 2em; // stylistic, but important that we have enough spacing for readability, when we are not floating !, so maybe move into the scoped block for mobile ?
		color: @color-base; // stylistic
		background-color: @background-color-interactive-subtle; // stylistic

		// this block, scope to: max-width: @max-width-breakpoint-mobile
		// Alignment and auto columns for narrow situations. 
		// This undos the tables'' grid layout. As most content is just (two or three) columns, it avoids strict 50% - 50% columns
		// It provides more flexibility for the cells to size to content without overflowing. If some cells are too wide it changes from an equal column layout to more of a brick pattern.
		display: flex; // override default display:table behaviors
		flex: 1 1 100%; // not 100% sure if we need this... This might be for infoboxes nested inside infoboxes ?????
		flex-flow: column nowrap; // we don't want table rows to wrap into new columns

		caption {
			padding: 10px 10px 0; // stylistic
			text-align: center; // I think this is an override for Minerva's default of left aligning captions
		}

		th,
		td {
			vertical-align: top; // stylistic, but possibly emulates a table default for flex columns ???
			border: 0; // emulate border collapse for flex columns
			border-bottom: @border-width-base @border-style-base @border-color-muted; // emulate border collapse for flex columns
			padding: 7px 10px; //stylistic
		}

                // For the flex columns, so should be in that same scope
		// this applies to nested tables.. not 100% sure it should...
		tbody > tr > td,
		tbody > tr > th {
			flex: 1 0;
		}

                // Flex columns, Single cell rows should be full width.
		td:only-child,
		th:only-child {
			width: 100%;
		}

		// Flex columns
		// we don''t want borders because there is no border-collapse in flex
		tr:last-child th,
		tr:last-child td {
			border: 0;
		}

		// Flex columns, overriding the display:table behaviors
		// but only for direct children of infobox, not nested tables
		& > tbody,
		& > caption {
			display: flex;
			flex-flow: column nowrap;
		}

                // Flex columns, Rows should be full width and not wrap
		// but only for direct children of infobox, not nested tables
		& > tbody > tr {
			min-width: 100%;
			display: flex;
			flex-flow: row nowrap;
		}
	}


	// Hack to assign info boxes properly when using RTL languages on LTR wiki
	// Possibly the following can be replaced with flex alignment start properties ??
	.mw-content-ltr .infobox {
		/* @noflip */
		text-align: left;
	}

	// Hack to assign info boxes properly when using LTR languages on RTL wiki
	.mw-content-rtl .infobox {
		/* @noflip */
		text-align: right;
	}
}

// We mostly don't need this when we invert the above rules
/* Tablet specific styling */
@media all and ( min-width: @min-width-breakpoint-tablet ) {
	body.skin-minerva.skin--responsive .mw-parser-output {
		// Float infoboxes to the right of the page
		.infobox {
			margin: 0.5em 0 1em 35px !important;
			// Note this is fixed to ensure that we leave enough space for the sections to the infoboxes left
			// FIXME [Templates]: Inline styles force us to use !important
			max-width: 320px !important; // At most, set this (without important) as a stylistic .infobox rule for all skins.
			width: auto !important;
			float: right !important;
			clear: right !important;
		}
	}
}

There shouldn't be any stylistic rules in infobox.less, the additional padding was always breaking tables on minerva causing weird look and overflows when used with fixed inline width. Time to get rid of it and let TemplateStyles do it where wanted.

There shouldn't be any stylistic rules in infobox.less, the additional padding was always breaking tables on minerva causing weird look and overflows when used with fixed inline width. Time to get rid of it and let TemplateStyles do it where wanted.

Some stylistic safety nets rules are unavoidable. Like the bottom margin of an infobox, or the fact that we cannot have cell borders, as there is no border collapsing. While templatestyles are nice, they are not universally and correctly used.

and overflows when used with fixed inline width.

That would likely be a reminder then that we also should be setting setting box-sizing: border-box on mobile view....

Thanks for the merge @Jdlrobson.
Pinging @Escargot_rouge (e already have a theme-based concern at frwiki).

I think the design task here is to define the breakpoint (which we should do based on CPL measurements for the wiki font in question), and then the second task is to decide what, if anything, should shift based on that breakpoint.

Jdlrobson added a subscriber: JScherer-WMF.

Container queries

See also T331227 and my comment at T331227#8666726. I'd prefer .mw-parser-output be the container queried since it is also more or less guaranteed to surround content that needs responsiveness. (Contrary to other comment at T330532, I'd prefer to have access to container queries for content because different skins have different breakpoints and container queries would make the content breaks consistent, meaning we can ignore how many sidebars the skins have, and how wide they are.)

I'd prefer .mw-parser-output be the container queried since it is also more or less guaranteed to surround content that needs responsiveness.

FWIW I didn't use mw-parser-output as it seemed to break display on certain pages e.g .https://ru.wikipedia.org/wiki/%D0%A7%D0%B5%D0%B1%D0%BE%D0%BA%D1%81%D0%B0%D1%80%D1%81%D0%BA%D0%B8%D0%B9_%D0%BA%D1%80%D0%B5%D0%BC%D0%BB%D1%8C - I haven't investigated why though.

But yes, this would need support in TemplateStyles (but should work in MediaWiki:Common.css with a general helper class?)

I'd prefer .mw-parser-output be the container queried since it is also more or less guaranteed to surround content that needs responsiveness.

(but should work in MediaWiki:Common.css with a general helper class?)

T331227#8666804 :)

I considered writing a patch, but instead i'm leaving some comments about my insights so that team can take that into account and make their own decisions.

Broad summary: I agree with most of TheDJ here. I have some specifics (qualms) which I will comment about.

	.infobox {
		caption {
			...
			text-align: center; // I think this is an override for Minerva's default of left aligning captions
		}

Yes, I'm also pretty sure that's what that does. There's probably an argument to be made that Minerva shouldn't be deviating on the text alignment of the caption from default browser behavior and probably not deviating from what other skins are doing.

		th,
		td {
			vertical-align: top; // stylistic, but possibly emulates a table default for flex columns ???
			border: 0; // emulate border collapse for flex columns
			border-bottom: @border-width-base @border-style-base @border-color-muted; // emulate border collapse for flex columns
			padding: 7px 10px; //stylistic
		}

The border-bottom is stylistic. There are very few infoboxes on en.wp that have such a border. No comment on border: 0. I am pretty sure vertical-align does not work with flex items...

	// Hack to assign info boxes properly when using RTL languages on LTR wiki
	// Possibly the following can be replaced with flex alignment start properties ??
	.mw-content-ltr .infobox {
		/* @noflip */
		text-align: left;
	}

	// Hack to assign info boxes properly when using LTR languages on RTL wiki
	.mw-content-rtl .infobox {
		/* @noflip */
		text-align: right;
	}

Honestly these blocks should never have been merged upstream because they aren't required for making infoboxes work at small width and even aren't stylistic for Minerva. The additions, made in T161399, should have been made in the relevant Common.css pages of the day that need to deal with these issues, since they also impact non-Minerva skins. They're now very annoying to deal with because of their selectors' specificity.

Jdlrobson-WMF lowered the priority of this task from High to Medium.Apr 1 2025, 9:57 PM