kitbash Sign in Connect agent
Components

Erasure workbench

The signature tool: a three-step rail beside a framed story window; pick words, black out the rest, keep the poem. On phones the rail folds into a Step n / 3 bar.

Part of the style

Pixel Caps Manuscript

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --paper: #241f23;
  --ink: #c6b4be;
  --ink-mute: #8d838b;
  --rule-mute: #4e464c;
  --paper-wash: #292428;
}
</style>

<section class="workbench" data-stage="1" aria-label="Erasure workbench">
  <div class="workbench__side">
    <ol class="workbench__rail">
      <li class="workbench__step is-current">
        <span class="workbench__dot" aria-hidden="true"></span>
        <h3 class="workbench__label">Step 1</h3>
        <p class="workbench__hint">Read the page and find the story inside it.</p>
        <button class="workbench__action" type="button" data-step="1">Find your words</button>
      </li>
      <li class="workbench__step">
        <span class="workbench__dot" aria-hidden="true"></span>
        <h3 class="workbench__label">Step 2</h3>
        <p class="workbench__hint">Tap the words to keep, then black out the rest.</p>
        <button class="workbench__action" type="button" data-step="2" disabled>Black out the rest</button>
      </li>
      <li class="workbench__step">
        <span class="workbench__dot" aria-hidden="true"></span>
        <h3 class="workbench__label">Step 3</h3>
        <p class="workbench__hint">Keep your poem and leave the page for the next reader.</p>
        <button class="workbench__action" type="button" data-step="3" disabled>Keep your poem</button>
      </li>
    </ol>
    <button class="workbench__again" type="button">
      <svg class="workbench__spin" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M13 6.5A5.2 5.2 0 0 0 3.6 4.4M3 9.5a5.2 5.2 0 0 0 9.4 2.1" fill="none" stroke="currentColor" stroke-width="1.6" /><path d="M3 1.8v3.4h3.4M13 14.2v-3.4H9.6" fill="none" stroke="currentColor" stroke-width="1.6" /></svg>
      <span>Start over</span>
    </button>
  </div>

  <article class="workbench__window is-loading">
    <header class="workbench__bar">
      <h2 class="workbench__title is-shown" data-page="0">Comet Over the Market</h2>
      <h2 class="workbench__title" data-page="1">The Almanac for May</h2>
      <h2 class="workbench__title" data-page="2">Notice to the Ferry Town</h2>
      <div class="workbench__dots" role="group" aria-label="Pages">
        <button class="workbench__pager is-current" type="button" data-page="0" aria-label="Page 1" aria-pressed="true"></button>
        <button class="workbench__pager" type="button" data-page="1" aria-label="Page 2" aria-pressed="false"></button>
        <button class="workbench__pager" type="button" data-page="2" aria-label="Page 3" aria-pressed="false"></button>
      </div>
    </header>
    <div class="workbench__body">
      <div class="workbench__loader" aria-hidden="true"><span></span><span></span><span></span></div>
      <div class="workbench__page is-shown" data-page="0">
        <p>The night the comet came, the whole market stayed open past the lamps. Fishmongers left their ice to melt, the bread woman climbed onto her own cart, and the clockmaker stopped every clock in his window so that nobody could say how late it was.</p>
        <p>We had been told it would burn the sky, or poison the wells, or bring back everyone we had lost. It did none of those things. It hung there over the church roof like a pale thread pulled loose from a coat, and the children tried to reach it with brooms.</p>
        <p>My grandmother sold more candles that night than in the whole of winter. She said a light in the hand is worth a light in the sky, and she would not look up, not once, until the square was empty and the last candle gone.</p>
        <p>In the morning the paper called it a great wonder and a terrible warning on the same page. I cut out both halves and kept them in the tin with the buttons, and some years later I could not remember which one I had believed.</p>
      </div>
      <div class="workbench__page" data-page="1">
        <p>Sow beans when the elm leaf is the size of a mouse's ear. Mend the fence before the moon is full, for a full moon makes the cattle bold and the neighbours generous with advice.</p>
        <p>Expect rain on the third, a fair wind on the ninth and a quarrel near the end of the month that will turn out to be about nothing at all. Keep the cellar door shut and the letters answered.</p>
        <p>The swallows return. The bees swarm. Somebody in the house will learn to whistle and will not stop until June.</p>
      </div>
      <div class="workbench__page" data-page="2">
        <p>Notice is given that the ferry will cross twice daily, weather allowing, and once on Sundays for the pleasure of the river. Passengers are asked to keep their hats on and their opinions low.</p>
        <p>Goods left on the landing for more than three tides become the property of the gulls. Lost children are kept at the toll house and returned with a biscuit. The ferryman does not sing on request, but he does sing.</p>
      </div>
    </div>
  </article>

  <div class="workbench__phonebar">
    <p class="workbench__count">Step <span class="workbench__now">1</span> / 3</p>
    <button class="workbench__next" type="button">Find your words</button>
    <button class="workbench__reset" type="button" aria-label="Start over">
      <svg class="workbench__spin" viewBox="0 0 16 16" width="18" height="18" aria-hidden="true"><path d="M13 6.5A5.2 5.2 0 0 0 3.6 4.4M3 9.5a5.2 5.2 0 0 0 9.4 2.1" fill="none" stroke="currentColor" stroke-width="1.6" /><path d="M3 1.8v3.4h3.4M13 14.2v-3.4H9.6" fill="none" stroke="currentColor" stroke-width="1.6" /></svg>
    </button>
  </div>
