Toast.svelte 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <!--
  2. The bottom-centre note. Ink fill, paper text, 2.6 s (design spec §appendix).
  3. `aria-live="polite"` rather than `alert`: the screen has already refreshed by
  4. the time this appears, so it is a confirmation, not something to interrupt for.
  5. -->
  6. <script lang="ts">
  7. import { toast } from '../lib/toast.svelte';
  8. </script>
  9. <div class="live-region" aria-live="polite">
  10. {#if toast.message}
  11. <div class="toast">{toast.message}</div>
  12. {/if}
  13. </div>
  14. <style>
  15. .toast {
  16. position: fixed;
  17. left: 50%;
  18. bottom: 22px;
  19. transform: translateX(-50%);
  20. background: var(--ink);
  21. color: var(--paper);
  22. padding: 8px 14px;
  23. font-size: 12.5px;
  24. line-height: 1.4;
  25. max-width: 70ch;
  26. z-index: 50;
  27. animation: rise 140ms ease-out;
  28. }
  29. @keyframes rise {
  30. from {
  31. opacity: 0;
  32. transform: translate(-50%, 6px);
  33. }
  34. to {
  35. opacity: 1;
  36. transform: translate(-50%, 0);
  37. }
  38. }
  39. @media (prefers-reduced-motion: reduce) {
  40. .toast {
  41. animation: none;
  42. }
  43. }
  44. </style>