kitbash Sign in Connect agent
Components

Scramble loader

Black opening screen with a serif LOADING word, mono fragments decoding around it and a counting hairline gauge.

Part of the style

Pewter Haze Readout

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --fog-core: #873323;
  --fog-mid: #d25a43;
  --fog-edge: #db634b;
  --night: #db634b;
  --ink: #190f08;
  --ink-soft: rgba(25, 15, 8, 0.62);
  --ink-faint: rgba(25, 15, 8, 0.28);
  --veil: rgba(25, 15, 8, 0.08);
  --shade: rgba(219, 99, 75, 0.35);
  --iris-a: #bdc8a2;
  --iris-b: #debdab;
  --iris-c: #d7c1ac;
  --iris-d: #bdc8a2;
}
</style>

<section class="loader" aria-label="Loading screen">
  <div class="loader__center">
    <p class="loader__frag loader__frag--n" data-text="Kelda / light & sound">Kelda / light &amp; sound</p>
    <p class="loader__frag loader__frag--w" data-text="Signal warm">Signal warm</p>
    <h2 class="loader__word">Loading</h2>
    <p class="loader__frag loader__frag--e" data-text="Lens 04 ready">Lens 04 ready</p>
    <p class="loader__frag loader__frag--s" data-text="52°N — 4°E">52°N — 4°E</p>
  </div>
  <div class="loader__gauge" role="progressbar" aria-label="Loading progress" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0">
    <span class="loader__fill"></span>
    <span class="loader__count">0%</span>
  </div>
</section>

<style>
  .loader {
    position: relative;
    display: grid;
    place-items: center;
    min-height: clamp(26rem, 52vw, 45rem);
    padding: var(--section) var(--edge);
    background: var(--night);
    color: var(--ink);
    overflow: hidden;
  }
  .loader__center {
    position: relative;
    display: grid;
    grid-template-columns: auto auto auto;
    grid-template-areas: ". n ." "w word e" ". s .";
    align-items: center;
    justify-items: center;
    gap: var(--space-xs) var(--space-s);
  }
  .loader__word {
    grid-area: word;
    margin: 0;
    font: 400 var(--display-m)/1 var(--font-display);
    letter-spacing: var(--track-display);
    text-transform: uppercase;
  }
  .loader__frag {
    margin: 0;
    color: var(--ink-soft);
    font-size: var(--text-s);
    white-space: nowrap;
  }
  .loader__frag--n { grid-area: n; }
  .loader__frag--w { grid-area: w; justify-self: end; }
  .loader__frag--e { grid-area: e; justify-self: start; }
  .loader__frag--s { grid-area: s; }
  .loader__gauge {
    position: absolute;
    inset: auto var(--edge) var(--edge);
    height: 6px;
    border: var(--line) solid var(--ink-faint);
  }
  .loader__fill {
    position: absolute;
    inset: 1px auto 1px 1px;
    width: calc((100% - 2px) * var(--progress, 0));
    background: var(--ink);
  }
  .loader__count {
    position: absolute;
    top: calc(100% + var(--space-xs));
    left: calc(100% * var(--progress, 0));
    translate: -100% 0;
    font-size: var(--text-s);
  }
  .loader.is-done .loader__center {
    opacity: 0.25;
    transition: opacity var(--glide) var(--ease);
  }
  @media (max-width: 40rem) {
    .loader__center {
      grid-template-columns: auto;
      grid-template-areas: "n" "w" "word" "e" "s";
    }
    .loader__frag--w, .loader__frag--e { justify-self: center; }
  }
</style>

<script>
(() => {
  const glyphs = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789*/<>#%&';
  const still = matchMedia('(prefers-reduced-motion: reduce)');

  function scramble(el, step) {
    const text = el.dataset.text;
    let frame = 0;
    clearInterval(el._timer);
    el._timer = setInterval(() => {
      frame += 1;
      el.textContent = [...text].map((ch, i) => (ch === ' ' || i < frame / 2 ? ch : glyphs[Math.floor(Math.random() * glyphs.length)])).join('');
      if (frame / 2 >= text.length) { clearInterval(el._timer); el.textContent = text; }
    }, step);
  }

  for (const root of document.querySelectorAll('.loader')) {
    const gauge = root.querySelector('.loader__gauge');
    const count = root.querySelector('.loader__count');
    const frags = root.querySelectorAll('.loader__frag');
    const step = parseFloat(getComputedStyle(root).getPropertyValue('--scramble')) || 28;
    let start = 0;
    let frame = 0;
    const set = (p) => {
      root.style.setProperty('--progress', p);
      const pct = Math.round(p * 100);
      count.textContent = pct + '%';
      gauge.setAttribute('aria-valuenow', pct);
    };
    if (still.matches) { set(1); continue; }
    const tick = (now) => {
      if (!start) { start = now; root.classList.remove('is-done'); frags.forEach((f) => scramble(f, step)); }
      const t = Math.min(1, (now - start) / 2400);
      set(1 - Math.pow(1 - t, 2.2));
      if (t >= 1) {
        root.classList.add('is-done');
        if (now - start > 4200) start = 0;
      }
      frame = requestAnimationFrame(tick);
    };
    new IntersectionObserver(([entry]) => {
      cancelAnimationFrame(frame);
      if (entry.isIntersecting) { start = 0; frame = requestAnimationFrame(tick); }
    }).observe(root);
  }
})();
</script>

Similar components

Lens-scale intro

Lens-scale intro

Wordmark intro

Wordmark intro

Letter gathering intro

Letter gathering intro

Boot screen

Boot screen

Thumbnail ring loader

Thumbnail ring loader

Blur-in statement

Blur-in statement

Intro loader

Intro loader

Neon Mark Loader

Neon Mark Loader