Page MenuHomePhabricator

[EPIC] Image: Add Image component to Codex
Closed, ResolvedPublic

Assigned To
Authored By
Sarai-WMDE
Aug 3 2022, 6:09 PM
Referenced Files
F57775785: Image.zip
Dec 3 2024, 7:08 PM
F57775793: image.png
Dec 3 2024, 7:08 PM
F57775788: image.png
Dec 3 2024, 7:08 PM
F57775791: image.png
Dec 3 2024, 7:08 PM
F57775786: image.png
Dec 3 2024, 7:08 PM
Restricted File
Nov 19 2024, 5:42 PM
F57721679: ImageContainer.webm
Nov 19 2024, 2:59 PM
F36961746: Captura de pantalla 2023-04-24 a las 14.01 1.png
Apr 24 2023, 12:03 PM

Description

Background

Image component needs to be implemented in Codex.

Description

The Image component is used to display visual content (e.g. photos, illustrations). This component is used to provide visual context to the content. We can use images as individual components in the interface or to provide visual context in other components (e.g. cards, dialogs).

User stories

  • As a designer and developer, I want to be able to reuse an image component to support the meaning or illustrate content in layouts and components.

History

We've considered the introduction of image as a core Codex component. This wasn't listed as part of the big design inventory of the Wikiverse performed by the Product design team, though.

Known use cases

Images within the interface
Captura de pantalla 2023-04-19 a las 17.03.png (710×1 px, 446 KB)
Captura de pantalla 2023-04-19 a las 17.04-2.png (704×1 px, 855 KB)
Captura de pantalla 2023-04-19 a las 17.04.png (706×1 px, 1 MB)
Captura de pantalla 2023-04-19 a las 17.04-1.png (703×1 px, 1 MB)
Captura de pantalla 2023-04-19 a las 17.08-1.png (700×1 px, 451 KB)
Captura de pantalla 2023-04-19 a las 17.47 1.png (702×1 px, 272 KB)
Captura de pantalla 2023-04-19 a las 17.08-2.png (704×1 px, 379 KB)
Captura de pantalla 2023-04-19 a las 17.08.png (704×1 px, 938 KB)
Images as part of other components
Captura de pantalla 2023-04-19 a las 17.11 1.png (704×1 px, 137 KB)
Portrait card with image
Captura de pantalla 2023-04-19 a las 17.10 1.png (682×1 px, 271 KB)
Image within a popup
Captura de pantalla 2023-04-24 a las 14.01 1.png (702×1 px, 429 KB)
Thumbnail with image
Desktop - Onboarding - first step example.png (646×762 px, 49 KB)
Onboarding Dialog with image T332767

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:

  • Design style guide: -
  • OOUI: -
  • Vue: -

External libraries:


Codex implementation

Component task owners

Open questions

  • What does the image need to do from tech standpoint, lazy loading, etc?
  • Component's properties:
    • Aspect ratios: they will be implemented as components properties
    • Image customization (e.g. left, right, center): it will be implemented in a separated ImageContainer component
    • Option to provide a specific px size (e.g. VE image settings): we will not specify the px at the moment

Design spec

Anatomy
Style
  • Image: it will not have any style applied
  • Placeholder: it will use background-color-interactive-subtle and color-placeholder in the icon
Interaction

