kitbash Sign in Connect agent
Components

Counter loader

The signature opening: a 90px percent counter, a rule growing down column 3 with the role label riding its foot, then the counter melts into goo, corner chrome slides in and the pale split wordmark appears. Replay button.

Part of the style

Ink Bloom Column

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

Preview

Code
<style>
/* Goes after the pack's base.css */
@import url("https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;800&family=Newsreader:opsz,wght@6..72,400;6..72,600&display=swap");
:root {
  --paper: #bacd82;
  --ink: #000000;
  --mist: #b0c27b;
  --tint: rgba(0, 0, 0, 0.05);
  --hairline: rgba(0, 0, 0, 0.1);
  --ink-ghost: rgba(0, 0, 0, 0.1);
  --ink-soft: rgba(0, 0, 0, 0.5);
  --menu-1: #94a367;
  --menu-2: #9eae6e;
  --menu-3: #a7b975;
  --theme-slate: #8c9b61;
  --on-ink: #bacd82;
  --theme-ember: #508a36;
  --theme-oxblood: #4f8934;
  --theme-lichen: #6c8452;
  --font-display: "Newsreader", "Iowan Old Style", "Times New Roman", serif;
  --font-body: "Hanken Grotesk", "Helvetica Neue", Arial, sans-serif;
}
</style>

<section class="loader" aria-label="Loading screen">
  <svg class="loader__defs" aria-hidden="true" focusable="false"><defs></defs></svg>
  <span class="loader__square" aria-hidden="true"></span>
  <span class="loader__pill" aria-hidden="true">Menu</span>
  <div class="loader__track">
    <span class="loader__rule" aria-hidden="true"></span>
    <p class="loader__label"><span class="loader__line">Sound Designer</span><span class="loader__line">&amp; Engineer</span></p>
  </div>
  <p class="loader__count" role="status" aria-live="off"><span class="loader__line"><span class="loader__number">0</span>%</span></p>
  <p class="loader__name" aria-label="nachklang">
    <span class="loader__half"><span class="loader__line">nach</span></span>
    <span class="loader__half"><span class="loader__line">klang</span></span>
  </p>
  <button class="loader__replay" type="button" disabled>Replay</button>
</section>

<style>
  .loader {
    position: relative;
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    column-gap: var(--gap);
    height: max(560px, 62.5vw);
    padding: var(--edge);
    overflow: clip;
    background: var(--paper);
  }
  .loader__defs {
    position: absolute;
    width: 0;
    height: 0;
  }
  .loader__line {
    display: block;
  }

  /* The corner chrome waits off screen and slides in when the count is done. */
  .loader__square {
    position: absolute;
    top: var(--edge);
    left: var(--edge);
    width: max(12px, 1.1111vw);
    height: max(12px, 1.1111vw);
    background: var(--tint);
  }
  .loader__pill {
    position: absolute;
    top: var(--edge);
    right: var(--edge);
    padding: 4px max(8px, 0.5556vw);
    border-radius: var(--radius-m);
    background: var(--ink);
    color: var(--on-ink);
  }
  .is-waiting .loader__square { translate: -5vw -5vw; }
  .is-waiting .loader__pill { translate: 5vw -5vw; }
  .is-settled .loader__square,
  .is-settled .loader__pill {
    translate: 0 0;
    transition: translate var(--dur-m) var(--ease-out);
  }

  /* The rule grows down the right edge of column 3, carrying its label at the foot. */
  .loader__track {
    position: relative;
    grid-column: 3;
    grid-row: 1;
    height: 70%;
  }
  .loader__rule {
    position: absolute;
    top: 0;
    right: calc(var(--gap) / -2);
    width: var(--stroke);
    height: calc(var(--grow, 1) * 100%);
    background: var(--ink);
  }
  .loader__label {
    position: absolute;
    left: 0;
    top: calc(var(--grow, 1) * 100%);
    margin: 0;
    translate: 0 -100%;
    white-space: nowrap;
  }

  .loader__count {
    position: absolute;
    left: var(--edge);
    bottom: var(--edge);
    margin: 0;
    font-size: var(--text-xl);
    line-height: var(--leading-xl);
    letter-spacing: var(--tracking-xl);
  }

  /* The split wordmark rests at the bottom corners in a pale ink. */
  .loader__name {
    position: absolute;
    inset: auto var(--edge) var(--edge);
    display: flex;
    justify-content: space-between;
    margin: 0;
    color: var(--ink-ghost);
    font-size: var(--text-xl);
    line-height: var(--leading-xl);
    letter-spacing: var(--tracking-xl);
    pointer-events: none;
  }
  .is-counting .loader__name { visibility: hidden; }

  .loader__replay {
    position: absolute;
    right: var(--edge);
    bottom: calc(var(--edge) + var(--text-xl) * var(--leading-xl) + var(--space-s));
    min-width: var(--tap);
    min-height: var(--tap);
    padding: 0;
    border: 0;
    background: none;
    color: var(--ink);
    font: inherit;
    letter-spacing: inherit;
    text-align: right;
    text-decoration: underline;
    text-decoration-thickness: var(--stroke);
    text-underline-offset: 3px;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--dur-s) var(--ease-out);
  }
  .loader__replay:not(:disabled) { opacity: 1; }
  .loader__replay:hover { text-decoration-color: transparent; }
  .loader__replay:focus-visible { outline: var(--stroke) solid var(--ink); outline-offset: 2px; }

  @media (max-width: 47.99rem) {
    .loader {
      grid-template-columns: repeat(4, minmax(0, 1fr));
      height: max(560px, 150vw);
    }
    .loader__track { grid-column: 2; height: 62%; }
    .loader__label { left: auto; right: calc(100% + var(--gap)); translate: 100% -100%; }
    .is-waiting .loader__square { translate: -25vw -25vw; }
    .is-waiting .loader__pill { translate: 25vw -25vw; }
  }
