kitbash Sign in Connect agent
Components

Discipline ticker and machine reel

A black band of disciplines separated by slashes rolling at 40 px per second over a full-width machine shop photograph with a round play button that starts a slow dolly and a timecode.

Part of the style

Machine Shop Grid

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --page: #e9e9e9;
  --ink: #363736;
  --ink-soft: rgba(55, 56, 55, 0.65);
  --paper: #fefefe;
  --on-dark: #e9e9e9;
  --rule-col: #d2d2d2;
  --grid-dark: rgba(233, 233, 233, 0.12);
  --hatch: #d9d9d9;
  --steel: #cacaca;
  --accent: #4bb299;
}
</style>

<section class="reel" aria-label="Disciplines and the lathe room">
  <div class="reel__band">
    <ul class="reel__track">
      <li class="reel__item">Optical design</li>
      <li class="reel__item">Mirror grinding</li>
      <li class="reel__item">Equatorial mounts</li>
      <li class="reel__item">Dome drives</li>
      <li class="reel__item">Encoders &amp; firmware</li>
      <li class="reel__item">Spectrographs</li>
      <li class="reel__item">Alignment &amp; star test</li>
    </ul>
  </div>

  <figure class="reel__stage">
    <div class="reel__frame">
      <img class="reel__picture" src="assets/lathe-shafts.jpg" alt="Long belt-driven lathes for turning shafts in an old machine shop" width="1200" height="857" loading="lazy">
    </div>
    <button class="reel__play" type="button" aria-pressed="false" aria-label="Play the lathe room reel">
      <svg class="reel__icon reel__icon--play" viewBox="0 0 24 24" aria-hidden="true"><path d="M9 5l7 7-7 7"/></svg>
      <svg class="reel__icon reel__icon--pause" viewBox="0 0 24 24" aria-hidden="true"><path d="M9 6v12M15 6v12"/></svg>
    </button>
    <figcaption class="reel__caption">
      <span>Reel 03 / Lathe room, shaft line</span>
      <output class="reel__time">00:00:00:00</output>
    </figcaption>
  </figure>
</section>

<style>
  .reel {
    background: var(--ink);
  }
  .reel__band {
    display: flex;
    align-items: center;
    height: var(--cell-h);
    overflow: hidden;
    color: var(--on-dark);
  }
  .reel__track {
    display: flex;
    width: max-content;
    margin: 0;
    padding: 0;
    list-style: none;
    animation: reel-roll var(--reel-duration, 42s) linear infinite;
  }
  .reel__band:hover .reel__track,
  .reel.is-away .reel__track {
    animation-play-state: paused;
  }
  .reel__item {
    flex: none;
    font: var(--weight-label) var(--text-tick)/var(--text-tick) var(--font-display);
    text-transform: uppercase;
    white-space: nowrap;
  }
  .reel__item::after {
    content: "/";
    padding: 0 var(--space-xs);
  }
  @keyframes reel-roll {
    to { transform: translateX(-50%); }
  }

  .reel__stage {
    position: relative;
    margin: 0;
  }
  .reel__frame {
    aspect-ratio: 21 / 8;
    overflow: hidden;
    background: var(--steel);
  }
  .reel__picture {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(1) contrast(1.25) brightness(1.05);
    mix-blend-mode: multiply;
    scale: 1.1;
    transform-origin: 40% 60%;
  }
  .reel.is-playing .reel__picture {
    animation: reel-dolly 18s var(--ease) infinite alternate;
  }
  @keyframes reel-dolly {
    from { scale: 1.1; translate: 0 0; }
    to { scale: 1.32; translate: -4% 2%; }
  }

  .reel__play {
    position: absolute;
    top: 50%;
    left: 50%;
    display: grid;
    place-items: center;
    width: var(--play);
    height: var(--play);
    translate: -50% -50%;
    border: 2px solid var(--paper);
    border-radius: var(--radius-round);
    background: rgba(26, 27, 28, 0.35);
    color: var(--paper);
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: background-color var(--quick) var(--ease), color var(--quick) var(--ease);
  }
  .reel__play:hover,
  .reel__play:focus-visible {
    background: var(--paper);
    color: var(--ink);
  }
  .reel__icon {
    grid-area: 1 / 1;
    width: 32px;
    height: 32px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
  }
  .reel__icon--pause,
  .reel.is-playing .reel__icon--play {
    display: none;
  }
  .reel.is-playing .reel__icon--pause {
    display: block;
  }

  .reel__caption {
    position: absolute;
    right: var(--frame);
    bottom: var(--frame);
    left: var(--frame);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--space-xs) var(--space-m);
    padding: var(--space-s) var(--gutter);
    color: var(--paper);
    font: var(--weight-label) var(--text-label)/var(--lh-label) var(--font-display);
    text-transform: uppercase;
    text-shadow: 0 1px 6px rgba(26, 27, 28, 0.6);
  }
  .reel__time {
    font-variant-numeric: tabular-nums;
  }
  .reel.is-playing .reel__time {
    color: var(--accent);
  }

  @media (max-width: 56rem) {
    .reel__frame {
      aspect-ratio: 4 / 3;
    }
    .reel__play {
      --play: 72px;
    }
  }
</style>

<script>
(() => {
  const still = matchMedia('(prefers-reduced-motion: reduce)');
  const pad = (n) => String(Math.floor(n)).padStart(2, '0');

  function setUpTicker(root) {
    const track = root.querySelector('.reel__track');
    for (const item of [...track.children]) {
      const copy = item.cloneNode(true);
      copy.setAttribute('aria-hidden', 'true');
      track.append(copy);
    }
    const speed = Number(getComputedStyle(root).getPropertyValue('--tick-speed')) || 40;
    const measure = () => root.style.setProperty('--reel-duration', `${track.scrollWidth / 2 / speed}s`);
    measure();
    document.fonts.ready.then(measure);
    new IntersectionObserver(([entry]) => root.classList.toggle('is-away', !entry.isIntersecting)).observe(root);
  }

  function setUpPlayer(root) {
    const button = root.querySelector('.reel__play');
    const time = root.querySelector('.reel__time');
    let started = 0;
    let shown = 0;
    let timer = 0;
    const show = () => {
      const frames = ((performance.now() - started) / 1000 + shown) * 24;
      time.textContent = [frames / 86400, (frames / 1440) % 60, (frames / 24) % 60, frames % 24].map(pad).join(':');
    };
    button.addEventListener('click', () => {
      const playing = root.classList.toggle('is-playing');
      button.setAttribute('aria-pressed', String(playing));
      button.setAttribute('aria-label', playing ? 'Pause the lathe room reel' : 'Play the lathe room reel');
      clearInterval(timer);
      if (playing) {
        started = performance.now();
        timer = setInterval(show, 1000 / 24);
      } else {
        shown += (performance.now() - started) / 1000;
      }
    });
    new IntersectionObserver(([entry]) => {
      if (!entry.isIntersecting && root.classList.contains('is-playing')) button.click();
    }).observe(root);
    if (still.matches) root.querySelector('.reel__track').style.animation = 'none';
  }

  document.querySelectorAll('.reel').forEach((root) => {
    setUpTicker(root);
    setUpPlayer(root);
  });
})();
</script>

Similar components

Red word band

Red word band

Wave ribbon

Wave ribbon

Reed ribbon

Reed ribbon

Film player

Film player

Film reel

Film reel

Band and case accordion

Band and case accordion

Showcase with progress tabs

Showcase with progress tabs

Ticker and nav bar

Ticker and nav bar