kitbash Sign in Connect agent
Components

Redacted line

Sentences with secret words set as shuffling block glyphs; hover or focus pops a bouncing bubble with typing dots, then a hint.

Part of the style

Pixel Redaction Notes

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=Inter:opsz,wght@14..32,400..700&family=Fraunces:ital,opsz,wght@1,9..144,400..600&display=swap");
:root {
  --paper: #b9a391;
  --paper-depth: #bea896;
  --well: #a5907e;
  --line: #a5907e;
  --marker: #94806f;
  --ink: #000000;
  --ink-soft: #1c0d06;
  --ink-faint: #665445;
  --dot: rgba(0, 0, 0, 0.5);
  --font-body: "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}
</style>

<section class="redact">
  <div class="redact__inner">
    <h2 class="redact__label">In the workshop</h2>
    <p class="redact__text">
      On the side I'm building
      <button class="redact__secret is-open" type="button" aria-describedby="redact-hint-1">
        <span class="redact__glyphs" aria-hidden="true" data-length="9">▓▓░▒█░░▓▒</span>
        <span class="redact__sr">a secret project</span>
        <span class="redact__bubble" role="tooltip">
          <span class="redact__dots" aria-hidden="true"><span class="redact__dot"></span><span class="redact__dot"></span><span class="redact__dot"></span></span>
          <span class="redact__hint" id="redact-hint-1">A tiny bookbinding app. Out in March.</span>
        </span>
      </button>
      and slowly teaching my
      <button class="redact__secret" type="button" aria-describedby="redact-hint-2">
        <span class="redact__glyphs" aria-hidden="true" data-length="7">░▒▓█▒░▓</span>
        <span class="redact__sr">a second secret</span>
        <span class="redact__bubble" role="tooltip">
          <span class="redact__dots" aria-hidden="true"><span class="redact__dot"></span><span class="redact__dot"></span><span class="redact__dot"></span></span>
          <span class="redact__hint" id="redact-hint-2">Old letterpress. It is going badly.</span>
        </span>
      </button>
      to read.
    </p>
    <p class="redact__aside">Hover or tap the blocks. Some things are better said later.</p>
  </div>
</section>

<style>
  .redact {
    padding: var(--section-space) var(--edge);
    overflow-x: clip;
  }
  .redact__inner {
    max-width: var(--measure);
    margin: 0 auto;
    padding-top: var(--space-m);
  }
  .redact__label {
    margin: 0 0 var(--space-xl);
    color: var(--ink);
    font-size: var(--text-m);
    font-weight: 500;
    line-height: var(--leading-label);
  }
  .redact__text {
    margin: 0;
    color: var(--ink-soft);
    font-size: var(--text-m);
    line-height: var(--leading-read);
  }
  .redact__aside {
    margin: var(--space-l) 0 0;
    color: var(--ink-faint);
    font-size: var(--text-s);
    line-height: var(--leading-small);
  }

  .redact__secret {
    position: relative;
    display: inline-block;
    min-height: 44px;
    margin-block: -9px;
    padding: 9px 0;
    border: 0;
    background: none;
    color: var(--ink-soft);
    font: 400 var(--text-m)/var(--leading-read) var(--font-mono);
    vertical-align: baseline;
    cursor: help;
    border-radius: var(--radius-s);
  }
  .redact__secret:focus-visible {
    outline: var(--rule) solid var(--ink);
    outline-offset: 2px;
  }
  .redact__glyphs {
    letter-spacing: -0.08em;
    white-space: pre;
  }
  .redact__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .redact__bubble {
    position: absolute;
    left: 0;
    bottom: calc(100% - 2px);
    z-index: 2;
    display: flex;
    width: max-content;
    max-width: min(320px, calc(100vw - 48px));
    padding: var(--space-xs) 12px;
    background: var(--well);
    border-radius: var(--radius-l);
    color: var(--ink);
    font: 400 var(--text-m)/var(--leading-label) var(--font-body);
    text-align: left;
    white-space: normal;
    translate: var(--redact-shift, 0px) 0;
    transform-origin: 12px 100%;
    visibility: hidden;
    opacity: 0;
    scale: 1.05;
    filter: blur(6px);
    transition-property: opacity, scale, filter, visibility;
    transition-duration: var(--pop);
    transition-timing-function: var(--ease-bounce);
  }
  .redact__secret:hover .redact__bubble,
  .redact__secret:focus-visible .redact__bubble,
  .redact__secret.is-open .redact__bubble {
    visibility: visible;
    opacity: 1;
    scale: 1;
    filter: blur(0);
  }
  .redact__dots {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    height: 26px;
  }
  .redact__dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-pill);
    background: var(--dot);
    animation: redact-pulse var(--pulse) cubic-bezier(0.4, 0, 0.6, 1) infinite;
  }
  .redact__dot:nth-child(2) { animation-delay: 300ms; }
  .redact__dot:nth-child(3) { animation-delay: 600ms; }
  .redact__hint {
    display: none;
  }
  .redact__secret.is-said .redact__dots {
    display: none;
  }
  .redact__secret.is-said .redact__hint {
    display: block;
    animation: redact-reveal var(--reveal) linear both;
  }
  @keyframes redact-pulse {
    50% { opacity: 0.35; }
  }
  @keyframes redact-reveal {
    from { clip-path: inset(0 100% 0 0); opacity: 0.4; }
    to { clip-path: inset(0 0 0 0); opacity: 1; }
  }

  @media (prefers-reduced-motion: reduce) {
    .redact__bubble { transition: none; filter: none; }
    .redact__dot { animation: none; }
    .redact__secret.is-said .redact__hint { animation: none; }
  }
