kitbash Sign in Connect agent
Components

Night viewer

One picture centred on the navy ground with a numbered counter and Previous and Next words; clicking either half steps and crossfades.

Part of the style

Night Water Footnote

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --night: #f15b29;
  --mist: #1d0c0b;
  --day: #e9cfcd;
  --wall: #010000;
  --mat: #010000;
  --ink: #993c1e;
  --ink-soft: #3c1817;
  --rule: #020000;
  --mist-soft: #580a05;
  --night-deep: #ef4837;
  --night-swell: #f51706;
  --glint: #4f090e;
  --glint-core: #805653;
}
</style>

<section class="viewer" aria-roledescription="carousel" aria-label="Weather Over the Mole, views">
  <div class="viewer__stage">
    <figure class="viewer__slide is-current" aria-label="1 of 4">
      <img class="viewer__img" src="assets/great-wave.jpg" alt="Sepia seascape: low sun behind piled clouds over a calm sea" width="1200" height="978">
      <figcaption class="viewer__caption"><em>Weather Over the Mole</em>, 2025–2026. Installation view, harbour shed</figcaption>
    </figure>
    <figure class="viewer__slide" aria-label="2 of 4">
      <img class="viewer__img" src="assets/solar-clouds.jpg" alt="Dark sea under a sky broken by bands of light" width="800" height="627" loading="lazy">
      <figcaption class="viewer__caption"><em>Weather Over the Mole</em>, 2025–2026. Still from the loop, minute eleven</figcaption>
    </figure>
    <figure class="viewer__slide" aria-label="3 of 4">
      <img class="viewer__img" src="assets/brig.jpg" alt="A small sailing boat on a pale grey sea" width="800" height="634" loading="lazy">
      <figcaption class="viewer__caption"><em>Weather Over the Mole</em>, 2025–2026. Still from the loop, minute thirty</figcaption>
    </figure>
    <figure class="viewer__slide" aria-label="4 of 4">
      <img class="viewer__img" src="assets/breaking-wave.jpg" alt="Surf breaking white over black rocks" width="650" height="800" loading="lazy">
      <figcaption class="viewer__caption"><em>Weather Over the Mole</em>, 2025–2026. Detail of the lamp housing</figcaption>
    </figure>
    <button class="viewer__half viewer__half--prev" type="button" aria-label="Previous view"></button>
    <button class="viewer__half viewer__half--next" type="button" aria-label="Next view"></button>
  </div>

  <div class="viewer__controls">
    <button class="viewer__word" type="button" data-step="-1">Previous</button>
    <p class="viewer__count" aria-live="polite"><span class="viewer__now">1</span> / <span class="viewer__total">4</span></p>
    <button class="viewer__word" type="button" data-step="1">Next</button>
  </div>
</section>

<style>
  .viewer {
    display: grid;
    grid-template-rows: 1fr auto;
    gap: var(--space-m);
    height: clamp(560px, 50vw, 720px);
    padding: var(--space-l) var(--edge) var(--space-s);
    background: var(--night);
    color: var(--mist);
  }
  .viewer__stage {
    position: relative;
    min-height: 0;
  }
  .viewer__slide {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    justify-items: center;
    gap: var(--space-s);
    margin: 0;
    opacity: 0;
    transition: opacity var(--slow) var(--ease);
  }
  .viewer__slide.is-current {
    opacity: 1;
  }
  .viewer__img {
    width: 100%;
    height: 100%;
    max-width: 960px;
    object-fit: contain;
  }
  .viewer__caption {
    font-size: var(--text-s);
    line-height: var(--leading);
    text-align: center;
  }
  .viewer__half {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50%;
    padding: 0;
    border: 0;
    background: none;
  }
  .viewer__half--prev {
    left: 0;
    cursor: w-resize;
  }
  .viewer__half--next {
    right: 0;
    cursor: e-resize;
  }
  .viewer__controls {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
  }
  .viewer__word {
    justify-self: start;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: 500 var(--text-nav) / var(--leading-tight) var(--font-grotesk);
    cursor: pointer;
    transition: color var(--quick) var(--ease);
  }
  .viewer__word + .viewer__count + .viewer__word {
    justify-self: end;
  }
  .viewer__word:hover,
  .viewer__word:focus-visible {
    color: var(--day);
  }
  .viewer__word:focus-visible,
  .viewer__half:focus-visible {
    outline: var(--line) solid var(--mist);
    outline-offset: -2px;
  }
  .viewer__count {
    margin: 0;
    color: var(--mist-soft);
    font-size: var(--text-s);
    font-variant-numeric: tabular-nums;
  }

  @media (max-width: 40rem) {
    .viewer {
      height: clamp(480px, 140vw, 600px);
    }
  }
</style>

<script>
  (() => {
    document.querySelectorAll('.viewer').forEach((root) => {
      const slides = [...root.querySelectorAll('.viewer__slide')];
      const now = root.querySelector('.viewer__now');
      let index = 0;
      const go = (step) => {
        slides[index].classList.remove('is-current');
        index = (index + step + slides.length) % slides.length;
        slides[index].classList.add('is-current');
        if (now) now.textContent = String(index + 1);
      };
      root.querySelector('.viewer__half--prev')?.addEventListener('click', () => go(-1));
      root.querySelector('.viewer__half--next')?.addEventListener('click', () => go(1));
      root.querySelectorAll('.viewer__word').forEach((button) => {
        button.addEventListener('click', () => go(Number(button.dataset.step)));
      });
      root.addEventListener('keydown', (event) => {
        if (event.key === 'ArrowLeft') go(-1);
        if (event.key === 'ArrowRight') go(1);
      });
    });
  })();
</script>

Similar components

Spread

Spread

Line-screen archive

Line-screen archive

Project index

Project index

Colour wash showcase

Colour wash showcase

Spiral gallery

Spiral gallery

Latest work rail

Latest work rail

Bracketed Exhibits

Bracketed Exhibits

Loose project grid

Loose project grid