Page MenuHomePhabricator

Image Browsing: Port Carousel component to MMV
Open, In Progress, HighPublic3 Estimated Story Points

Description

Following up on this spike T418333, Reader Growth plans to port the Carousel component (horizontal image scroll) to MultimediaViewer (MMV).

New modules:

  • Add mmv.carousel and mmv.carousel.styles modules
  • mmv.carousel depends on mmv.bootstrap so the router and hash navigation are available when the click interceptor runs.
"mmv.carousel.styles": {
    "styles": [ "resources/mmv.carousel/carousel.less" ]
},
"mmv.carousel": {
    "packageFiles": [ "resources/mmv.carousel/index.js" ],
    "dependencies": [ "mmv.bootstrap", "mediawiki.router" ]
}

Acceptance Criteria

  • Add a new carousel module and style module to extension.json: mmv.carousel and mmv.carousel.styles.
  • Register the new carousel modules and config variable ($wgMMVMobileCarousel) in skin.json.
  • Extend getModules() to load mmv.bootstrap when carousel is enabled.
  • Use PHP/server-side rendering to generate the carousel HTML (use HTML::* helpers or mustache template). One way to accomplish this is to extend onBeforePageDisplay() hook handler in Hooks.php by calling a new private method injectCarousel().
  • Intercept carousel image clicks and navigate them to MMV's hash route. The JavaScript click interceptor lives in a new file like mmv.carousel/index.js.

Some notes about this based on the decision made in T418333 (and also T407850). I would consider these as additional requirements:

  • The carousel will need to be ported from Vue.js to plain HTML and CSS (which we may need to generate in PHP). It needs to render properly and be clickable immediately at the time of first paint, before JS has initialized. We should either use MediaWiki's HTML building classes or something like Mustache templates to do this. We don't want to load Vue to show the carousel, only the lightbox (after the user clicks).
  • A small amount of JS for the carousel module should intercept link clicks here and trigger hash navigation (just like the MMV desktop viewer does) once JS initializes
  • Since the carousel is loading in PHP, we also need to perform the thumbnail selection/exclusion process in PHP as well. Currently this happens client-side. We'll need to add some kind of hook to manipulate the parser output (we should rely on the parser cache for this), find all matching thumbnails, etc.
  • Opt-out mechanisms are handled by T419786, but we need to still hide this new element behind a feature flag of some sort while we build it
  • Finally, adding the carousel to pages should not negatively impact performance.

Event Timeline

lwatson renamed this task from Image Browsing: Port Carousel component to Image Browsing: Port Carousel component to MMV.Fri, Mar 13, 6:06 PM
lwatson removed a project: MinervaNeue.
lwatson updated the task description. (Show Details)

Some notes about this based on the decision made in T418333 (and also T407850). I would consider these as additional requirements:

  • The carousel will need to be ported from Vue.js to plain HTML and CSS (which we may need to generate in PHP). It needs to render properly and be clickable immediately at the time of first paint, before JS has initialized. We should either use MediaWiki's HTML building classes or something like Mustache templates to do this. We don't want to load Vue to show the carousel, only the lightbox (after the user clicks).
  • A small amount of JS for the carousel module should intercept link clicks here and trigger hash navigation (just like the MMV desktop viewer does) once JS initializes
  • Since the carousel is loading in PHP, we also need to perform the thumbnail selection/exclusion process in PHP as well. Currently this happens client-side. We'll need to add some kind of hook to manipulate the parser output (we should rely on the parser cache for this), find all matching thumbnails, etc.
  • Opt-out mechanisms are handled by T419786, but we need to still hide this new element behind a feature flag of some sort while we build it
  • Finally, adding the carousel to pages should not negatively impact performance.

will update task to be about building the UI (relying on thumbnail logic from [related task])

Just wanted to document the tweak to the carousel designs we spoke about before, but I can't find any records of it. In user testing, people didn't know that more images were available in the carousel unless one of them was overlapping the right side. Correct me if I'm wrong here, but since we decided not to crop carousel images to a uniform width/height, we don't have any way of knowing whether or not more images are "hiding" off the right side of a reader's viewport.

As an affordance to show when more images are available, I want to show a horizontal scrollbar beneath the carousel. This also makes the design more accessible and usable overall.

image.png (1×794 px, 687 KB)

I'd love to see what this looks like and dogfood it on a bunch of browsers and a few devices. I know it looks decent in a mockup, but I don't know what it'll look like once it's rendered because it's a browser affordance. So if whoever picks this up could create a patchdemo for me to play around with when they get the chance, I'd love to verify the design decision before this goes wide.

Correct me if I'm wrong here, but since we decided not to crop carousel images to a uniform width/height, we don't have any way of knowing whether or not more images are "hiding" off the right side of a reader's viewport.

We can programmatically detect whether there is overflow, so we can know. E.g. @lwatson has done this to conditionally add a gradient at the top/bottom of the TOC to indicate when there is more content in either direction.

Change #1259252 had a related patch set uploaded (by Kimberly Sarabia; author: Kimberly Sarabia):

[mediawiki/extensions/MultimediaViewer@master] Add mobile carousel shell and MMV routing

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

Port excludedImageSelectors.js (additional exclusions beyond MMV's isAllowedThumb()) from ReaderExperiments to MMV. This extends MMV's exclusion logic.

This acceptance criterion about exclusion logic was left over when we split this task into two during refinement. T420392: Image Browsing: Port thumbnail extraction logic to PHP will handle exclusion logic, and the carousel port task will focus on the UI.

cc: @mfossati @KSarabia-WMF - also made a similar comment in Gerrit as I realized the tasks overlap. Let me know if you disagree https://gerrit.wikimedia.org/r/c/mediawiki/extensions/MultimediaViewer/+/1259252/comment/4396ff98_3b6f6852/

lwatson changed the task status from Open to In Progress.Thu, Mar 26, 5:49 PM
lwatson updated the task description. (Show Details)

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

[mediawiki/extensions/MultimediaViewer@master] ImageBrowsing: carousel thumbs

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

Change #1259252 merged by jenkins-bot:

[mediawiki/extensions/MultimediaViewer@master] Add mobile carousel shell and MMV routing

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

Change #1261699 merged by jenkins-bot:

[mediawiki/extensions/MultimediaViewer@master] ImageBrowsing: carousel thumbnails HTML

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

QA Instructions

This should be tested after the patch for T420392 is merged

It's needed for the carousel to render at the current setup.

QA Instructions

Just wanted to document the tweak to the carousel designs we spoke about before, but I can't find any records of it. In user testing, people didn't know that more images were available in the carousel unless one of them was overlapping the right side. Correct me if I'm wrong here, but since we decided not to crop carousel images to a uniform width/height, we don't have any way of knowing whether or not more images are "hiding" off the right side of a reader's viewport.

As an affordance to show when more images are available, I want to show a horizontal scrollbar beneath the carousel. This also makes the design more accessible and usable overall.

image.png (1×794 px, 687 KB)

The patchdemo https://3e365bbbf8.catalyst.wmcloud.org/wiki/Paris?useformat=mobile shows the horizontal scrollbar only when actual scrolling is initiated. But "hiding" images should provide a strong signal that the images are scrollable, I think.