kitbash Sign in Connect agent
Components

Timed reviews

A centred review headline over a quote carousel with a 7.55s timer line, prev and next keys and a strip of drawn client marks that shows which quote is up.

Part of the style

Pressed Key Grid

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --ink: #08121f;
  --paper: #ffffff;
  --white: #ffffff;
  --pressed: #f0f0ef;
  --sand: #f1f0ef;
  --guide: #dcdbd9;
  --rule-dark: #2e3743;
  --muted: #8b8880;
  --muted-dark: #bbb9b3;
  --glass: rgba(255, 255, 255, 0.64);
  --phosphor-deep: #0a1420;
  --ember: #6b88ad;
  --ember-deep: #000001;
  --plum: #496588;
  --lilac: #f4f9ff;
  --orchid: #6b88ad;
  --phosphor: #6b88ad;
}
</style>

<section class="reviews" aria-labelledby="reviews-title">
  <div class="reviews__head">
    <p class="reviews__label">
      <span class="reviews__label-text">Pressed start</span>
      <svg class="reviews__cup" viewBox="0 0 40 40" aria-hidden="true"><path d="M13 7h14v9a7 7 0 0 1-14 0zM13 10H8.5a4.5 4.5 0 0 0 4.8 5M27 10h4.5a4.5 4.5 0 0 1-4.8 5M20 23v6M14 33h12M16 29h8v4h-8z"></path><path class="reviews__cup-star" d="M20 9.5l1.2 2.5 2.7.3-2 1.9.5 2.7-2.4-1.3-2.4 1.3.5-2.7-2-1.9 2.7-.3z"></path></svg>
      <span class="reviews__label-text">Kept playing</span>
    </p>
    <h2 class="reviews__title" id="reviews-title" aria-label="High scores">
      <span class="reviews__line">High <span class="reviews__deep">scores</span></span>
    </h2>
    <p class="reviews__lead">What the people who run our machines say once the doors have closed.</p>
  </div>

  <div class="reviews__stage" aria-roledescription="carousel" aria-label="Reviews">
    <button class="reviews__key reviews__key--prev" type="button" aria-label="Previous review"><span class="reviews__key-panel"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M21 12H4M10 6l-6 6 6 6"></path></svg></span></button>
    <div class="reviews__window">
      <span class="reviews__timer" aria-hidden="true"></span>
      <figure class="reviews__quote is-current" aria-roledescription="slide" aria-label="1 of 3">
        <blockquote>The pinball table earns its keep by nine every night. People queue for it, and they never queue for anything here.</blockquote>
        <figcaption>Maren Holt, The Late Arcade</figcaption>
      </figure>
      <figure class="reviews__quote" aria-roledescription="slide" aria-label="2 of 3" hidden>
        <blockquote>They built a four-player cabinet for our lane bar in six weeks and answered the phone every time a coin jammed.</blockquote>
        <figcaption>Teo Vasquez, Ballpark Bowl</figcaption>
      </figure>
      <figure class="reviews__quote" aria-roledescription="slide" aria-label="3 of 3" hidden>
        <blockquote>Our festival tent had one button and a bell. Twelve thousand people pressed it. Nobody asked for the rules.</blockquote>
        <figcaption>Ines Albrecht, Pixel Pier</figcaption>
      </figure>
    </div>
    <button class="reviews__key reviews__key--next" type="button" aria-label="Next review"><span class="reviews__key-panel"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 12h17M14 6l6 6-6 6"></path></svg></span></button>
  </div>

  <div class="reviews__marks" role="group" aria-label="Choose a review">
    <button class="reviews__mark is-current" type="button" aria-label="The Late Arcade" aria-pressed="true">
      <svg viewBox="0 0 120 40" aria-hidden="true"><path class="reviews__fill" d="M22 8a12 12 0 1 0 9 20 10 10 0 0 1-9-20z"></path><text x="38" y="19">THE LATE</text><text x="38" y="31">ARCADE</text></svg>
    </button>
    <button class="reviews__mark" type="button" aria-label="Ballpark Bowl" aria-pressed="false">
      <svg viewBox="0 0 120 40" aria-hidden="true"><path class="reviews__fill" d="M20 6c3 0 4 3 3 6-1 2-1 3 0 5 3 5 3 11-1 17h-4c-4-6-4-12-1-17 1-2 1-3 0-5-1-3 0-6 3-6z"></path><path d="M16.5 14h7"></path><text x="34" y="25">Ballpark Bowl</text></svg>
    </button>
    <button class="reviews__mark" type="button" aria-label="Pixel Pier" aria-pressed="false">
      <svg viewBox="0 0 120 40" aria-hidden="true"><path class="reviews__fill" d="M10 10h6v6h-6zM16 16h6v6h-6zM22 10h6v6h-6zM10 22h6v6h-6zM22 22h6v6h-6z"></path><text x="36" y="25">PIXEL PIER</text></svg>
    </button>
  </div>
