kitbash Sign in Connect agent
Components

Sound notice

A small translucent notice card asking to turn on sound, with hairline yes and no buttons, above a round toggle whose four thin bars bounce while sound is on.

Part of the style

Threaded Night Board

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --night: #12100e;
  --night-deep: #979491;
  --panel: #14110f;
  --panel-glass: rgba(13, 11, 9, 0.82);
  --ink: #85b5c3;
  --ink-soft: rgba(140, 188, 202, 0.5);
  --ink-mute: #64838c;
  --ink-faint: #473b30;
  --thread: rgba(140, 188, 202, 0.09);
  --line: rgba(140, 188, 202, 0.1);
  --line-strong: rgba(140, 188, 202, 0.28);
  --wash: rgba(140, 188, 202, 0.02);
  --button: #85b5c3;
  --button-ink: #0d0b0a;
}
</style>

<section class="notice" aria-label="Sound">
  <div class="notice__card" role="dialog" aria-labelledby="notice-ask">
    <button class="notice__dismiss" type="button" aria-label="Dismiss">
      <svg viewBox="0 0 12 12" width="10" height="10" aria-hidden="true"><path d="M2 2l8 8M10 2l-8 8"/></svg>
    </button>
    <p class="notice__line">The reading room hums with a quiet tide.</p>
    <p class="notice__ask" id="notice-ask">Turn on room sound?</p>
    <div class="notice__choices">
      <button class="notice__choice is-primary" type="button" data-sound="on">
        <svg viewBox="0 0 16 16" width="12" height="12" aria-hidden="true"><path d="M2 6h3l4-3v10l-4-3H2zM11.5 5.5a3.5 3.5 0 0 1 0 5M13 3.5a6 6 0 0 1 0 9"/></svg>
        Yes
      </button>
      <button class="notice__choice" type="button" data-sound="off">
        <svg viewBox="0 0 16 16" width="12" height="12" aria-hidden="true"><path d="M2 6h3l4-3v10l-4-3H2zM11 6l4 4M15 6l-4 4"/></svg>
        No
      </button>
    </div>
  </div>
  <p class="notice__state" aria-live="polite">Room sound <span class="notice__value">Off</span></p>
  <button class="notice__toggle" type="button" aria-pressed="false" aria-label="Room sound">
    <span class="notice__bar"></span><span class="notice__bar"></span><span class="notice__bar"></span><span class="notice__bar"></span>
  </button>
</section>

