Page MenuHomePhabricator

MenuItem: Icons and thumbnails should top-align with multiple lines of text
Closed, ResolvedPublic

Assigned To
Authored By
Esanders
Apr 20 2022, 2:01 PM
Referenced Files
Restricted File
Jun 22 2022, 10:32 PM
F35224418: Screenshot 2022-06-10 at 11.51.35.png
Jun 10 2022, 11:36 AM
F35224356: Screenshot 2022-06-10 at 11.29.35.png
Jun 10 2022, 11:36 AM
F35223476: image.png
Jun 9 2022, 9:35 PM
F35223460: image.png
Jun 9 2022, 9:35 PM
F35223464: image.png
Jun 9 2022, 9:35 PM
F35204382: Screenshot 2022-06-03 at 21.02.45.png
Jun 3 2022, 7:03 PM
F35203942: image.png
Jun 3 2022, 4:01 PM

Description

Background

When vertically aligning an icon or thumbnail with multiple lines of text, it is best to top align them with the text to improve readability.
Vertically centering breaks down with >2 lines of text, making it harder to associate the visual element with the text.

Screenshot 2022-05-09 at 19.13.50.png (744×574 px, 82 KB)

Goal

We'd like to apply this recommendation in Codex, which for now would require adjusting the MenuItem component.
Icons and thumbnails within menu options are currently center-aligned, which could hinder readability. Instead, both should be top-aligned with their labels:

Screenshot 2022-06-02 at 12.19.51.png (336×1 px, 30 KB)
Screenshot 2022-06-03 at 21.02.45.png (324×1 px, 45 KB)

image.png (748×578 px, 76 KB)

Find relevant design specifications in this Figma frame

Notes:

Simply changing the item's alignment from center to top or baseline makes the icons and thumbnails to not appear correctly center aligned with the menu item label (see screenshots below). We should find a way to correct this. In the designs, we introduced some extra pixels of padding at the top and bottom of the icon, at the top of the thumbnail in order to align them with the MenuItem label's content box.

Screenshot 2022-05-09 at 19.18.47.png (748×578 px, 84 KB)

Screenshot 2022-05-09 at 19.40.52.png (164×1 px, 41 KB)

Event Timeline

Screenshot 2022-05-09 at 19.18.47.png (748×578 px, 84 KB)

Looks good, although in this example I think the icons need to move down a few pixels, so they top align with the actual start of the text:

image.png (748×578 px, 76 KB)

Hey, @Esanders. That's right! The screenshots added in the description were taken from the Codex demo site, after modifying the alignment of the icons via dev tools. I left a note outlining the same issue you noticed:

Just changing the item's alignment from center to top or baseline makes the icons to not appear correctly center aligned with their corresponding labels (see screenshot above). We should find a way to correct this.

But I believe that I should include a proper design displaying the right alignment in the 'Goal' section, instead of leaving that messy screenshot there. Otherwise, it'd be confusing. Thanks!

This Figma branch documents the new icon and thumbnail alignment in MenuItem and is up to be discussed by the Pattern lab team. Att. @bmartinezcalvo and @Volker_E, your feedback would be very much appreciated.

Please note that we should make an exception with thumbnails. These should be treated differently, and stay center-aligned with options' text within MenuItem to avoid creating irregular spacing/ misalignment:

If you have variable height text you will get irregular spacing regardless of using top or centre alignment. I think we should still top align thumbnails, and don't see a particular reason why they should be treated differently from icons. We top-align a thumbnail in VE's link context (although where there is only ever one item):

image.png (159×394 px, 23 KB)

Sarai-WMDE renamed this task from MenuItem: Icons should top-align with multiple lines of text to MenuItem: Icons and thumbnails should top-align with multiple lines of text.Jun 3 2022, 7:03 PM
Sarai-WMDE updated the task description. (Show Details)

Agreed! Thanks @Esanders. Task description was updated.

This Figma branch documents the new icon and thumbnail alignment in MenuItem and is up to be discussed by the Pattern lab team. Att. @bmartinezcalvo and @Volker_E, your feedback would be very much appreciated.

@Sarai-WMDE I added some small comments in Figma but I think in general this branch is all right.

The comments were tackled (thanks as always, Bárbara!) and the branch was merged. I added a link to the relevant design specs in the task's description.

Change 804451 had a related patch set uploaded (by Anne Tomasevich; author: Anne Tomasevich):

[design/codex@main] [WIP] MenuItem: Align icon and thumbnail to top, not center

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

Hi @Sarai-WMDE , shall we add this task to the sprint board?

