Filmstrip

Filmstrip

Thumbnails along the bottom edge. The active one stays centered as you page.

A real lightbox, open inside the frame. Use ←→ to page and Esc to close it.

import { createLightbox } from "@reuse-sh/lightbox";
import "@reuse-sh/lightbox/styles.css";
import "./lightbox-style.css";
import { addChrome } from "./lightbox-chrome.js";

const lightbox = createLightbox({
  thumbnails: true,
  className: "lightbox-style",
});

lightbox.open(photos, 0);
addChrome(lightbox, photos);

lightbox-style.css

.lightbox-style {
  --lightbox-pad: 16px;
  --lightbox-side: 0px;
  --lightbox-caption: 0px;
  --lightbox-strip: 0px;
  --lightbox-bar: 0px;
  --lightbox-under: 0px;
  --lightbox-bottom: calc(var(--lightbox-caption) + var(--lightbox-strip) + var(--lightbox-bar) + var(--lightbox-under));
  --lightbox-ring: 0 0 0 0.5px rgb(0 0 0 / 10%), 0 1px 2px rgb(0 0 0 / 6%), 0 2px 6px rgb(0 0 0 / 4%);
  --reuse-lightbox-background: #fcfcfc;
  --reuse-lightbox-foreground: #1f1f1f;
  --reuse-lightbox-control: #fff;
}
.lightbox-style *, .lightbox-style *::before, .lightbox-style *::after { box-sizing: border-box; }
.lightbox-style .reuse-lightbox-viewport {
  width: calc(100% - var(--lightbox-side));
  height: calc(100% - var(--lightbox-bottom));
}
.lightbox-style .reuse-lightbox-button {
  width: 40px;
  height: 40px;
  padding: 0;
  color: inherit;
  box-shadow: var(--lightbox-ring);
  backdrop-filter: none;
  transition: background-color 150ms ease, transform 160ms cubic-bezier(0.23, 1, 0.32, 1), opacity 300ms ease;
}
.lightbox-style .reuse-lightbox-button svg { width: 18px; height: 18px; }
.lightbox-style .reuse-lightbox-button:hover { background: #f4f4f4; }
.lightbox-style .reuse-lightbox-button:active:not(:disabled) { transform: scale(0.95); }
.lightbox-style .reuse-lightbox-button:disabled { opacity: 0.3; }
.lightbox-style .reuse-lightbox-close, .lightbox-style .reuse-lightbox-zoom { top: var(--lightbox-pad); }
.lightbox-style .reuse-lightbox-close { right: var(--lightbox-pad); }
.lightbox-style .reuse-lightbox-zoom { right: calc(var(--lightbox-pad) + 48px); }
.lightbox-style .reuse-lightbox-footer {
  right: calc(var(--lightbox-side) + var(--lightbox-pad));
  bottom: calc(var(--lightbox-under) + var(--lightbox-pad));
  left: var(--lightbox-pad);
  gap: 10px;
}
.lightbox-style .reuse-lightbox-counter {
  padding: 0;
  background: none;
  backdrop-filter: none;
  font-size: 13px;
}

.lightbox-style .reuse-lightbox-prev,
.lightbox-style .reuse-lightbox-next { top: calc((100% - var(--lightbox-bottom)) / 2 - 20px); }
.lightbox-style .reuse-lightbox-prev { left: var(--lightbox-pad); }
.lightbox-style .reuse-lightbox-next { right: calc(var(--lightbox-side) + var(--lightbox-pad)); }

.lightbox-style .reuse-lightbox-counter { display: none; }

.lightbox-style .reuse-lightbox-caption { display: none; }

.lightbox-style { --lightbox-strip: 64px; }
.lightbox-style .reuse-lightbox-thumbnails { order: 2; max-width: 100%; gap: 6px; padding: 5px; scrollbar-width: none; }
.lightbox-style .reuse-lightbox-thumbnails::-webkit-scrollbar { display: none; }
.lightbox-style .reuse-lightbox-thumbnails button {
  flex: 0 0 60px;
  width: 60px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: #e6e6e3;
  opacity: 0.45;
  transition: opacity 200ms ease, box-shadow 200ms ease;
}
.lightbox-style .reuse-lightbox-thumbnails button:hover { opacity: 0.8; }
.lightbox-style .reuse-lightbox-thumbnails button[aria-current="true"] {
  opacity: 1;
  box-shadow: 0 0 0 2px var(--reuse-lightbox-background), 0 0 0 3.5px var(--reuse-lightbox-foreground);
}

@media (max-width: 559px) {
  .lightbox-style { --lightbox-pad: 12px; }
}

@media (max-width: 559px) {
  .lightbox-style { --lightbox-strip: 56px; }
  .lightbox-style .reuse-lightbox-thumbnails button { flex-basis: 48px; width: 48px; height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox-style, .lightbox-style * { transition-duration: 0ms !important; }
}

lightbox-chrome.js

export function addChrome(lightbox, items) {
  const dialog = document.querySelector("dialog.lightbox-style");
  const part = (name) => dialog.querySelector(`.reuse-lightbox-${name}`);
  const syncs = [];
  const cleanups = [];

  const strip = part("thumbnails");
  let shown = -1;
  syncs.push((state) => {
    const thumb = strip.children[state.index];
    if (!thumb || state.index === shown || strip.scrollWidth <= strip.clientWidth) return;
    const left = thumb.offsetLeft - (strip.clientWidth - thumb.offsetWidth) / 2;
    strip.scrollTo({ left: Math.max(0, left), behavior: shown < 0 ? "instant" : "smooth" });
    shown = state.index;
  });

  const sync = (state) => syncs.forEach((fn) => fn(state));
  sync(lightbox.getState());
  const stop = lightbox.subscribe((state) => {
    if (state.isOpen) sync(state);
    else if (!state.isClosing) {
      stop();
      cleanups.forEach((fn) => fn());
    }
  });
}