feat(mdx): add ImageCarousel component for post galleries #9

Merged
trex Bot merged 1 commits from feat/image-carousel into main 2026-11-22 01:18:36 -06:00

Adds an ImageCarousel MDX component so posts can embed a swipeable gallery.

Usage

<ImageCarousel
  images={[
    { src: "https://s3.jonb.io/cdn/projects/qbitmaid.jpg", alt: "qbit-maid", caption: "qbit-maid dashboard" },
    { src: "/static/images/qbitmaid.jpg", alt: "local", caption: "local static path" },
  ]}
/>

Or hoist the array with export const shots = [...] and pass images={shots}.

Props: images (required), aspect (default aspect-[16/9]), fit (cover|contain), showArrows, showDots, showCounter.

Notes

  • No new dependencies — scroll-snap based, so touch swipe and trackpad scroll work natively; arrows/dots call scrollTo.
  • Reuses the existing Image wrapper, so s3.jonb.io and /static paths work with no next.config.js change.
  • not-prose on the figure so the typography plugin does not fight the layout.
  • Arrow-key navigation when focused; aria-roledescription="carousel" and labelled buttons. Two eslint-disable lines for jsx-a11y because the WAI-ARIA carousel pattern requires a focusable region with a key handler.
  • Arrows, dots and counter auto-hide for a single image.

Verified with a local static export: inline array, export const array, remote s3 path, local /static path, and single-image case all render.

Adds an `ImageCarousel` MDX component so posts can embed a swipeable gallery. **Usage** ```mdx <ImageCarousel images={[ { src: "https://s3.jonb.io/cdn/projects/qbitmaid.jpg", alt: "qbit-maid", caption: "qbit-maid dashboard" }, { src: "/static/images/qbitmaid.jpg", alt: "local", caption: "local static path" }, ]} /> ``` Or hoist the array with `export const shots = [...]` and pass `images={shots}`. **Props:** `images` (required), `aspect` (default `aspect-[16/9]`), `fit` (`cover`|`contain`), `showArrows`, `showDots`, `showCounter`. **Notes** - No new dependencies — scroll-snap based, so touch swipe and trackpad scroll work natively; arrows/dots call `scrollTo`. - Reuses the existing `Image` wrapper, so `s3.jonb.io` and `/static` paths work with no `next.config.js` change. - `not-prose` on the figure so the typography plugin does not fight the layout. - Arrow-key navigation when focused; `aria-roledescription="carousel"` and labelled buttons. Two `eslint-disable` lines for `jsx-a11y` because the WAI-ARIA carousel pattern requires a focusable region with a key handler. - Arrows, dots and counter auto-hide for a single image. Verified with a local static export: inline array, `export const` array, remote s3 path, local `/static` path, and single-image case all render.
trex Bot added 1 commit 2026-11-22 01:18:33 -06:00
Scroll-snap carousel usable directly in .mdx posts:

  <ImageCarousel images={[{ src, alt, caption }]} />

Props: images (required), aspect (default aspect-[16/9]), fit
(cover|contain), showArrows, showDots, showCounter. Native swipe and
trackpad scroll, arrow-key support when focused, per-slide captions,
and arrows/dots/counter auto-hide for a single image.

No new dependencies; reuses the existing Image wrapper so s3.jonb.io
and /static paths work as-is.
trex Bot merged commit e05e8a3fc3 into main 2026-11-22 01:18:36 -06:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jblu/jonbio#9