Skip to content

fix(ui): upgrade swiper to v12 and add carousel pause control #104

Closed

Description

@Ardnived

Summary

[email protected] carries a CRITICAL prototype-pollution advisory — GHSA-hmx5-qpq5-p643, vulnerable >=6.5.1 <12.1.2, patched >=12.1.2 — a semver-major bump from our declared ^11.2.1, so it is excluded from the sibling in-range dependency-update ticket and owned here. The same component also fails WCAG 2.2.2 (Pause, Stop, Hide): the image carousel autoplays at 4s with disableOnInteraction: false and NO pause control (src/components/molecules/ImageCarousel/ImageCarousel.tsx:46), and prefers-reduced-motion has zero hits repo-wide (verified by grep across src/ + tailwind.config.js). One file, one ticket: take the major and make the motion controllable.

Proposed changes

  • Bump swiper to >=12.1.2 (one-line package.json range change + lockfile) and migrate API/CSS imports per the swiper v12 migration guide. The CSS entry points are imported in src/styles/globals.css:3-5 (swiper/css, swiper/css/a11y, swiper/css/pagination) — a sibling release-hardening ticket owns globals.css and is rescoping its selectors, so keep any edit there strictly additive and minimal (touch only the swiper @import lines, and only if v12 renames them). Verify the .sy-carousel pagination theming in globals.css still matches v12's DOM/class names.
  • Add a visible, localized pause/play control wired to swiper's autoplay API (swiper.autoplay.stop() / .start()): a real <button>, keyboard-operable, with a localized aria-label and aria-pressed state. Render it only when the carousel actually autoplays — a single image already renders as a static slide with autoplay/pagination disabled (ImageCarousel.tsx:41, carousel = slides.length > 1).
  • Disable autoplay entirely under prefers-reduced-motion: reduce (e.g. window.matchMedia at render) — the repo's first reduced-motion support.
  • New locale keys go through pnpm i18n:add <dotted.key> '<{lng:value}>' [ns] across ALL 10 locales (cs de en es fr hu nl pt-BR ru uk), per .claude/rules/i18n-and-state.md. The component reads the events namespace (useTranslation('events') at ImageCarousel.tsx:26).

Acceptance criteria

  • pnpm audit --prod no longer reports GHSA-hmx5-qpq5-p643 (swiper resolves to >=12.1.2)
  • Pause/play control is visible on the autoplaying carousel, keyboard-operable, carries a localized aria-label + aria-pressed, and exists in all 10 locales
  • Pressing pause stops auto-advance until the viewer resumes it — interacting with the carousel does not silently restart autoplay
  • Under prefers-reduced-motion: reduce, autoplay never starts
  • Single-slide behaviour is unchanged: static slide, no autoplay, no pause control
  • Carousel verified in Ladle (pnpm ladle) after the v12 migration — slides render, pagination bullets keep the .sy-carousel theming, tapping a slide still opens the lightbox
  • pnpm lint && pnpm typecheck && pnpm test:run && pnpm build && pnpm ladle:build pass
  • Write an implementation report to .claude/reports/<issue-number>-<short-slug>.md — in the MAIN checkout at /Users/devindra/Documents/Projects/SahajAtlasWeb even when implementing from a worktree (the folder is gitignored) — covering what changed, what was deliberately NOT changed, and which readiness-report findings are resolved.

Files affected

  • src/components/molecules/ImageCarousel/ImageCarousel.tsx
  • pnpm-lock.yaml (shared — see note) + the one-line swiper range bump in package.json
  • public/locales/<lng>/events.json — additive keys, all 10 locales
  • src/styles/globals.css — NOT owned (sibling ticket); swiper @import lines only, additively, if v12 requires it

Parallel implementation: this ticket OWNS the files listed above; sibling release-hardening tickets run concurrently — avoid edits outside owned files except strictly additive ones. The pnpm lockfile is shared with two sibling tickets; conflicts there are expected and resolved by re-running pnpm install.

References

  • .claude/reports/RELEASE_READINESS.md §3.6 (blocker 3, the critical) + §5 (WCAG AA failure 1: autoplay without pause; failure 4: no reduced-motion support) (repo-local, gitignored)
  • GHSA-hmx5-qpq5-p643 (verified in pnpm audit --prod, 2026-08-06)
  • .claude/rules/i18n-and-state.md (locale-key workflow), .claude/rules/components.md (accessibility expectations)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Hold Until

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions