kitbash Sign in Connect agent
Components

Wave ribbon

A lime ribbon on an S-curve between two section colours with text and rolling stickers running along it. Scroll speed and direction push the text. Set --wave-above and --wave-below to the neighbouring section colours.

Part of the style

Sticker Shock

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --lime: #ffffff;
  --paper: #ffffff;
  --pine: #02020a;
  --ink: #000000;
  --shade: rgba(0, 0, 0, 0.3);
  --forest: #0e0e29;
  --sun: #5a7ed1;
  --kraft: #6e7fa3;
  --kraft-ink: #000004;
  --tape: #6b7895;
  --kraft-light: #7281a1;
  --note: #5a7ac3;
  --coral: #6d7aac;
  --tangerine: #6a79b1;
  --sky: #73779a;
  --iris: #4466b6;
  --grape: #010035;
  --candy: #6d7aac;
}
</style>

<section class="wave-band" aria-label="Boring sandwiches fear us. Pass the jar.">
  <svg class="wave-band__svg" viewBox="0 0 1440 330" preserveAspectRatio="xMidYMid slice" aria-hidden="true">
    <path class="wave-band__ribbon" id="wave-band-path" d="M-240,205 C120,330 470,70 860,128 S1480,300 1700,90" />
    <text class="wave-band__text" dy="0.33em">
      <textPath class="wave-band__run" href="#wave-band-path"><tspan class="wave-band__phrase">Boring sandwiches fear us</tspan><tspan class="wave-band__phrase" dx="150">Pass the jar</tspan><tspan class="wave-band__phrase" dx="150">Boring sandwiches fear us</tspan><tspan class="wave-band__phrase" dx="150">Pass the jar</tspan><tspan class="wave-band__phrase" dx="150">Boring sandwiches fear us</tspan><tspan class="wave-band__phrase" dx="150">Pass the jar</tspan><tspan class="wave-band__phrase" dx="150">Boring sandwiches fear us</tspan><tspan class="wave-band__phrase" dx="150">Pass the jar</tspan></textPath>
    </text>
    <g class="wave-band__lids"></g>
  </svg>
</section>

<style>
  .wave-band {
    --wave-above: var(--forest);
    --wave-below: var(--tangerine);
    --wave-cut: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 330' preserveAspectRatio='xMidYMid slice'%3E%3Cpath d='M-240,205 C120,330 470,70 860,128 S1480,300 1700,90 V-100 H-240 Z'/%3E%3C/svg%3E");
    position: relative;
    z-index: 1;
    height: clamp(11.5rem, 23vw, 20.5rem);
    margin-bottom: -1px;
    background: var(--crease) 0 0 / var(--crease-size), var(--wave-below);
    background-blend-mode: soft-light;
    overflow: hidden;
  }

  /* the colour above the ribbon: a full layer cut along the same curve the ribbon follows */
  .wave-band::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--crease) 0 0 / var(--crease-size), var(--wave-above);
    background-blend-mode: soft-light;
    -webkit-mask: var(--wave-cut) 0 0 / 100% 100% no-repeat;
    mask: var(--wave-cut) 0 0 / 100% 100% no-repeat;
  }

  .wave-band__svg {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
  }

  .wave-band__ribbon {
    fill: none;
    stroke: var(--lime);
    stroke-width: 124;
  }

  .wave-band__text {
    fill: var(--pine);
    font: 900 92px / 1 var(--font-display);
    text-transform: uppercase;
    letter-spacing: 0.01em;
    word-spacing: 0.08em;
  }

  .wave-band__lid-rim {
    fill: var(--sun);
  }

  .wave-band__lid-face {
    fill: color-mix(in srgb, var(--sun) 42%, var(--paper));
  }

  .wave-band__lid-name {
    fill: var(--ink);
    font: 900 21px / 1 var(--font-display);
    text-transform: uppercase;
    text-anchor: middle;
  }
</style>

<script>
  (() => {
    const GAP = 150;
    const CRUISE = 70;
    const SCROLL_PUSH = 1.6;
    const SVG = 'http://www.w3.org/2000/svg';
    const calm = matchMedia('(prefers-reduced-motion: reduce)');

    const drawLid = () => {
      const lid = document.createElementNS(SVG, 'g');
      lid.innerHTML =
        '<circle class="wave-band__lid-rim" r="50"/><circle class="wave-band__lid-face" r="41"/>' +
        '<text class="wave-band__lid-name" y="-3">Loud</text><text class="wave-band__lid-name" y="17">Jar</text>';
      return lid;
    };

    const setUp = (band) => {
      const path = band.querySelector('.wave-band__ribbon');
      const run = band.querySelector('.wave-band__run');
      const phrases = [...band.querySelectorAll('.wave-band__phrase')];
      const lidLayer = band.querySelector('.wave-band__lids');
      const lids = phrases.map(() => lidLayer.appendChild(drawLid()));
      const pathLength = path.getTotalLength();
      let starts = [];
      let loop = 0;
      let offset = 0;
      let lastScroll = scrollY;
      let lastTime = 0;

      const measure = () => {
        let cursor = 0;
        starts = phrases.map((phrase) => {
          const start = cursor;
          cursor += phrase.getComputedTextLength() + GAP;
          return start;
        });
        loop = starts[2];
      };

      const place = () => {
        run.setAttribute('startOffset', offset);
        lids.forEach((lid, index) => {
          const along = offset + starts[index] - GAP / 2;
          const onPath = along > 0 && along < pathLength;
          lid.style.display = onPath ? '' : 'none';
          if (!onPath) return;
          const here = path.getPointAtLength(along);
          const ahead = path.getPointAtLength(along + 2);
          const angle = (Math.atan2(ahead.y - here.y, ahead.x - here.x) * 180) / Math.PI;
          lid.setAttribute('transform', `translate(${here.x} ${here.y}) rotate(${angle + offset * 0.4})`);
        });
      };

      const tick = (time) => {
        const elapsed = Math.min(0.05, (time - lastTime) / 1000 || 0);
        const scrolled = scrollY - lastScroll;
        lastTime = time;
        lastScroll = scrollY;
        offset -= CRUISE * elapsed + scrolled * SCROLL_PUSH;
        offset = ((offset % loop) - loop) % loop;
        place();
        if (!calm.matches) requestAnimationFrame(tick);
      };

      document.fonts.ready.then(() => {
        measure();
        offset = -loop * 0.35;
        place();
        if (!calm.matches) requestAnimationFrame(tick);
      });
    };

    document.querySelectorAll('.wave-band').forEach(setUp);
  })();
</script>

Similar components

Red word band

Red word band

Reed ribbon

Reed ribbon

Band and case accordion

Band and case accordion

Ticker and nav bar

Ticker and nav bar

Mixed-type headline

Mixed-type headline

Pill menu bar

Pill menu bar

Greeting loader

Greeting loader

Big call and footer

Big call and footer