kitbash Sign in Connect agent
Components

Wordmark intro

Signature piece: the huge _mensula slides in at the bottom right and folds letter by letter down to _m; replays on a button.

Part of the style

Shelf Atelier

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --ink: #6d3528;
  --paper: #ffffff;
  --line: #c8c1af;
  --line-soft: #e1ded4;
  --scrim: rgba(109, 53, 40, 0.2);
}
</style>

<section class="intro" aria-label="_mensula, atelier">
  <div class="intro__corner">
    <a class="intro__small" href="#">_mensula</a>
    <p class="intro__line">Taller Ojeda_Brandt. Buildings, furniture and teaching, between Valencia and Ghent.</p>
  </div>
  <button class="intro__replay" type="button">_replay</button>
  <div class="intro__mark" aria-hidden="true"><span class="intro__glyph">_</span><span class="intro__glyph">m</span><span class="intro__glyph intro__glyph--fold">e</span><span class="intro__glyph intro__glyph--fold">n</span><span class="intro__glyph intro__glyph--fold">s</span><span class="intro__glyph intro__glyph--fold">u</span><span class="intro__glyph intro__glyph--fold">l</span><span class="intro__glyph intro__glyph--fold">a</span></div>
</section>

<style>
  .intro {
    position: relative;
    height: clamp(360px, 60vw, 680px);
    overflow: hidden;
    background: var(--paper);
    color: var(--ink);
  }
  .intro__corner {
    position: absolute;
    top: var(--edge);
    left: var(--edge);
    max-width: 22em;
    opacity: 0;
    transition: opacity var(--time) var(--ease);
  }
  .intro__small {
    display: inline-flex;
    align-items: center;
    min-height: var(--tap);
    margin-top: -12px;
    color: inherit;
    font-weight: var(--weight-bold);
    text-decoration: none;
  }
  .intro__line {
    margin: 0;
  }
  .intro__replay {
    position: absolute;
    top: var(--edge);
    right: var(--edge);
    min-width: var(--tap);
    min-height: var(--tap);
    margin-top: -12px;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-weight: var(--weight-bold);
    letter-spacing: inherit;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--time) var(--ease);
  }
  .intro__small:hover,
  .intro__replay:hover {
    text-decoration: underline;
    text-decoration-thickness: var(--hair);
    text-underline-offset: 3px;
  }
  .intro__small:focus-visible,
  .intro__replay:focus-visible {
    outline: var(--hair) solid var(--ink);
    outline-offset: 2px;
  }
  .intro.is-done .intro__corner,
  .intro.is-done .intro__replay {
    opacity: 1;
  }

  /* The word sits on the bottom right; folding letters lose their width so the mark slides right as it shrinks. */
  .intro__mark {
    position: absolute;
    right: var(--edge);
    bottom: calc(var(--edge) - 0.1em);
    display: flex;
    font-family: var(--font-display);
    font-size: var(--text-huge);
    font-weight: var(--weight-bold);
    line-height: 0.8;
    letter-spacing: -0.035em;
    white-space: nowrap;
    transform: translateX(120%);
  }
  .intro__glyph {
    display: inline-block;
    overflow: hidden;
  }
  .intro.is-still .intro__mark {
    transform: none;
  }
  .intro.is-still .intro__glyph--fold {
    width: 0;
  }
</style>

<script>
  (() => {
    const SLIDE_MS = 900;
    const FOLD_START_MS = 1500;
    const FOLD_MS = 520;
    const FOLD_STEP_MS = 40;
    const easeOut = 'cubic-bezier(0.19, 1, 0.22, 1)';
    const prefersStill = matchMedia('(prefers-reduced-motion: reduce)');

    function showFinal(root) {
      root.classList.add('is-still', 'is-done');
    }

    function play(root) {
      const mark = root.querySelector('.intro__mark');
      const folds = [...root.querySelectorAll('.intro__glyph--fold')];
      root.getAnimations({ subtree: true }).forEach((animation) => animation.cancel());
      root.classList.remove('is-still', 'is-done');
      if (prefersStill.matches) return showFinal(root);

      mark.animate([{ transform: 'translateX(120%)' }, { transform: 'translateX(0)' }], {
        duration: SLIDE_MS, delay: 250, easing: easeOut, fill: 'forwards',
      });
      folds.forEach((glyph, order) => {
        glyph.animate([{ width: `${glyph.scrollWidth}px`, opacity: 1 }, { width: '0px', opacity: 0 }], {
          duration: FOLD_MS, delay: FOLD_START_MS + order * FOLD_STEP_MS, easing: easeOut, fill: 'forwards',
        });
      });
      setTimeout(() => root.classList.add('is-done'), FOLD_START_MS);
    }

    const firstView = new IntersectionObserver((entries) => {
      for (const entry of entries) {
        if (!entry.isIntersecting) continue;
        firstView.unobserve(entry.target);
        play(entry.target);
      }
    }, { threshold: 0.3 });

    for (const root of document.querySelectorAll('.intro')) {
      root.querySelector('.intro__replay').addEventListener('click', () => play(root));
      firstView.observe(root);
    }
  })();
</script>

Similar components

Counter loader

Counter loader

Wordmark intro

Wordmark intro

Badge intro

Badge intro

Boot screen

Boot screen

Intro loader

Intro loader

Greeting loader

Greeting loader

Loading screen

Loading screen

Corner nav with stepped panels

Corner nav with stepped panels