Patterns

Filmstrip

The filmstrip is an optional add-on from @ogdakke/fluidbox/filmstrip. The default strip draws the items' thumbnails, or you draw each thumbnail yourself.

Loading the live example…

filmstrip.tsx
import { itemLabel } from "@ogdakke/fluidbox";
import { Fluidbox } from "@ogdakke/fluidbox/react";
import "@ogdakke/fluidbox/filmstrip.css";
import { photos } from "./data";

function Thumbnails() {
  return (
    <div className="pattern-grid">
      {photos.map((photo) => (
        <Fluidbox.Trigger
          key={photo.src}
          item={photo}
          className="pattern-thumb"
        >
          <img src={photo.src} alt={itemLabel(photo)} />
        </Fluidbox.Trigger>
      ))}
    </div>
  );
}

export function Filmstrip() {
  return (
    <>
      <Fluidbox.Root items={photos}>
        <Thumbnails />
        {/* Being there turns the filmstrip on. */}
        <Fluidbox.Filmstrip />
      </Fluidbox.Root>
      <Fluidbox.Root items={photos}>
        <Thumbnails />
        {/* Your own thumbnails. The selected button has data-fluidbox-selected. */}
        <Fluidbox.Filmstrip>
          {({ index }) => (
            <span className="pattern-filmstrip-thumb">
              {index + 1}
            </span>
          )}
        </Fluidbox.Filmstrip>
      </Fluidbox.Root>
    </>
  );
}
  • import "@ogdakke/fluidbox/filmstrip" once, then filmstrip: true turns it on. In the frameworks, rendering the Filmstrip part turns it on. On custom elements, a <fluidbox-filmstrip> child does, and it loads the add-on itself. It shows only when there is more than one item.
  • For your own thumbnails, use filmstrip: { render } in plain JavaScript, the render property of <fluidbox-filmstrip>, or a child of the framework Filmstrip part.
  • The selected thumbnail's button has data-fluidbox-selected, so CSS can mark it without your thumbnails tracking anything.
  • The add-on is its own import, so it costs nothing until you use it.