</section>

<style>
  .reviews {
    padding: var(--space-xl) var(--edge);
    background: var(--paper);
    color: var(--ink);
  }
  .reviews__head { display: grid; justify-items: center; gap: var(--space-s); margin-bottom: var(--space-l); text-align: center; }
  .reviews__label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(6px, 0.6vw, 10px);
    width: min(100%, 30em);
    margin: 0;
    font: 600 var(--label)/1.7 var(--font-sans);
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }
  .reviews__label-text { flex: 1 1 40%; }
  .reviews__label-text:first-child { text-align: right; }
  .reviews__label-text:last-child { text-align: left; }
  .reviews__cup { flex: none; width: 3.4em; fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linejoin: round; }
  .reviews__cup-star { fill: currentColor; stroke: none; transform-box: fill-box; transform-origin: center; animation: reviews-spin var(--t-spin) linear infinite; }
  .reviews.is-hidden .reviews__cup-star { animation-play-state: paused; }
  @keyframes reviews-spin { from { transform: rotate(360deg); } to { transform: rotate(0deg); } }
  .reviews__title {
    margin: 0;
    font: 900 var(--heading)/0.85 var(--font-sans);
    letter-spacing: -0.02em;
    text-transform: uppercase;
  }
  .reviews__line { display: block; }
  .reviews__word { display: inline-block; white-space: nowrap; }
  .reviews__char { position: relative; display: inline-block; }
  .reviews__glyph { display: inline-block; }
  .reviews.is-armed .reviews__char--rise { contain: paint; }
  .reviews.is-armed .reviews__char--rise .reviews__glyph { transform: translateY(100%); }
  .reviews.is-armed.is-seen .reviews__char--rise .reviews__glyph {
    transform: translateY(0);
    transition: transform var(--t-rise) var(--spring-rise-curve) var(--delay, 0ms);
  }
  .reviews__char--deep { --depth: 0.08em; cursor: pointer; }
  .reviews__char--deep > :not(.reviews__glyph) { position: absolute; top: 0; left: 0; pointer-events: none; user-select: none; }
  .reviews__faux {
    -webkit-text-stroke: max(3px, 0.05em) var(--ink);
    transform: translate(calc(var(--depth) * var(--i) / 8), calc(var(--depth) * var(--i) / -8));
  }
  .reviews__face { transform: translate(var(--depth), calc(var(--depth) * -1)); }
  .reviews__face > * { position: absolute; top: 0; left: 0; }
  .reviews__light { color: var(--paper); }
  .reviews.is-armed .reviews__char--deep { opacity: 0; transition: opacity var(--t-quick) var(--ease-std); }
  .reviews.is-armed .reviews__char--deep.is-out { opacity: 1; }

  .reviews__lead {
    max-width: 24em;
    margin: var(--space-s) 0 0;
    font: 520 var(--opening)/1.47 var(--font-sans);
    letter-spacing: 0.01em;
  }

  .reviews__stage {
    display: grid;
    grid-template-columns: var(--cell) minmax(0, 1fr) var(--cell);
    align-items: end;
    border: var(--hair) solid var(--ink);
  }
  .reviews__window {
    position: relative;
    display: grid;
    min-height: clamp(260px, 24vw, 340px);
    overflow: hidden;
    border-inline: var(--hair) solid var(--ink);
  }
  .reviews__timer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--hair);
    background: var(--ink);
    transform: scaleX(0);
    transform-origin: left;
  }
  .reviews.is-running .reviews__timer { animation: reviews-timer var(--t-timer) linear forwards; }
  .reviews.is-paused .reviews__timer { animation-play-state: paused; }
  @keyframes reviews-timer { from { transform: scaleX(0); } to { transform: scaleX(1); } }

  .reviews__quote {
    grid-area: 1 / 1;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: var(--space-m);
    margin: 0;
    padding: var(--space-l) var(--space-m);
    text-align: center;
    transition: opacity var(--t-panel) var(--ease-expo), transform var(--t-slide) var(--ease-expo);
  }
  .reviews__quote[hidden] { display: grid; visibility: hidden; opacity: 0; transform: translateX(var(--from, 2em)); }
  .reviews__quote.is-leaving { visibility: visible; opacity: 0; transform: translateX(var(--to, -2em)); }
  .reviews__quote blockquote {
    max-width: 21em;
    margin: 0;
    font: 400 var(--large)/1.3 var(--font-sans);
    letter-spacing: -0.02em;
    text-wrap: balance;
  }
  .reviews__quote figcaption {
    color: var(--muted);
    font: 600 var(--label)/1.7 var(--font-sans);
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }

  .reviews__key {
    position: relative;
    display: block;
    width: var(--cell);
    height: var(--cell);
    padding: 0;
    border: 0;
    background: var(--ink);
    color: var(--ink);
    cursor: pointer;
    outline: none;
    -webkit-tap-highlight-color: transparent;
  }
  .reviews__key-panel {
    display: grid;
    place-items: center;
    height: 100%;
    border-top: var(--hair) solid var(--ink);
    background: var(--paper);
    font-size: var(--key);
    transform: translate(var(--lift-x, 0px), var(--lift-y, 0px));
    transition: transform var(--t-panel) var(--ease-expo), background-color var(--t-panel) var(--ease-expo);
  }
  .reviews__key--next .reviews__key-panel { border-left: var(--hair) solid var(--ink); }
  .reviews__key--prev .reviews__key-panel { border-right: var(--hair) solid var(--ink); }
  .reviews__key svg { width: 1.6em; fill: none; stroke: currentColor; stroke-width: 1.4; }
  @media (hover: hover) and (pointer: fine) {
    .reviews__key:hover .reviews__key-panel { --lift-x: 0.8em; --lift-y: -0.8em; border: var(--hair) solid var(--ink); }
  }
  .reviews__key:focus-visible .reviews__key-panel { --lift-x: 0.8em; --lift-y: -0.8em; border: var(--hair) solid var(--ink); outline: 2px solid var(--ink); outline-offset: 3px; }
  .reviews__key:active .reviews__key-panel { --lift-x: 0px; --lift-y: 0px; background: var(--pressed); }

  .reviews__marks {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: var(--space-m);
  }
  .reviews__mark {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 16 / 7;
    min-height: var(--tap);
    padding: 0 clamp(16px, 4vw, 64px);
    border: 0;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    outline: none;
    transition: transform var(--t-quick) var(--ease-std);
  }
  .reviews__mark::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--hair);
    background: var(--guide);
    transition: background-color var(--t-quick) var(--ease-std);
  }
  .reviews__mark.is-current::before { background: var(--ink); }
  .reviews__mark svg {
    width: min(100%, 220px);
    overflow: visible;
    opacity: 0.32;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.4;
    transition: opacity var(--t-panel) var(--ease-expo), transform var(--t-panel) var(--ease-back);
  }
  .reviews__mark text { fill: currentColor; stroke: none; font: 800 12px var(--font-sans); letter-spacing: 0.06em; }
  .reviews__fill { fill: currentColor; stroke: none; }
  .reviews__mark:hover svg { opacity: 0.65; }
  .reviews__mark.is-current svg { opacity: 1; transform: scale(1.06); }
  .reviews__mark:active { transform: scale(0.95); }
  .reviews__mark:focus-visible { outline: 2px solid var(--ink); outline-offset: -4px; }

  @media (max-width: 599px) {
    .reviews__stage { grid-template-columns: 1fr 1fr; }
    .reviews__window { grid-column: 1 / -1; grid-row: 1; border-inline: 0; border-bottom: var(--hair) solid var(--ink); }
    .reviews__key { width: 100%; }
    .reviews__key-panel { border-top: 0; }
    .reviews__mark { aspect-ratio: auto; padding: var(--space-s) 8px; }
  }
  @media (prefers-reduced-motion: reduce) {
    .reviews__cup-star { animation: none; }
    .reviews.is-running .reviews__timer { animation: none; }
  }