@Sarai-WMDE you can check out the demo for the WIP patch here

Aligning icons and text to the top gets tricky when you scale font size, and really requires scaling the icon size with font size to maintain perfect alignment. For example, if the icon is always 20px by 20px, and I set a margin-top of 0.25em on the icon to align it with the text, it looks perfect at a 16px font-size:

image.png (356×884 px, 33 KB)

...But then if I scale up the font size to 32px, you can see that the margin-top is not large enough:

image.png (398×942 px, 41 KB)

Obviously this is exaggerated at such a large font-size, but we would be getting a subtle misalignment at, for example, a 14px font size in MediaWiki.

The solution I also used in the Message component was to scale the icon size with font size, which gets you this at 32px:

image.png (344×950 px, 32 KB)

My questions are:

  1. Is this an appropriate solution for icons? My understanding is that we're generally not scaling icons, but it seems like the best solution to me in this instance (as with the Message icon).
  2. What about thumbnails? Scaling up thumbnails would require us to set a relative size for the "search figure," which is the size of the input icon container, the footer icon container, and the thumbnails in TypeaheadSearch (in order to keep those things in alignment with the thumbnails). For what it's worth, thumbnails are relatively sized in the VE link example Ed posted above.

Happy to share my screen and talk about this together at our meeting next Tuesday if that's easier!

AnneT changed the task status from Open to In Progress.Jun 9 2022, 9:35 PM
AnneT claimed this task.

Thanks so much for the detailed explanation and screenshots! Definitely this change makes the issue more apparent, but not scaling icons was going to cause problems whenever font sizes are modified, regardless of alignment

Screenshot 2022-06-10 at 11.29.35.png (298×1 px, 41 KB)

Why would we apply a fixed size to icons and keep them small, when the reason someone would increase their font size might be due to a visual impairment? Applying relative sizes to icons seems key to maintain alignment and legibility, so I'd be all for defining these (together with min-width and min-height) for icons and thumbnails: so, yes to both question on my end. Nevertheless, I'd like to get @Volker_E's point of view here, as I might be disregarding important caveats.

Anne, I'm really sorry, but I just realized that I left something out when I included Thumbnails in the task again. I believe we discussed this during a design/engineering meeting, and that we found it feasible: in lack of a description, thumbnails and menu item labels /titles should be center-aligned to avoid introducing that extra white space under the title. Would this be doable? I guess this might involve changing the approach and maybe using a grid display instead? But I'm not sure.

Screenshot 2022-06-10 at 11.51.35.png (254×1 px, 46 KB)

Happy to jump in a call on Tuesday to discuss all this.

but not scaling icons was going to cause problems whenever font sizes are modified, regardless of alignment

+1, I think having oversized text in a MenuItem is an edge case and requiring a bit of tweaking to maintain a sensible alignment is probably not unreasonable. You would have a similar issue with a MessageWidget in OOUI right now: http://localhost/oojs/ui/demos/?page=widgets&theme=wikimediaui&direction=ltr&platform=desktop

@Sarai-WMDE based on our conversations today, I've updated the patch to remove the margin-top placed on the icon and thumbnail, and adjusted the line-height of the MenuItem content to 1.375 (which is 20/16, same as the design spec). Please take a look at the demos not only for a single MenuItem, but for a menu of MenuItems and TypeaheadSearch, specifically. Let me know if you have any further feedback!

Change 804451 merged by jenkins-bot:

[design/codex@main] MenuItem: Align icon and thumbnail to top with description

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

The changes were reviewed in the MenuItem, Select and TypeaheadSearch demos. The alignment between icon and text was correctly maintained under a combination of conditions: increasing the length of item labels to make them wrap, increasing the size of their font, and/or rounding up line height to 1.4 (see comment below). Browsers used: Safari 15.5, Firefox 101 and Chrome v.102.

The center alignment of thumbnails and single menu item labels was also verified. Thank you, @AnneT!

The task can be signed-off from a design perspective.

Leaving here a couple of notes for visibility:

  • Line-height: Even if the implementation now correctly translates the px line-height used in the designs, this value will be subject to change once typography tokens are ready. Most likely, that new value will be 1.4, which wouldn't have a noticeable impact on alignment thanks to the relative approach to sizing taken in this patch.
  • Thumbnails: Tests made really apparent the need to apply relative sizing to these elements. This way, MenuItems would keep the right proportions and alignment in case fonts are increased.
NBaca-WMF subscribed.

Setting Owner to Desiree for Product Sign-off