kitbash Sign in Connect agent
Components

Screen tile

A small dark rounded tile with a soft shadow that floats in the bottom-left corner and crossfades black-and-white photographs, with a tan caption list where the frame showing turns black.

Part of the style

Faded Label Index

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --paper: #e3e3e3;
  --ink: #28171c;
  --ink-deep: #040001;
  --ink-faded: #a5a39e;
  --tile: #27161b;
  --tile-ink: #e3e3e3;
  --flood: #c8774a;
}
</style>

<section class="screen" aria-label="Bench camera">
  <div class="screen__intro">
    <p class="screen__label">Bench camera</p>
    <h2 class="screen__head">On the bench this week</h2>
  </div>

  <div class="screen__reading">
    <p class="screen__text">A small screen follows you down the page with whatever is open on the bench. Tap it to hold a frame, or pick one from the list.</p>
    <ol class="screen__captions">
      <li><a class="screen__caption is-current" href="#" data-frame="0">Pocket watch, cleaned and oiled</a></li>
      <li><a class="screen__caption" href="#" data-frame="1">Pewter mantel clock, new hands</a></li>
      <li><a class="screen__caption" href="#" data-frame="2">Porcelain table clock, case reglued</a></li>
      <li><a class="screen__caption" href="#" data-frame="3">Gilt bracket clock, full overhaul</a></li>
      <li><a class="screen__caption" href="#" data-frame="4">Enamel dial, set back in its bezel</a></li>
    </ol>
  </div>

  <div class="screen__tile">
    <img class="screen__frame is-current" src="assets/pocket-watch.jpg" alt="Woodblock print of a pocket watch on its chain" width="893" height="1000" loading="eager">
    <img class="screen__frame" src="assets/shelf-clock.jpg" alt="Pewter mantel clock with a square dial" width="667" height="1000">
    <img class="screen__frame" src="assets/table-clock.jpg" alt="Ornate porcelain table clock" width="1000" height="1000">
    <img class="screen__frame" src="assets/wall-clock.jpg" alt="Gilt bracket clock on its wall shelf" width="786" height="1000">
    <img class="screen__frame" src="assets/watch-movement.jpg" alt="Dark enamel watch dial with gold numerals" width="1000" height="1000">
    <button class="screen__hold" type="button" aria-pressed="false" aria-label="Hold this frame">
      <span class="screen__state">Live</span>
    </button>
  </div>
</section>

<style>
  .screen {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-m) var(--gap);
    align-items: start;
    padding: var(--space-l) var(--edge) var(--section-space);
  }
  .screen p,
  .screen h2,
  .screen ol {
    margin: 0;
    padding: 0;
    font: inherit;
  }
  .screen__intro {
    grid-column: 2;
  }
  .screen__label,
  .screen__text {
    color: var(--ink-faded);
  }
  .screen__head {
    color: var(--ink);
  }
  .screen__reading {
    grid-column: 3 / 5;
    max-width: 34em;
  }
  .screen .screen__captions {
    margin-top: var(--space-s);
    list-style: none;
  }
  .screen__caption {
    color: var(--ink-faded);
    text-decoration: none;
    transition: color var(--time) var(--ease);
  }
  .screen__caption:hover,
  .screen__caption:focus-visible,
  .screen__caption.is-current {
    color: var(--ink);
    outline: none;
  }

  .screen__tile {
    position: fixed;
    left: var(--edge);
    bottom: var(--edge);
    z-index: 30;
    width: var(--tile-width);
    height: var(--tile-height);
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--tile);
    box-shadow: var(--shadow-tile);
  }
  .screen__frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(1) contrast(1.2) brightness(0.78);
    opacity: 0;
    transition: opacity var(--fade) var(--ease);
  }
  .screen__frame:nth-of-type(1) {
    object-position: 30% 85%;
  }
  .screen__frame:nth-of-type(2) {
    object-position: 50% 25%;
  }
  .screen__frame:nth-of-type(4) {
    object-position: 50% 35%;
  }
  .screen__frame.is-current {
    opacity: 1;
  }
  .screen__hold {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    padding: 8px 10px;
    border: 0;
    background: none;
    color: var(--tile-ink);
    font: inherit;
    font-size: var(--text-s);
    line-height: 1;
    letter-spacing: inherit;
    cursor: pointer;
    transition: transform var(--quick) var(--ease);
  }
  .screen__hold:active {
    transform: scale(0.98);
  }
  .screen__hold:focus-visible {
    outline: var(--line) solid var(--tile-ink);
    outline-offset: -4px;
  }
  .screen__state {
    opacity: 0.7;
  }

  @media (max-width: 1100px) {
    .screen__intro {
      grid-column: 1 / 3;
    }
  }

  @media (max-width: 760px) {
    .screen {
      grid-template-columns: minmax(0, 1fr);
      padding-top: var(--space-m);
      font-size: var(--text-phone);
      line-height: var(--leading-phone);
    }
    .screen__intro,
    .screen__reading {
      grid-column: 1;
    }
    .screen__tile {
      position: relative;
      left: auto;
      bottom: auto;
      grid-row: 1;
      justify-self: center;
      width: min(100%, 320px);
      height: auto;
      aspect-ratio: 220 / 124;
    }
    .screen__captions li {
      padding-block: 11px;
    }
  }
</style>

<script>
  (() => {
    const STEP = 3200;
    const still = matchMedia('(prefers-reduced-motion: reduce)');
    for (const root of document.querySelectorAll('.screen')) {
      const tile = root.querySelector('.screen__tile');
      const frames = [...root.querySelectorAll('.screen__frame')];
      const captions = [...root.querySelectorAll('.screen__caption')];
      const hold = root.querySelector('.screen__hold');
      const state = root.querySelector('.screen__state');
      if (!tile || frames.length < 2) continue;
      let index = 0;
      let held = false;
      let visible = true;
      let timer = 0;

      const show = (next) => {
        index = (next + frames.length) % frames.length;
        frames.forEach((frame, i) => frame.classList.toggle('is-current', i === index));
        captions.forEach((caption, i) => caption.classList.toggle('is-current', i === index));
      };
      const stop = () => {
        clearInterval(timer);
        timer = 0;
      };
      const sync = () => {
        const run = !held && visible && !document.hidden && !still.matches;
        if (run && !timer) timer = setInterval(() => show(index + 1), STEP);
        if (!run) stop();
        if (state) state.textContent = held ? 'Held' : 'Live';
        root.classList.toggle('is-held', held);
        hold.setAttribute('aria-pressed', String(held));
      };

      hold.addEventListener('click', () => {
        held = !held;
        sync();
      });
      captions.forEach((caption, i) => caption.addEventListener('click', (event) => {
        event.preventDefault();
        show(i);
        stop();
        sync();
      }));
      new IntersectionObserver(([entry]) => {
        visible = entry.isIntersecting;
        sync();
      }).observe(tile);
      document.addEventListener('visibilitychange', sync);
      still.addEventListener('change', sync);
      sync();
    }
  })();
</script>

Similar components

Framed slideshow

Framed slideshow

Film player

Film player

Opening reel frame

Opening reel frame

Radio dock

Radio dock

Grain player

Grain player

Open plate

Open plate

Captioned film still

Captioned film still

Edge-to-edge plate

Edge-to-edge plate