<style>
  .notice {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-m);
    padding: var(--space-xl) var(--edge);
    min-height: 320px;
    justify-content: flex-end;
    background: radial-gradient(80% 120% at 100% 100%, #15161a, var(--night) 70%);
    color: var(--ink);
  }

  .notice__card {
    position: relative;
    width: min(100%, 250px);
    padding: var(--space-m) var(--space-m) var(--space-m);
    border: var(--rule) solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-glass);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-card);
    transform-origin: 85% 100%;
    transition: opacity var(--time) var(--ease), transform var(--time) var(--ease);
  }
  /* The little tail pointing down at the toggle. */
  .notice__card::after {
    content: "";
    position: absolute;
    right: 34px;
    bottom: -6px;
    width: 10px;
    height: 10px;
    border-right: var(--rule) solid var(--line);
    border-bottom: var(--rule) solid var(--line);
    background: var(--panel);
    transform: rotate(45deg);
  }
  .notice.is-closed .notice__card {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
    pointer-events: none;
  }

  .notice__dismiss {
    position: absolute;
    top: 0;
    right: 0;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 0;
    background: none;
    color: var(--ink-faint);
    cursor: pointer;
    transition: color var(--quick) var(--ease);
  }
  .notice__dismiss:hover,
  .notice__dismiss:focus-visible {
    color: var(--ink);
    outline: none;
  }
  .notice__dismiss path,
  .notice__choice path {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.2;
  }

  .notice__line {
    margin: 0 28px var(--space-xs) 0;
    color: var(--ink-mute);
    font-size: 11.5px;
    line-height: 1.55;
  }
  .notice__ask {
    margin: 0 0 var(--space-m);
    font-size: var(--text-m);
    font-weight: 500;
  }
  .notice__choices {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-xs);
  }
  .notice__choice {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    min-height: 44px;
    padding: 0 14px;
    border: var(--rule) solid transparent;
    border-radius: var(--radius-s);
    background: none;
    color: var(--ink-faint);
    font: inherit;
    font-size: 10.5px;
    letter-spacing: var(--track-caps);
    text-transform: uppercase;
    cursor: pointer;
    transition: color var(--quick) var(--ease), border-color var(--quick) var(--ease);
  }
  .notice__choice.is-primary {
    border-color: var(--line);
    color: var(--ink-soft);
  }
  .notice__choice:hover,
  .notice__choice:focus-visible {
    border-color: var(--line-strong);
    color: var(--ink);
    outline: none;
  }

  .notice__state {
    position: absolute;
    left: var(--edge);
    bottom: calc(var(--space-xl) + 14px);
    margin: 0;
    color: var(--ink-faint);
    font-size: 9.5px;
    letter-spacing: var(--track-caps);
    text-transform: uppercase;
  }
  .notice__value {
    margin-left: var(--space-xs);
    color: var(--ink-soft);
  }
  .notice__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 46px;
    height: 46px;
    margin-right: 22px;
    border: var(--rule) solid var(--line);
    border-radius: var(--pill);
    background: var(--panel-glass);
    cursor: pointer;
    transition: border-color var(--quick) var(--ease);
  }
  .notice__toggle:hover,
  .notice__toggle:focus-visible {
    border-color: var(--line-strong);
    outline: none;
  }
  .notice__bar {
    width: 1px;
    height: 3px;
    background: var(--ink-soft);
    transform-origin: 50% 50%;
  }
  .notice.is-on .notice__bar {
    height: 12px;
    background: var(--ink);
    animation: notice-bar 0.9s var(--ease) infinite alternate;
  }
  .notice.is-on .notice__bar:nth-child(2) { animation-delay: -0.3s; }
  .notice.is-on .notice__bar:nth-child(3) { animation-delay: -0.6s; }
  .notice.is-on .notice__bar:nth-child(4) { animation-delay: -0.15s; }
  .notice.is-paused .notice__bar {
    animation-play-state: paused;
  }
  @keyframes notice-bar {
    from { transform: scaleY(0.25); }
    to { transform: scaleY(1); }
  }

  @media (prefers-reduced-motion: reduce) {
    .notice.is-on .notice__bar {
      animation: none;
      transform: scaleY(0.7);
    }
  }
</style>

<script>
(() => {
  for (const root of document.querySelectorAll('.notice')) {
    const toggle = root.querySelector('.notice__toggle');
    const value = root.querySelector('.notice__value');
    const setSound = (on) => {
      value.textContent = on ? 'On' : 'Off';
      root.classList.toggle('is-on', on);
      toggle.setAttribute('aria-pressed', String(on));
    };
    for (const choice of root.querySelectorAll('.notice__choice')) {
      choice.addEventListener('click', () => {
        setSound(choice.dataset.sound === 'on');
        root.classList.add('is-closed');
        toggle.focus();
      });
    }
    root.querySelector('.notice__dismiss').addEventListener('click', () => {
      root.classList.add('is-closed');
      toggle.focus();
    });
    toggle.addEventListener('click', () => setSound(!root.classList.contains('is-on')));
    // The bars rest while the notice is off screen.
    new IntersectionObserver((entries) => {
      for (const entry of entries) root.classList.toggle('is-paused', !entry.isIntersecting);
    }).observe(root);
  }
})();
</script>

Similar components

Collections

Collections

Daylight readout

Daylight readout

Type tester

Type tester

Lift Panel Floors

Lift Panel Floors

Folding spines

Folding spines

Theme flood

Theme flood

Service cells

Service cells

Instrument panel

Instrument panel