</style>

<script>
(() => {
  const BLOCKS = ['░', '▒', '▓', '█', '░', '▒', ' '];
  const STEP = 90;
  const SAY_AFTER = 1100;
  const still = window.matchMedia('(prefers-reduced-motion: reduce)');

  for (const root of document.querySelectorAll('.redact')) {
    const secrets = [...root.querySelectorAll('.redact__secret')];
    let timer = 0;
    let onScreen = false;

    const shuffle = () => {
      for (const secret of secrets) {
        const glyphs = secret.querySelector('.redact__glyphs');
        const length = Number(glyphs.dataset.length) || glyphs.textContent.length;
        let text = '';
        for (let i = 0; i < length; i += 1) text += BLOCKS[Math.floor(Math.random() * BLOCKS.length)];
        glyphs.textContent = text;
      }
    };
    const run = () => {
      clearInterval(timer);
      timer = 0;
      if (onScreen && !still.matches) timer = setInterval(shuffle, STEP);
    };
    new IntersectionObserver((entries) => {
      onScreen = entries[0].isIntersecting;
      run();
    }).observe(root);
    still.addEventListener('change', run);

    // Keep each bubble inside the section, then let the dots give way to the words.
    const place = (secret) => {
      const bubble = secret.querySelector('.redact__bubble');
      const box = root.getBoundingClientRect();
      const anchor = secret.getBoundingClientRect();
      const over = anchor.left + bubble.offsetWidth - (box.right - 16);
      secret.style.setProperty('--redact-shift', `${over > 0 ? -over : 0}px`);
    };
    const open = (secret) => {
      for (const other of secrets) if (other !== secret) other.classList.remove('is-open', 'is-said');
      secret.classList.add('is-open');
      place(secret);
      clearTimeout(secret.sayTimer);
      secret.sayTimer = setTimeout(() => { secret.classList.add('is-said'); place(secret); }, still.matches ? 0 : SAY_AFTER);
    };
    const close = (secret) => {
      clearTimeout(secret.sayTimer);
      secret.classList.remove('is-open', 'is-said');
    };

    window.addEventListener('resize', () => secrets.filter((s) => s.classList.contains('is-open')).forEach(place));
    for (const secret of secrets) {
      if (secret.classList.contains('is-open')) {
        requestAnimationFrame(() => open(secret));
        if (document.fonts) document.fonts.ready.then(() => place(secret));
      }
      secret.addEventListener('pointerenter', () => open(secret));
      secret.addEventListener('focus', () => open(secret));
      secret.addEventListener('click', () => (secret.classList.contains('is-said') ? close(secret) : open(secret)));
      secret.addEventListener('pointerleave', (event) => { if (event.pointerType === 'mouse') close(secret); });
      secret.addEventListener('blur', () => close(secret));
    }
    shuffle();
    run();
  }
})();
</script>

Similar components

Chapter stepper

Chapter stepper

Extruded word swap

Extruded word swap

Statement with pills

Statement with pills

Letter and footer

Letter and footer

Quote and three rails

Quote and three rails

Studio statement

Studio statement

Black statement

Black statement

Welcome statement

Welcome statement