The following states will be implemented in the Image component:

  • default
  • loading (it will use the skeleton once it's implemented in T311874)
Documentation

A configurable demo will be included with the component's properties and states:

  • Image's content: Image with photo / Placeholder
  • Aspect ratios: No/Yes (when yes, we should view the different aspect ratios options)
  • Loading: a toggle switch will display/hide the loading state
  • LTR/RTL: the RTL option will not mirror the image component in this case

Apart from the configurable demo, we will include other demos with:

  • Image component using an illustration
  • Placeholder: we will need to explain in the demo that the placeholder's icon will be scaled with the width of the placeholder as defined in the Figma spec

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

  • List all parts of the MVP scope for this component

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

  • If applicable, list future work that should be done for this component after the MVP is implemented as part of this task. You should open new, standalone tasks for all future work.

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
AnneT raised the priority of this task from Lowest to Low.Mar 1 2023, 4:59 PM
bmartinezcalvo renamed this task from [Needs discussion] Design and implement Image component to Image: Add Image component to Codex.Apr 24 2023, 11:41 AM
bmartinezcalvo updated the task description. (Show Details)
bmartinezcalvo subscribed.
Restricted Application raised the priority of this task from Low to High. · View Herald TranscriptApr 24 2023, 4:53 PM
ldelench_wmf set the point value for this task to 1.Apr 24 2023, 4:53 PM

FWIW, Codex thumbnails use background image styles, not actual <img> elements. If we want Thumbnail to use the Image component internally, we would either need to change that in the Thumbnail or support use of background images in the Image component.

I wanted to add a few implementation-specific notes which might impact design of this component as well.

  • I'd recommend limiting the initial MVP version of this component to <img> elements (no CSS background-image use yet). The img element provides onload and onerror events that we can use to implement lazy-loading and fallback behavior; images loaded via CSS don't provide the same interface (though we may be able to figure out workarounds later).
  • Modern CSS already provides pretty sophisticated controls for control of image aspect ratio, cropping, and positioning. Rather than duplicating a lot of this functionality ourselves within the component, I think we should just expect the user to style image components using these CSS properties. We could still provide design tokens or LESS mixins for commonly used image styles (including pre-defined aspect ratios).
  • I think that this v-lazy-image component on GitHub is a good example of the kind of thing we'll want to build in Codex – this component is very simple and style-free; the component controls the loading and fallback behavior but not much else, with the expectation that styling should come from the user.

So maybe we need to build two different things here:

  • A basic CdxImage component similar to v-lazy-image that manages loading/fallback state for images using the IntersectionObserver API (where the user provides a src or srcset, a fallback src, and intersection observer options); this component would have very little additional styling on its own
  • Some tokens and mixins to provide consistent values for one or more style properties – aspect ratio, border, CSS transitions/animations, background color during fallback state, etc.

In the future we could build more specific components on top of the base Image component that are more opinionated in terms of appearance & behavior.

During the last Eng/Design sync we decided that aspect ratios will not be defined as tokens but they will be included in the Image component as component's property. So I've created the Figma spec sheet accordingly with this and adding the following:

  1. Aspect ratios (16:9, 3:2, 4:3, etc.) have been added as component's property
  2. Image component will have 2 states: default and loading (using the Skeleton once it's implemented in T311874)
  3. If Image component doesn't have an image uploaded, it will display the placeholder
  4. Placeholder icon will scale from a minimum size (12px) to a maximum size (40px). More details in the spec.
  5. RTL behavior: the image component will not be mirrored but the assets for the image component will be created/exported in both LTR/RTL in some cases (e.g. illustrations)

Apart from the image component, we will create an ImageContainer or Figure in the future, where we will implement the image position within a container, the image's container borders and caption (image text). This will be done in a separate task. I've defined some of the aspects in this other spec to grab the differences between Image and ImageContainer.

Let me know your feedback about all this.

There is one open question to solve in the task before implementing the Image component: Do we want an option to provide a specific px size in the image? (use case from VE image settings)

There is one open question to solve in the task before implementing the Image component: Do we want an option to provide a specific px size in the image? (use case from VE image settings)

During the last Engineering/Design sync we decided to move forward with no option to specify px. So this task is Ready for development.

CCiufo-WMF removed the point value 1 for this task.
CCiufo-WMF raised the priority of this task from High to Needs Triage.Feb 15 2024, 9:01 PM

Change #1091815 had a related patch set uploaded (by Abaris; author: Abaris):

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

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

Change #1091840 had a related patch set uploaded (by Abaris; author: Abaris):

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

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

In the task specifications for the ImageContainer component, there is no explicit mention of how the container’s width and height should be handled. While implementing the component, I used container-specific width (380px) and height (230px) to define the dimensions.

It would be helpful to clarify whether the container’s width and height should:

  1. Be inherited from the Image dimensions,
  2. Be set explicitly through ImageContainer props (as I have done in my implementation), or
  3. Be fully customizable through user-defined styles.

Could this be addressed in the design spec or during development? Thank you! You can see my current work in the video below.

{F57721910}

@bmartinezcalvo I'd like to add an example to the Image demo page of an illustration that's different in RTL and LTR. Could you please export images that we can use for this, like the ones you used in the Figma spec?

El T314514#10376294, @AnneT escribió:

@bmartinezcalvo I'd like to add an example to the Image demo page of an illustration that's different in RTL and LTR. Could you please export images that we can use for this, like the ones you used in the Figma spec?

The idea is that we should create the LTR and RTL version for those illustrations communicating any of the mirroring recommendations from the Bidirectionallity guidelines (e.g. when communicating direction, horizontal orientation, or navigation).

image.png (360×640 px, 20 KB)
image.png (360×640 px, 12 KB)
image.png (360×640 px, 20 KB)
image.png (360×640 px, 12 KB)
LTRRTL

So I've included illustrations examples for both cases:

  • Map: it should not be mirrored, so the same illustration is used for both LTR and RTL.
  • Article: it should include the mirror version since the reading direction is different in LRT and RTL.

Change #1091815 merged by jenkins-bot:

[design/codex@main] Image: Add WIP Image and component

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

Thank you for working on this @Anne. Listing here some feedback collected from yesterdays DST design sync in case we want to apply this feedback in future versions of Image:

  • When the Image is loading, a skeleton would be more appropriate than the placeholder.We could complete this once the Skeleton is implemented in T311874.
  • Evaluate the need of an error state. In case we need an error in Image, the error state should always provide an error message explaining how to fix that.
  • We will need to define how width, height, and aspect ratios should interact.
  • We will need to evaluate if we want to use the border-radius-base (2px) to style the images radios as in other components.
  • We will need to include some of the decisions applied in Thumbnail:
    • Probably use a subtle border to avoid white images to merge with the background of the page
    • Set background-color-base-fixed so PNG images are visible in dark mode.
  • Evaluate if we want to tokenize available options for objectFit and objectPosition to avoid unnecessary complexity.
CCiufo-WMF renamed this task from Image: Add Image component to Codex to [EPIC] Image: Add Image component to Codex.Dec 10 2024, 11:46 AM
CCiufo-WMF triaged this task as Low priority.
CCiufo-WMF removed a project: Patch-For-Review.
CCiufo-WMF moved this task from Later to Next on the Design-System-Team (Roadmap) board.

Change #1101943 had a related patch set uploaded (by LWatson; author: LWatson):

[mediawiki/core@master] Update Codex from v1.17.0 to v1.18.0

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

Change #1101943 merged by jenkins-bot:

[mediawiki/core@master] Update Codex from v1.17.0 to v1.18.0

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

CCiufo-WMF raised the priority of this task from Low to Needs Triage.Jan 24 2025, 7:24 PM
CCiufo-WMF moved this task from Next to Later on the Design-System-Team (Roadmap) board.
CCiufo-WMF moved this task from Upcoming to Backlog on the Codex board.
CCiufo-WMF triaged this task as Medium priority.
CCiufo-WMF moved this task from Later to Now on the Design-System-Team (Roadmap) board.
CCiufo-WMF updated Other Assignee, added: bmartinezcalvo.
CCiufo-WMF removed a subscriber: Sarai-WMDE.
lwatson changed the status of subtask T381863: Image: Take out of WIP from Stalled to In Progress.Jun 17 2025, 5:05 PM