Page MenuHomePhabricator

Label: Add Label component to Codex
Closed, ResolvedPublic3 Estimated Story Points

Description

Background

Description

Describes the information requested by a given form field

User stories

As a form user, I want clear information about every form field.

As a screen reader user, I want a semantic label attached to every form field.

History

OOUI has LabelWidget (which inherits LabelElement). We may want to create a standalone Label component, consider a composable that will take in label text and output a semantic label to be used within input/control components, or both.

Known use cases

All form fields should use a label, either as part of a Field component or as a composable inside the input/control component.

Captura de pantalla 2023-05-31 a las 21.34.25.png (526×1 px, 26 KB)

Existing implementations

These artifacts are listed for historical context. The figma spec, linked below, is the source of truth for the new component.

Wikimedia community:

External libraries:

  • Vuetify: labels are part of form input/control components
  • Buefy: part of the Field component

Codex implementation

Component task owners

Open questions

  • Will label be used as text in other components? - Label component will be used on top of Form items while label item will be used as text on Checkboxes, Radios and ToggleSwitches
  • Will label be customized to Bold and Regular? - Yes, Label as bold by default, with ability to Regular in certain cases
  • Will be the description part of the label? - Yes, it needs to be so we can include it in the <legend>, which is needed for screen readers

Design spec

Anatomy
  • Label section will include the following elements:
    • Start icon (it will be optional)
    • Label (it will be always displayed)
    • "Optional" indicator when the form field is not required (it will be optional)
    • Tooltip. It will be created with a small 24px icon-only quiet button (it will be optional)
  • Description will be include bellow the label to use when the user needs to provide extra info about the label
Style
  • Label style will be Bold as default and it could be customized to Regular for specific cases
Interaction

The following states will be implemented:

  • Default
  • Disabled
Documentation

Configurable demo will include the following:

  • startIcon: the user will be able to type in a text input the icon they want to display
  • optional field
  • tooltip
  • description: the user will be able to type in a text input the text they want to display in the demo
  • disabled: the user will be able to select the disabled state with a toggle switch
  • Reading direction: LTR/RTL will be selected with radios

Other standalone demos could include:

  • A label component displaying the description with a link within the text
  • A label component where the text style is Regular, explaining that the Bold style will be the base style but we will use Regular if needed for specific cases
  • The use of the label component combining it within a Form Field component

Acceptance criteria

Minimum viable product

This task covers the minimum viable product (MVP) version of this component. MVP includes basic layout, default states, and most important functionality.

MVP scope

  • Label section will include the following elements:
    • Start icon (it will be optional)
    • Label (it will be always displayed)
    • "Optional" indicator when the form field is not required (it will be optional)
  • Description will be include bellow the label to use when the user needs to provide extra info about the label

Design

  • Design the Figma spec sheet and add a link to it in this task
  • Update the component in the Figma library. This step will be done by a DST member.

Code

  • Implement the component in Codex

Future work

  • Tooltip. It will be created with a small 24px icon-only quiet button (it will be optional). See T338282
  • Label's loading state. It will be created once Skeleton is implemented. See T339076

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
STH subscribed.

Flagged for potential collaboration with WMDE in Q2.

AnneT renamed this task from Add Label component to Codex to Label: Add Label component or composable to Codex.Feb 21 2023, 8:20 PM
AnneT removed a project: Epic.
AnneT updated the task description. (Show Details)
AnneT removed a subscriber: STH.
AnneT changed the task status from Open to In Progress.May 22 2023, 5:57 PM
AnneT claimed this task.

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

[design/codex@main] [wip do not merge] Field and Label

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

AnneT renamed this task from Label: Add Label component or composable to Codex to Label: Add Label component to Codex.May 29 2023, 11:44 AM
bmartinezcalvo added a subscriber: AnneT.

Moving this task to In Design to define the spec and explore the open questions to solve.

The open questions listed in this task have been solved during our last Eng/Design sync and the Label component's spec sheet has been completed so the task is Ready for development.

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

[design/codex@main] Label: Add WIP Label component

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

Change 923428 abandoned by Anne Tomasevich:

[design/codex@main] [wip do not merge] Field and Label

Reason:

Real patches have been opened

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

Change 927264 merged by jenkins-bot:

[design/codex@main] Label: Add WIP Label component

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

@AnneT design sign-off done. Listing here some small things to update:

  1. Text should be 16/22 so it means the line height should be @line-height-small in all Label, Optional and Description
  2. Label style could be Regular in some cases as specified in the spec. Could we include a standalone demo?
    Captura de pantalla 2023-06-12 a las 16.44.53.png (822×2 px, 149 KB)
  3. Description could include a link. Could we add another standalone demo with this example?

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

[design/codex@main] Label: Change line height and add a rich text demo

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

  1. Text should be 16/22 so it means the line height should be @line-height-small in all Label, Optional and Description

Done!

  1. Label style could be Regular in some cases as specified in the spec. Could we include a standalone demo?

This is built into the Field component - when there are nested fields, the nested fields' labels will be regular instead of bold (demo).

We discussed at a previous design/eng sync that we don't typically add configuration for things that can easily be overridden in CSS - is it sufficient to support the case of nested fields as we currently do, and then just assume that developer users can set the font weight to regular if they have other cases where they need to do so?

  1. Description could include a link. Could we add another standalone demo with this example?

Done!

Change 929420 merged by jenkins-bot:

[design/codex@main] Label: Change line height and add a rich text demo

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

  1. Text should be 16/22 so it means the line height should be @line-height-small in all Label, Optional and Description

Done!

@AnneT the line height is still 25.1, it should be 22px @line-height-small

Captura de pantalla 2023-06-13 a las 13.34.00.png (500×892 px, 92 KB)

  1. Label style could be Regular in some cases as specified in the spec. Could we include a standalone demo?

This is built into the Field component - when there are nested fields, the nested fields' labels will be regular instead of bold (demo).

We discussed at a previous design/eng sync that we don't typically add configuration for things that can easily be overridden in CSS - is it sufficient to support the case of nested fields as we currently do, and then just assume that developer users can set the font weight to regular if they have other cases where they need to do so?

Ok, I agree label should be Regular just when nested fields with a bold title. So let's leave it as it is.

  1. Description could include a link. Could we add another standalone demo with this example?

Done!

Thank you!

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

[design/codex@main] Field, Label: Set smaller line height

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

I'm checking the line height was fixed to @line-height-xx-small in the last patch so moving the task to Pending Release.

Change 929722 merged by jenkins-bot:

[design/codex@main] Field, Label: Set smaller line height

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

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

[design/codex@main] Field, Label: Move from WIP components to lib

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

Change 929794 merged by jenkins-bot:

[design/codex@main] Field, Label: Move from WIP components to lib

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

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

[mediawiki/core@master] Update Codex from v0.12.0 to v0.13.0

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

Test wiki created on Patch demo by ATomasevich (WMF) using patch(es) linked to this task:
https://patchdemo.wmflabs.org/wikis/2c8b23bc31/w

Change 931666 merged by jenkins-bot:

[mediawiki/core@master] Update Codex from v0.12.0 to v0.13.0

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

Test wiki on Patch demo by ATomasevich (WMF) using patch(es) linked to this task was deleted:

https://patchdemo.wmflabs.org/wikis/2c8b23bc31/w/