</section>

<style>
  .workbench {
    display: grid;
    grid-template-columns: minmax(15rem, 28rem) minmax(0, 1fr);
    align-items: start;
    gap: var(--gap);
    padding: var(--space-l) var(--edge) var(--section-space);
  }

  /* Rail */
  .workbench__rail {
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .workbench__step {
    position: relative;
    padding: 0 0 var(--space-xl) calc(var(--dot) + var(--space-l));
    color: var(--ink-mute);
    transition: color var(--step) var(--ease);
  }
  .workbench__step:not(:last-child)::before {
    content: "";
    position: absolute;
    top: calc(var(--dot) / 2 + 6px);
    bottom: -6px;
    left: calc(var(--dot) / 2 - var(--rule) / 2);
    width: var(--rule);
    background: var(--ink);
  }
  .workbench__dot {
    position: absolute;
    top: 6px;
    left: 0;
    width: var(--dot);
    height: var(--dot);
    border: var(--rule) solid var(--ink);
    border-radius: var(--radius-dot);
    background: var(--paper);
    transition: background-color var(--step) var(--ease);
  }
  .workbench__step.is-current,
  .workbench__step.is-done {
    color: var(--ink);
  }
  .workbench__step.is-current .workbench__dot,
  .workbench__step.is-done .workbench__dot {
    background: var(--ink);
  }
  .workbench__label {
    margin: 0 0 var(--space-xs);
    font-family: var(--font-display);
    font-size: var(--display-m);
    font-weight: 400;
    line-height: 1.2;
  }
  .workbench__hint {
    margin: 0 0 var(--space-m);
  }
  .workbench__action,
  .workbench__next {
    width: 100%;
    min-height: var(--tap);
    padding: var(--space-s) var(--space-m);
    border: var(--rule) solid var(--ink);
    border-radius: var(--radius-none);
    background: transparent;
    color: var(--ink);
    font: 500 var(--text-m)/1.2 var(--font-body);
    cursor: pointer;
    transition: background-color var(--quick) var(--ease), color var(--quick) var(--ease), border-color var(--quick) var(--ease);
  }
  .workbench__action:hover:not(:disabled),
  .workbench__next:hover:not(:disabled),
  .workbench__action:focus-visible,
  .workbench__next:focus-visible {
    background: var(--paper-wash);
    outline: none;
  }
  .workbench__action:active:not(:disabled),
  .workbench__next:active:not(:disabled) {
    background: var(--ink);
    color: var(--paper);
  }
  .workbench__action:disabled,
  .workbench__next:disabled {
    border-color: var(--rule-mute);
    color: var(--ink-mute);
    cursor: default;
  }
  .workbench__again {
    display: flex;
    align-items: center;
    gap: var(--space-s);
    min-height: var(--tap);
    margin-left: calc(var(--dot) + var(--space-l));
    width: calc(100% - var(--dot) - var(--space-l));
    padding: var(--space-s) 0 0;
    border: 0;
    border-top: var(--rule-thin) solid var(--ink);
    background: none;
    color: var(--ink);
    font: 400 var(--text-s)/1 var(--font-body);
    cursor: pointer;
  }
  .workbench__again:hover span,
  .workbench__again:focus-visible span {
    text-decoration: underline;
    text-underline-offset: 3px;
  }
  .workbench.is-spinning .workbench__spin {
    animation: workbench-spin var(--spin) var(--ease) 1;
  }
  @keyframes workbench-spin {
    to { transform: rotate(-360deg); }
  }

  /* Window */
  .workbench__window {
    border: var(--rule) solid var(--ink);
    background: var(--paper);
  }
  .workbench__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-m);
    padding: 0 var(--space-s) 0 var(--space-l);
    border-bottom: var(--rule) solid var(--ink);
  }
  .workbench__title {
    display: none;
    margin: 0;
    padding: var(--space-s) 0;
    font-family: var(--font-display);
    font-size: var(--display-m);
    font-weight: 400;
    line-height: 1.2;
  }
  .workbench__title.is-shown {
    display: block;
  }
  .workbench__dots {
    display: flex;
    flex: none;
  }
  .workbench__pager {
    display: grid;
    place-items: center;
    width: var(--tap);
    height: var(--tap);
    margin-inline: calc((var(--tap) - var(--dot) - 12px) / -2);
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
  }
  .workbench__pager::before {
    content: "";
    width: var(--dot);
    height: var(--dot);
    border: var(--rule) solid var(--ink);
    border-radius: var(--radius-dot);
    transition: background-color var(--quick) var(--ease);
  }
  .workbench__pager.is-current::before,
  .workbench__pager:hover::before {
    background: var(--ink);
  }
  .workbench__pager:disabled {
    cursor: default;
  }
  .workbench__pager:disabled:not(.is-current)::before {
    background: none;
  }
  .workbench__body {
    position: relative;
    padding: var(--space-l);
  }
  .workbench__page {
    display: none;
  }
  .workbench__page.is-shown {
    display: block;
    animation: workbench-in var(--step) var(--ease);
  }
  .workbench__page p {
    max-width: 68ch;
    margin: 0 0 var(--space-m);
  }
  .workbench__page p:last-child {
    margin-bottom: 0;
  }
  @keyframes workbench-in {
    from { opacity: 0; }
  }
  .workbench__loader {
    display: none;
  }
  .workbench__window.is-loading .workbench__page {
    visibility: hidden;
  }
  .workbench__window.is-loading .workbench__loader {
    position: absolute;
    inset: var(--space-l);
    display: grid;
    align-content: start;
    gap: var(--space-m);
  }
  .workbench__loader span {
    height: var(--space-m);
    background: var(--paper-wash);
    animation: workbench-pulse var(--pulse) ease-in-out infinite;
  }
  .workbench__loader span:nth-child(2) { width: 86%; animation-delay: 160ms; }
  .workbench__loader span:nth-child(3) { width: 62%; animation-delay: 320ms; }
  @keyframes workbench-pulse {
    50% { opacity: 0.35; }
  }

  /* Words */
  .workbench__word {
    display: inline;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: inherit;
    transition: background-color var(--step) var(--ease), color var(--step) var(--ease), box-shadow var(--step) var(--ease);
    transition-delay: calc(var(--order, 0) * 4ms);
  }
  .workbench[data-stage="2"] .workbench__word {
    cursor: pointer;
  }
  .workbench[data-stage="2"] .workbench__word:hover {
    box-shadow: inset 0 -2px 0 var(--ink);
  }
  .workbench__word:focus-visible {
    outline: var(--rule) solid var(--ink);
    outline-offset: 1px;
  }
  .workbench__word.is-kept {
    background: var(--ink);
    color: var(--paper);
    box-shadow: 0.15em 0 0 var(--ink), -0.15em 0 0 var(--ink);
  }
  .workbench[data-stage="3"] .workbench__word,
  .workbench[data-stage="4"] .workbench__word {
    background: var(--ink);
    color: transparent;
    box-shadow: 0.3em 0 0 var(--ink);
  }
  .workbench[data-stage="3"] .workbench__word.is-kept,
  .workbench[data-stage="4"] .workbench__word.is-kept {
    background: var(--paper);
    color: var(--ink);
    box-shadow: 0.15em 0 0 var(--paper), -0.15em 0 0 var(--paper);
    font-weight: 500;
  }

  /* Phone bar */
  .workbench__phonebar {
    display: none;
  }

  @media (max-width: 48rem) {
    .workbench {
      grid-template-columns: minmax(0, 1fr);
      gap: 0;
      padding-bottom: 0;
    }
    .workbench__side {
      display: none;
    }
    .workbench__phonebar {
      position: sticky;
      bottom: 0;
      display: grid;
      grid-template-columns: auto minmax(0, 1fr) var(--tap);
      align-items: center;
      gap: var(--space-m);
      margin: var(--space-l) calc(var(--edge) * -1) 0;
      padding: var(--space-s) var(--edge);
      border-top: var(--rule) solid var(--ink);
      background: var(--paper);
    }
    .workbench__count {
      margin: 0;
      font-family: var(--font-display);
      font-size: var(--display-l);
      line-height: 1;
      white-space: nowrap;
    }
    .workbench__next {
      font-size: var(--text-s);
    }
    .workbench__reset {
      display: grid;
      place-items: center;
      width: var(--tap);
      height: var(--tap);
      padding: 0;
      border: 0;
      background: none;
      color: var(--ink);
      cursor: pointer;
    }
    .workbench__bar {
      padding-left: var(--space-m);
    }
    .workbench__title {
      font-size: var(--text-l);
    }
    .workbench__body {
      max-height: clamp(20rem, 100vw, 30rem);
      overflow-y: auto;
      padding: var(--space-m) var(--space-l) var(--space-l);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .workbench__loader span,
    .workbench__page.is-shown,
    .workbench.is-spinning .workbench__spin {
      animation: none;
    }
    .workbench__word {
      transition: none;
    }
  }
</style>

<script>
(() => {
  for (const root of document.querySelectorAll('.workbench')) {
    const steps = [...root.querySelectorAll('.workbench__step')];
    const actions = [...root.querySelectorAll('.workbench__action')];
    const pagers = [...root.querySelectorAll('.workbench__pager')];
    const titles = [...root.querySelectorAll('.workbench__title')];
    const pages = [...root.querySelectorAll('.workbench__page')];
    const windowBox = root.querySelector('.workbench__window');
    const now = root.querySelector('.workbench__now');
    const next = root.querySelector('.workbench__next');
    const nextLabels = actions.map((button) => button.textContent);
    let page = 0;

    const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
    setTimeout(() => windowBox.classList.remove('is-loading'), reduce ? 0 : 700);

    const kept = () => pages[page].querySelectorAll('.workbench__word.is-kept').length;

    const wrapWords = (container) => {
      if (container.dataset.wrapped) return;
      container.dataset.wrapped = 'yes';
      let order = 0;
      for (const paragraph of container.querySelectorAll('p')) {
        const words = paragraph.textContent.split(/(\s+)/);
        paragraph.textContent = '';
        for (const part of words) {
          if (!part) continue;
          if (/^\s+$/.test(part)) { paragraph.append(part); continue; }
          const word = document.createElement('button');
          word.type = 'button';
          word.className = 'workbench__word';
          word.setAttribute('aria-pressed', 'false');
          word.style.setProperty('--order', Math.min(order++, 120));
          word.textContent = part;
          paragraph.append(word);
        }
      }
    };

    const setStage = (stage) => {
      root.dataset.stage = String(stage);
      steps.forEach((step, index) => {
        step.classList.toggle('is-done', index + 1 < stage);
        step.classList.toggle('is-current', index + 1 === stage);
      });
      actions[0].disabled = stage !== 1;
      actions[1].disabled = stage !== 2 || kept() === 0;
      actions[2].disabled = stage !== 3;
      actions[2].textContent = stage === 4 ? 'Poem kept' : nextLabels[2];
      pagers.forEach((pager) => { pager.disabled = stage !== 1; });
      now.textContent = String(Math.min(stage, 3));
      next.textContent = stage === 4 ? 'Poem kept' : nextLabels[stage - 1];
      next.disabled = stage === 4 || (stage === 2 && kept() === 0);
      for (const word of pages[page].querySelectorAll('.workbench__word')) word.disabled = stage !== 2;
    };

    const advance = () => {
      const stage = Number(root.dataset.stage);
      if (stage === 1) wrapWords(pages[page]);
      if (stage < 4) setStage(stage + 1);
    };

    const showPage = (index) => {
      page = index;
      pagers.forEach((pager, i) => {
        pager.classList.toggle('is-current', i === index);
        pager.setAttribute('aria-pressed', String(i === index));
      });
      titles.forEach((title, i) => title.classList.toggle('is-shown', i === index));
      pages.forEach((item, i) => item.classList.toggle('is-shown', i === index));
    };

    const reset = () => {
      for (const word of root.querySelectorAll('.workbench__word.is-kept')) {
        word.classList.remove('is-kept');
        word.setAttribute('aria-pressed', 'false');
      }
      setStage(1);
      root.classList.remove('is-spinning');
      void root.offsetWidth;
      root.classList.add('is-spinning');
    };

    root.addEventListener('animationend', (event) => {
      if (event.animationName === 'workbench-spin') root.classList.remove('is-spinning');
    });
    actions.forEach((button) => button.addEventListener('click', advance));
    next.addEventListener('click', advance);
    root.querySelector('.workbench__again').addEventListener('click', reset);
    root.querySelector('.workbench__reset').addEventListener('click', reset);
    pagers.forEach((pager, index) => pager.addEventListener('click', () => showPage(index)));
    root.querySelector('.workbench__body').addEventListener('click', (event) => {
      const word = event.target.closest('.workbench__word');
      if (!word || root.dataset.stage !== '2') return;
      const on = word.classList.toggle('is-kept');
      word.setAttribute('aria-pressed', String(on));
      setStage(2);
    });
  }
})();
</script>

Similar components

Mono chat slab

Mono chat slab

Sky panel with tabs

Sky panel with tabs

Usage calculator

Usage calculator

App screen showcase

App screen showcase

Segmented showcase

Segmented showcase

Showcase with progress tabs

Showcase with progress tabs

Instrument panel

Instrument panel

Ink switcher

Ink switcher