</style>

<script>
(() => {
  const still = matchMedia('(prefers-reduced-motion: reduce)');
  const COUNT_MS = 2000;
  const RULE_MS = 4000;
  let filters = 0;

  function token(root, name) {
    return getComputedStyle(root).getPropertyValue(name).trim();
  }
  function ms(root, name) {
    return parseFloat(token(root, name)) * 1000;
  }

  function bezier(spec) {
    const [x1, y1, x2, y2] = spec.match(/-?[\d.]+/g).map(Number);
    const curve = (a, b, t) => 3 * a * t * (1 - t) ** 2 + 3 * b * t * t * (1 - t) + t ** 3;
    return (x) => {
      let low = 0, high = 1, t = x;
      for (let step = 0; step < 24; step += 1) {
        t = (low + high) / 2;
        if (curve(x1, x2, t) < x) low = t; else high = t;
      }
      return curve(y1, y2, t);
    };
  }
  const linear = (x) => x;

  function tween(duration, delay, ease, update) {
    return new Promise((done) => {
      const start = performance.now() + delay;
      const frame = (now) => {
        const progress = Math.min(1, Math.max(0, (now - start) / duration));
        if (now >= start) update(ease(progress));
        if (progress < 1) requestAnimationFrame(frame); else done();
      };
      requestAnimationFrame(frame);
    });
  }

  /* Goo: a heavy blur pushed through a hard alpha threshold, so letters grow out of ink blobs. */
  function gooFilter(root, line) {
    if (line._goo) return line._goo;
    const svg = 'http://www.w3.org/2000/svg';
    const filter = document.createElementNS(svg, 'filter');
    const blur = document.createElementNS(svg, 'feGaussianBlur');
    const matrix = document.createElementNS(svg, 'feColorMatrix');
    filters += 1;
    filter.id = `loader-goo-${filters}-${Math.random().toString(36).slice(2, 7)}`;
    Object.entries({ x: '-25%', y: '-25%', width: '150%', height: '150%', 'color-interpolation-filters': 'sRGB' }).forEach(([key, value]) => filter.setAttribute(key, value));
    blur.setAttribute('in', 'SourceGraphic');
    matrix.setAttribute('type', 'matrix');
    filter.append(blur, matrix);
    root.querySelector('.loader__defs defs').append(filter);
    const scale = parseFloat(getComputedStyle(line).fontSize) / 90;
    line._goo = {
      set(deviation, amp, offset) {
        blur.setAttribute('stdDeviation', (deviation * scale).toFixed(2));
        matrix.setAttribute('values', `1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 ${amp} ${offset}`);
        line.style.filter = `url(#${filter.id})`;
      },
    };
    return line._goo;
  }

  function reveal(root, lines, delay = 0) {
    const easeOut = bezier(token(root, '--ease-out'));
    const durL = ms(root, '--dur-l');
    const stagger = ms(root, '--stagger');
    const most = parseFloat(token(root, '--goo-blur'));
    return Promise.all(lines.map((line, index) => {
      line.style.visibility = 'visible';
      if (still.matches) return Promise.resolve();
      const goo = gooFilter(root, line);
      const state = { deviation: most, amp: 20, offset: -8 };
      const paint = () => goo.set(state.deviation, state.amp, state.offset);
      paint();
      const start = delay + index * stagger;
      return Promise.all([
        tween(durL, start, easeOut, (eased) => { state.deviation = most * (1 - eased); paint(); }),
        tween(durL * 0.35, start + durL * 0.65, linear, (eased) => { state.amp = 20 - 19 * eased; state.offset = -8 + 8 * eased; paint(); }),
      ]).then(() => { line.style.filter = ''; });
    }));
  }

  function hide(root, lines, delay = 0) {
    const easeIn = bezier(token(root, '--ease-in'));
    const durS = ms(root, '--dur-s');
    const stagger = ms(root, '--stagger') / 2;
    const most = parseFloat(token(root, '--goo-blur'));
    return Promise.all(lines.map((line, index) => {
      if (still.matches) { line.style.visibility = 'hidden'; return Promise.resolve(); }
      const goo = gooFilter(root, line);
      const state = { deviation: 0, amp: 1, offset: 0 };
      const paint = () => goo.set(state.deviation, state.amp, state.offset);
      const start = delay + index * stagger;
      return Promise.all([
        tween(durS * 0.3, start, linear, (eased) => { state.amp = 1 + 19 * eased; state.offset = -8 * eased; paint(); }),
        tween(durS, start, easeIn, (eased) => { state.deviation = most * eased; paint(); }),
      ]).then(() => { line.style.visibility = 'hidden'; line.style.filter = ''; });
    }));
  }

  function play(root) {
    const number = root.querySelector('.loader__number');
    const replay = root.querySelector('.loader__replay');
    const countLines = [...root.querySelectorAll('.loader__count .loader__line')];
    const labelLines = [...root.querySelectorAll('.loader__label .loader__line')];
    const nameLines = [...root.querySelectorAll('.loader__name .loader__line')];
    const easeInOut = bezier(token(root, '--ease-in-out'));
    replay.disabled = true;
    root.classList.remove('is-settled');
    root.classList.add('is-waiting', 'is-counting');
    nameLines.forEach((line) => { line.style.visibility = 'hidden'; });
    countLines.forEach((line) => { line.style.visibility = 'visible'; });
    number.textContent = '0';
    root.style.setProperty('--grow', 0);

    if (still.matches) {
      number.textContent = '100';
      root.style.setProperty('--grow', 1);
      root.classList.remove('is-waiting', 'is-counting');
      root.classList.add('is-settled');
      nameLines.forEach((line) => { line.style.visibility = 'visible'; });
      countLines.forEach((line) => { line.style.visibility = 'hidden'; });
      replay.disabled = false;
      return;
    }

    reveal(root, [...countLines, ...labelLines]);
    const rule = tween(RULE_MS, 0, easeInOut, (eased) => root.style.setProperty('--grow', eased));
    tween(COUNT_MS, 0, easeInOut, (eased) => { number.textContent = Math.round(eased * 100); }).then(() => {
      hide(root, countLines);
      root.classList.remove('is-counting');
      root.classList.add('is-settled');
      requestAnimationFrame(() => root.classList.remove('is-waiting'));
      return Promise.all([reveal(root, nameLines), rule]);
    }).then(() => { replay.disabled = false; });
  }

  function setUp(root) {
    let started = false;
    root.querySelector('.loader__replay').addEventListener('click', () => play(root));
    new IntersectionObserver(([entry], observer) => {
      if (!entry.isIntersecting || started) return;
      started = true;
      observer.disconnect();
      play(root);
    }, { threshold: 0.2 }).observe(root);
  }

  document.querySelectorAll('.loader').forEach(setUp);
})();
</script>

Similar components

Badge intro

Badge intro

Wordmark intro

Wordmark intro

Greeting loader

Greeting loader

Boot screen

Boot screen

Wordmark intro

Wordmark intro

Loading screen

Loading screen

Intro loader

Intro loader

Work grid with pill

Work grid with pill