Skip to content

feat(event): add yet-another-react-lightbox to image carousel #8

Closed

Description

@Ardnived

Summary

Event photos render in an autoplay Swiper carousel (EventImages, shown in
EventPanel) that can't be expanded — tapping a photo does nothing. Port
WeMeditateWeb's fullscreen lightbox (built on yet-another-react-lightbox v3,
with zoom + captions + a thumbnail strip) and wire it into the carousel so a tap
opens the photo fullscreen. Also delete the unused LightboxImage atom, which is
dead code pointing at a leftover requestly.io debug URL.

We adopt a simplified, lazy-loaded port: the YARL wrapper is loaded via
React.lazy so the library and its CSS stay out of the main bundle, and it's
wired directly into EventImages. We deliberately skip WeMeditate's
LightboxProvider / group-registration context — that infrastructure exists to
serve many SSR surfaces, whereas SahajAtlas is a client-only widget with a single
gallery surface.

Current behavior

  • src/components/molecules/EventImages/EventImages.tsx — autoplay Swiper
    carousel of event.images, no fullscreen affordance; clicking an image is a
    no-op.
  • src/components/atoms/LightboxImage/LightboxImage.tsx — a NextUI-Modal
    "lightbox" that is not used anywhere (only in its own story) and renders
    its fullscreen image from https://app.requestly.io/delay/1000/${imageUrl}.

WeMeditate's reference implementation (for parity):
~/Documents/Projects/WeMeditateWeb/components/molecules/Lightbox/Lightbox.tsx —
YARL with Captions + Zoom always, Thumbnails added when >1 slide,
zoom={{ scrollToZoom: true }}, and prev/next buttons suppressed for a single
slide.

Proposed changes

  • Add dependency yet-another-react-lightbox@^3.32.0 (supports React 18).
  • New atom src/components/atoms/Lightbox/ (folder-per-component:
    Lightbox.tsx + Lightbox.stories.tsx + index.ts):
    • Lightbox.tsx — port of WeMeditate's wrapper: imports YARL + the three CSS
      files (styles.css, plugins/captions.css, plugins/thumbnails.css),
      plugins [Captions, Zoom] for a single slide and [Captions, Thumbnails, Zoom] for multiple, scrollToZoom, and prev/next suppressed when single.
      Props: slides: LightboxSlide[], open, index, close — same shape as
      WeMeditate's LightboxImplProps. Define LightboxSlide (src, alt?,
      description?) locally.
    • index.ts — export the component lazily (React.lazy(() => import('./Lightbox'))) so YARL + its CSS land in a separate chunk and never
      load until the user opens a photo. (We don't need WeMeditate's ClientOnly
      wrapper — there is no SSR.)
    • Add to the atoms barrel (src/components/atoms/index.ts).
  • Wire into the carousel (EventImages.tsx):
    • Map images → slides ({ src: image.url, alt: image.altText, description: image.altText }) via a small pure helper so it's unit-testable.
    • Local state for open + active index; each slide image becomes a real
      <button> (keyboard-accessible per jsx-a11y) with cursor-zoom-in, whose
      onClick sets the index and opens the lightbox.
    • Render the lazy <Lightbox> inside a <Suspense fallback={null}>.
    • Keep the Swiper carousel and the swiper dependency — only the
      tap-to-expand behavior is added.
  • Remove dead code: delete src/components/atoms/LightboxImage/ (component +
    story + index.ts) and its export from the atoms barrel.

Acceptance criteria

  • Tapping any photo in an event's carousel opens it fullscreen in the YARL
    lightbox; Esc / backdrop / close button dismisses it.
  • Zoom (scroll, double-click/tap, pinch) and the caption (from altText)
    work; with multiple images a thumbnail strip and prev/next navigation are
    shown, and a single image shows neither.
  • The lightbox opens on the clicked image (correct starting index).
  • YARL and its CSS load in a lazy chunk — not in the initial bundle
    (verify in pnpm build output / a dist chunk).
  • The lightbox renders correctly in the embedded widget (demo.html),
    i.e. YARL's CSS is picked up by vite-plugin-css-injected-by-js, not just
    in standalone dev.
  • LightboxImage is deleted and no longer exported; no remaining references
    to it or to the requestly.io URL.
  • A Ladle story exists for the new Lightbox atom.
  • Unit test covers the images → slides mapping helper.
  • pnpm lint, pnpm typecheck, pnpm test:run, pnpm build, and
    pnpm ladle:build all pass.

Files affected

  • package.json — add yet-another-react-lightbox
  • src/components/atoms/Lightbox/{Lightbox.tsx,Lightbox.stories.tsx,index.ts} (new)
  • src/components/molecules/EventImages/EventImages.tsx — tap-to-open wiring
  • src/components/atoms/index.ts — add Lightbox, drop LightboxImage
  • src/components/atoms/LightboxImage/** — delete
  • src/components/molecules/EventImages/EventImages.test.ts(x) — slide-mapping test (new)

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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