kitbash Sign in Connect agent
Components

Transcript

A clip beside timecoded Courier lines; play steps a mint band down the lines and clicking a line jumps to it.

Part of the style

Clip Over Headline

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --ink: #f2f5ff;
  --black: #feffff;
  --paper: #29213d;
  --chip: #352d4a;
  --chip-hover: #3f3753;
  --ink-soft: #948ea9;
  --line: #403955;
  --on-signal: #29213d;
  --sky: #87529d;
  --signal: #7f579b;
  --mint: #402652;
  --screen-top: #6e6177;
  --screen-bottom: #281535;
  --stop: #b763bc;
}
</style>

<section class="transcript" aria-labelledby="transcript-title">
  <div class="transcript__media">
    <figure class="transcript__frame">
      <img class="transcript__picture" src="assets/owl.jpg" alt="A pink porcelain owl perched on a flowered stump" width="544" height="800">
      <button class="transcript__play" type="button" aria-label="Play the clip">
        <span class="transcript__disc transcript__disc--play" aria-hidden="true"><svg viewBox="0 0 100 100"><path d="M38 28 L72 50 L38 72 Z" /></svg></span>
        <span class="transcript__disc transcript__disc--pause" aria-hidden="true"><svg viewBox="0 0 100 100"><rect x="35" y="30" width="10" height="40" rx="2" /><rect x="55" y="30" width="10" height="40" rx="2" /></svg></span>
      </button>
    </figure>
    <p class="transcript__meta"><span class="transcript__clock">00:00</span> / 06:00 · Owl at Dusk</p>
  </div>

  <div class="transcript__body">
    <h2 class="transcript__title" id="transcript-title">Owl at Dusk, every word</h2>
    <ol class="transcript__lines">
      <li><button class="transcript__line is-current" type="button" data-time="00:00"><span class="transcript__stamp">00:00</span><span class="transcript__words">[wind in the larches]</span></button></li>
      <li><button class="transcript__line" type="button" data-time="00:48"><span class="transcript__stamp">00:48</span><span class="transcript__words">The owl turns its head. Most of the way round.</span></button></li>
      <li><button class="transcript__line" type="button" data-time="01:55"><span class="transcript__stamp">01:55</span><span class="transcript__words">[a mouse, somewhere, thinks better of it]</span></button></li>
      <li><button class="transcript__line" type="button" data-time="03:10"><span class="transcript__stamp">03:10</span><span class="transcript__words">It blinks once. We count this as a plot.</span></button></li>
      <li><button class="transcript__line" type="button" data-time="04:22"><span class="transcript__stamp">04:22</span><span class="transcript__words">[the light goes the colour of weak tea]</span></button></li>
      <li><button class="transcript__line" type="button" data-time="05:40"><span class="transcript__stamp">05:40</span><span class="transcript__words">The owl leaves. The branch stays. Credits.</span></button></li>
    </ol>
  </div>
</section>

<style>
  .transcript {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: var(--space-xl);
    align-items: start;
    padding: var(--section-space) var(--edge);
  }

  .transcript__frame {
    position: relative;
    margin: 0;
    aspect-ratio: 4 / 5;
    max-height: 560px;
    border-radius: var(--radius-clip);
    overflow: hidden;
    background: linear-gradient(180deg, var(--screen-top), var(--screen-bottom));
  }
  .transcript__picture {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 35%;
    mix-blend-mode: multiply;
    filter: contrast(1.1);
    transition: scale var(--slow) var(--ease-out);
  }
  .transcript.is-playing .transcript__picture { scale: 1.08; }

  .transcript__play {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
  }
  .transcript__play:focus-visible { outline: 3px solid var(--sky); outline-offset: -3px; border-radius: var(--radius-clip); }
  .transcript__disc {
    grid-area: 1 / 1;
    border-radius: var(--radius-round);
    transition: opacity var(--time) var(--ease), scale var(--slow) var(--ease-out);
  }
  .transcript__disc svg { width: 100%; height: 100%; fill: var(--on-signal); }
  .transcript__disc--play { width: 44%; aspect-ratio: 1; background: var(--signal); }
  .transcript__disc--pause { width: var(--disc-small); height: var(--disc-small); background: var(--stop); opacity: 0; scale: 0.6; }
  .transcript.is-playing .transcript__disc--play { opacity: 0; scale: 0.6; }
  .transcript.is-playing .transcript__play:is(:hover, :focus-visible) .transcript__disc--pause { opacity: 1; scale: 1; }

  .transcript__meta {
    margin: var(--space-s) 0 0;
    color: var(--ink-soft);
  }
  .transcript__clock { color: var(--black); }

  .transcript__title {
    margin: 0 0 var(--space-l);
    font-family: var(--font-display);
    font-size: var(--display-m);
    font-weight: 500;
    line-height: var(--display-leading);
    letter-spacing: var(--display-tracking);
  }
  .transcript__lines {
    margin: 0;
    padding: 0;
    list-style: none;
    border-top: var(--hairline) solid var(--line);
  }
  .transcript__lines li { border-bottom: var(--hairline) solid var(--line); }
  .transcript__line {
    display: grid;
    grid-template-columns: 6ch minmax(0, 1fr);
    gap: var(--space-m);
    width: 100%;
    min-height: 44px;
    padding: var(--space-s) var(--space-s);
    border: 0;
    border-radius: var(--radius-chip);
    background: transparent;
    color: var(--ink-soft);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background var(--time) var(--ease), color var(--time) var(--ease);
  }
  .transcript__line:hover { color: var(--black); background: var(--chip); }
  .transcript__line.is-current { color: var(--black); background: var(--mint); }
  .transcript__line:focus-visible { outline: 2px solid var(--sky); outline-offset: -2px; }
  .transcript__stamp { font-size: var(--text-s); }

  @media (max-width: 760px) {
    .transcript { grid-template-columns: minmax(0, 1fr); gap: var(--space-l); }
    .transcript__frame { aspect-ratio: 3 / 2; }
  }
</style>

<script>
(() => {
  for (const root of document.querySelectorAll('.transcript')) {
    const lines = [...root.querySelectorAll('.transcript__line')];
    const play = root.querySelector('.transcript__play');
    const clock = root.querySelector('.transcript__clock');
    let current = 0;
    let timer = null;
    let inView = true;

    const show = (index) => {
      current = index % lines.length;
      lines.forEach((line, i) => line.classList.toggle('is-current', i === current));
      clock.textContent = lines[current].dataset.time;
    };
    const stop = () => { clearInterval(timer); timer = null; };
    const start = () => { stop(); timer = setInterval(() => show(current + 1), 2400); };
    const sync = () => (root.classList.contains('is-playing') && inView ? start() : stop());

    play.addEventListener('click', () => {
      const playing = root.classList.toggle('is-playing');
      play.setAttribute('aria-label', playing ? 'Pause the clip' : 'Play the clip');
      sync();
    });
    lines.forEach((line, i) => line.addEventListener('click', () => { show(i); sync(); }));
    new IntersectionObserver(([entry]) => { inView = entry.isIntersecting; sync(); }).observe(root);
  }
})();
</script>

Similar components

Contents with buttons

Contents with buttons

Column issue

Column issue

Ledger

Ledger

Focus rows

Focus rows

Serif project index

Serif project index

Agenda

Agenda

Grid and list index

Grid and list index

Step rail

Step rail