</style>

<script>
(() => {
  const still = matchMedia('(prefers-reduced-motion: reduce)');
  const DEPTH_REST = 0.08;
  const DEPTH_HOVER = 0.14;
  const DEPTH_NEAR = 0.105;

  function springLoop() {
    const springs = new Set();
    let frame = 0;
    let last = 0;
    const tick = (now) => {
      const dt = Math.min(0.05, (now - last) / 1000);
      last = now;
      for (const s of springs) {
        if (now < s.startAt) continue;
        const steps = Math.ceil(dt * 240);
        for (let i = 0; i < steps; i++) {
          s.v += (-s.k * (s.x - s.target) - s.c * s.v) * (dt / steps);
          s.x += s.v * (dt / steps);
        }
        if (Math.abs(s.x - s.target) < 1e-4 && Math.abs(s.v) < 1e-3) { s.x = s.target; s.v = 0; springs.delete(s); }
        s.apply(s.x);
      }
      frame = springs.size ? requestAnimationFrame(tick) : 0;
    };
    return (s) => { springs.add(s); if (!frame) { last = performance.now(); frame = requestAnimationFrame(tick); } };
  }

  function letter(text, deep) {
    const char = document.createElement('span');
    char.className = `reviews__char reviews__char--${deep ? 'deep' : 'rise'}`;
    char.innerHTML = '<span class="reviews__glyph"></span>';
    if (deep) {
      for (let i = 0; i < 8; i++) char.insertAdjacentHTML('beforeend', `<span class="reviews__faux" style="--i:${i}"></span>`);
      char.insertAdjacentHTML('beforeend', '<span class="reviews__face"><span class="reviews__faux" style="--i:0"></span><span class="reviews__light"></span></span>');
    }
    char.querySelectorAll('.reviews__glyph, .reviews__faux, .reviews__light').forEach((layer) => { layer.textContent = text; });
    return char;
  }

  function split(title, charStep, wordStep) {
    let index = 0;
    let wordIndex = 0;
    for (const line of title.querySelectorAll('.reviews__line')) {
      const words = [];
      for (const node of line.childNodes) {
        const deep = node.nodeType === 1 && node.classList.contains('reviews__deep');
        for (const text of node.textContent.split(/\s+/).filter(Boolean)) {
          const word = document.createElement('span');
          word.className = 'reviews__word';
          const letters = [...text];
          letters.forEach((each, n) => {
            const char = letter(each, deep);
            char.style.zIndex = letters.length - n;
            char.dataset.at = index * charStep + wordIndex * wordStep;
            char.querySelector('.reviews__glyph').style.setProperty('--delay', `${char.dataset.at}ms`);
            word.append(char);
            index++;
          });
          words.push(word);
          wordIndex++;
        }
      }
      line.replaceChildren();
      words.forEach((word, n) => { if (n) line.append(' '); line.append(word); });
      line.setAttribute('aria-hidden', 'true');
    }
  }

  function springs(root, add) {
    const [k, c, v0] = getComputedStyle(root).getPropertyValue('--spring-extrude').trim().split(/\s+/).map(Number);
    const chars = [...root.querySelectorAll('.reviews__char--deep')];
    chars.forEach((char) => {
      char.spring = { x: DEPTH_REST, v: 0, target: DEPTH_REST, k, c, startAt: 0, apply: (x) => char.style.setProperty('--depth', `${x}em`) };
    });
    const aim = (char, depth) => {
      if (still.matches) { char.style.setProperty('--depth', `${depth}em`); return; }
      char.spring.target = depth;
      char.spring.startAt = 0;
      add(char.spring);
    };
    chars.forEach((char, n) => char.addEventListener('pointerenter', () =>
      chars.forEach((other, m) => aim(other, m === n ? DEPTH_HOVER : Math.abs(m - n) === 1 ? DEPTH_NEAR : DEPTH_REST))));
    if (chars[0]) chars[0].parentElement.addEventListener('pointerleave', () => chars.forEach((char) => aim(char, DEPTH_REST)));
    return () => {
      const now = performance.now();
      chars.forEach((char) => {
        Object.assign(char.spring, { x: 0, v: v0 * DEPTH_REST, target: DEPTH_REST, startAt: now + Number(char.dataset.at) });
        char.style.setProperty('--depth', '0em');
        setTimeout(() => char.classList.add('is-out'), Number(char.dataset.at));
        add(char.spring);
      });
    };
  }

  function carousel(root) {
    const quotes = [...root.querySelectorAll('.reviews__quote')];
    const marks = [...root.querySelectorAll('.reviews__mark')];
    const timer = root.querySelector('.reviews__timer');
    let current = 0;
    let visible = false;
    let hovered = false;

    const restartTimer = () => {
      root.classList.remove('is-running');
      void timer.offsetWidth;
      if (!still.matches) root.classList.add('is-running');
    };
    const show = (next, direction) => {
      if (next === current) return;
      const leaving = quotes[current];
      const entering = quotes[next];
      leaving.style.setProperty('--to', `${-2 * direction}em`);
      leaving.classList.add('is-leaving');
      leaving.classList.remove('is-current');
      setTimeout(() => { leaving.hidden = true; leaving.classList.remove('is-leaving'); }, 400);
      entering.style.setProperty('--from', `${2 * direction}em`);
      entering.style.transition = 'none';
      entering.hidden = true;
      void entering.offsetWidth;
      entering.style.transition = '';
      entering.hidden = false;
      entering.classList.add('is-current');
      marks.forEach((mark, n) => { mark.classList.toggle('is-current', n === next); mark.setAttribute('aria-pressed', String(n === next)); });
      current = next;
      restartTimer();
    };
    const step = (direction) => show((current + direction + quotes.length) % quotes.length, direction);
    const syncPause = () => root.classList.toggle('is-paused', hovered || !visible);

    root.querySelector('.reviews__key--prev').addEventListener('click', () => step(-1));
    root.querySelector('.reviews__key--next').addEventListener('click', () => step(1));
    marks.forEach((mark, n) => mark.addEventListener('click', () => show(n, n > current ? 1 : -1)));
    timer.addEventListener('animationend', () => step(1));
    const stage = root.querySelector('.reviews__stage');
    stage.addEventListener('pointerenter', () => { hovered = true; syncPause(); });
    stage.addEventListener('pointerleave', () => { hovered = false; syncPause(); });
    new IntersectionObserver(([entry]) => {
      visible = entry.isIntersecting;
      root.classList.toggle('is-hidden', !visible);
      syncPause();
    }).observe(root);
    restartTimer();
  }

  for (const root of document.querySelectorAll('.reviews')) {
    const style = getComputedStyle(root);
    split(root.querySelector('.reviews__title'), parseFloat(style.getPropertyValue('--stagger-char')), parseFloat(style.getPropertyValue('--stagger-word')));
    const add = springLoop();
    const pushOut = springs(root, add);
    carousel(root);
    if (still.matches) continue;
    root.classList.add('is-armed');
    const seen = new IntersectionObserver(([entry]) => {
      if (!entry.isIntersecting) return;
      seen.disconnect();
      requestAnimationFrame(() => { root.classList.add('is-seen'); pushOut(); });
    }, { threshold: 0.15 });
    seen.observe(root);
  }
})();
</script>

Similar components

Pink voice card

Pink voice card

Word-by-word testimonial

Word-by-word testimonial

Press quote

Press quote

Slab quote

Slab quote

Mixed-type headline

Mixed-type headline

Services list

Services list

Glass word with falling stickers

Glass word with falling stickers

Ruled hero

Ruled hero