kitbash Sign in Connect agent
Components

Numbered plate

A roman-numeral caption over one large centred picture and a strip of thumbnails that swap it with a short fade.

Part of the style

Roman Numeral Plates

7 parts that belong together, with their tokens, type and rules.

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --ink: #fbf4ee;
  --ink-faint: #584c4c;
  --paper: #251a1a;
  --veil: rgba(37, 26, 26, 0.72);
  --mat: #332828;
}
</style>

<section class="plate" aria-label="Plate I, Oriel Quarterly">
  <p class="plate__caption"><span class="plate__numeral">I</span><span class="plate__title">Oriel Quarterly</span></p>
  <figure class="plate__stage">
    <img class="plate__picture" src="assets/gloves.jpg" alt="A pair of printed kid gloves laid flat on red cloth" width="1057" height="1200">
    <figcaption class="plate__count"><span class="plate__current">1</span> / 5</figcaption>
  </figure>
  <ul class="plate__strip" aria-label="Pictures in this project">
    <li><button class="plate__thumb is-current" type="button" aria-label="Picture 1" data-src="assets/gloves.jpg" data-alt="A pair of printed kid gloves laid flat on red cloth"><img src="assets/gloves.jpg" alt="" width="1057" height="1200"></button></li>
    <li><button class="plate__thumb" type="button" aria-label="Picture 2" data-src="assets/ribbons.jpg" data-alt="A page of woven ribbon samples in black and white"><img src="assets/ribbons.jpg" alt="" width="596" height="800"></button></li>
    <li><button class="plate__thumb" type="button" aria-label="Picture 3" data-src="assets/textile.jpg" data-alt="A small piece of rose-patterned brocade on grey"><img src="assets/textile.jpg" alt="" width="800" height="617"></button></li>
    <li><button class="plate__thumb" type="button" aria-label="Picture 4" data-src="assets/jar.jpg" data-alt="A pale green glass jar on a grey sweep"><img src="assets/jar.jpg" alt="" width="797" height="800"></button></li>
    <li><button class="plate__thumb" type="button" aria-label="Picture 5" data-src="assets/tea-bowl.jpg" data-alt="A dark brown glazed tea bowl on grey"><img src="assets/tea-bowl.jpg" alt="" width="800" height="575"></button></li>
  </ul>
</section>

<style>
  .plate {
    display: grid;
    justify-items: center;
    gap: var(--space-s);
    padding: var(--space-l) var(--edge) var(--section-space);
    color: var(--ink);
    font: 400 var(--text)/var(--leading) var(--font-serif);
  }
  .plate__caption {
    display: grid;
    grid-template-columns: var(--numeral-col) auto;
    gap: var(--space-m);
    margin: 0 0 var(--space-s);
    transform: translateX(calc(var(--numeral-col) / -2));
  }
  .plate__numeral {
    text-align: right;
    font-variant: all-small-caps;
    letter-spacing: 0.06em;
  }
  .plate__stage {
    position: relative;
    margin: 0;
  }
  .plate__picture {
    width: auto;
    height: min(54vw, 760px);
    max-width: 100%;
    object-fit: contain;
    opacity: 1;
    transition: opacity var(--fade) var(--ease);
  }
  .plate__picture.is-fading { opacity: 0; }
  .plate__count {
    position: absolute;
    right: calc(100% + var(--space-m));
    bottom: 0;
    white-space: nowrap;
    font-variant-numeric: lining-nums;
  }
  .plate__strip {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .plate__thumb {
    display: block;
    height: var(--thumb);
    min-width: 44px;
    padding: 0;
    border: 0;
    background: var(--mat);
    cursor: pointer;
    opacity: 1;
    transition: opacity var(--quick) var(--ease);
  }
  .plate__thumb img {
    width: auto;
    height: 100%;
    object-fit: cover;
  }
  .plate__thumb:hover { opacity: 0.6; }
  .plate__thumb.is-current { outline: 1px solid var(--ink); outline-offset: 2px; }
  .plate__thumb:focus-visible { outline: 1px dashed var(--ink); outline-offset: 2px; }

  @media (max-width: 760px) {
    .plate__picture { width: 100%; height: auto; max-height: 120vw; }
    .plate__count { position: static; display: block; text-align: center; margin-top: var(--space-s); }
    .plate__thumb { height: 48px; }
  }
</style>

<script>
(() => {
  for (const root of document.querySelectorAll('.plate')) {
    const picture = root.querySelector('.plate__picture');
    const current = root.querySelector('.plate__current');
    const thumbs = [...root.querySelectorAll('.plate__thumb')];
    const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
    const fade = parseFloat(getComputedStyle(picture).transitionDuration) * 1000 || 300;
    let timer = 0;
    const show = (index) => {
      const thumb = thumbs[index];
      if (!thumb || thumb.classList.contains('is-current')) return;
      thumbs.forEach((other) => other.classList.toggle('is-current', other === thumb));
      current.textContent = String(index + 1);
      const swap = () => {
        picture.src = thumb.dataset.src;
        picture.alt = thumb.dataset.alt;
        const img = thumb.querySelector('img');
        picture.setAttribute('width', img.getAttribute('width'));
        picture.setAttribute('height', img.getAttribute('height'));
        const done = () => picture.classList.remove('is-fading');
        if (picture.complete) done(); else picture.addEventListener('load', done, { once: true });
      };
      clearTimeout(timer);
      if (reduce) { swap(); return; }
      picture.classList.add('is-fading');
      timer = setTimeout(swap, fade);
    };
    thumbs.forEach((thumb, index) => {
      thumb.addEventListener('click', () => show(index));
      thumb.addEventListener('keydown', (event) => {
        if (event.key !== 'ArrowRight' && event.key !== 'ArrowLeft') return;
        const next = (index + (event.key === 'ArrowRight' ? 1 : -1) + thumbs.length) % thumbs.length;
        thumbs[next].focus();
        show(next);
      });
    });
    picture.addEventListener('click', () => {
      const at = thumbs.findIndex((thumb) => thumb.classList.contains('is-current'));
      show((at + 1) % thumbs.length);
    });
  }
})();
</script>

Similar components

Drifting print field

Drifting print field

Framed still reel

Framed still reel

Statement with picture trail

Statement with picture trail

Grey stage

Grey stage

Threaded drag board

Threaded drag board

Tile ring hero

Tile ring hero

Portrait lineup

Portrait lineup

Drifting oval field

Drifting oval field