mirror of
https://github.com/mastra-ai/mastra.git
synced 2026-11-17 08:44:46 +00:00
refactor(playground-ui): move toast layout workaround out of Toaster (#28398)
**─────── TLDR ───────**
> Same toasts as #28357 in about a third fewer lines. `toaster.tsx` only
renders, each Sonner layout fix has a file of its own, and the stories
and tests check what a user sees.
Stacked on #28357 as review cleanup. I checked "same" in a built
Storybook, dark and light: toast colors, shadows, stack heights and
offsets, and the settled check and cross transforms all match #28357's
head. All 23 toast and Notice stories render there, and every play
function passes. Two real bugs turned up on the way.
a promise toast settling into a taller card, in any built bundle
├─ **was** — reveal and detail fade ran for 0.2ms, so the
content popped in
└─ **now** — they run the 200ms of `--duration-normal`
The source says `200ms`, but the minifier writes it as `.2s`, and
`parseFloat` read that as 0.2 milliseconds. #28357 added the only reader
of that value, so nothing released is affected.
any jsdom test that renders `Toaster`
├─ **was** — 40 tests across `add-dataset-item-dialog`,
`save-as-dataset-item-dialog`, `code-editor` and `markdown-table` fail
with `ResizeObserver is not defined`
└─ **now** — `Toaster` skips the layout observers when there
is no ResizeObserver, the way `CollapsibleBox` and `Combobox` already do
#28357's own toast test imports a ResizeObserver stub, which is why it
passed. The stub stays, so that test still runs the observers.
Everywhere else in jsdom they had nothing to measure anyway.
### Shape changed
| | | |
|---|---|---|
| **+** | `observe-toast-layout.ts` | the observers, attached through a
ref callback instead of an effect |
| **+** | `toast-stack-layout.ts` | unscaled heights and settle reveal,
the workaround in one file |
| **+** | `scrollable-toast-content.ts` | long content becomes focusable
and scrolls |
| **~** | `lib/toast.css` → `Toaster/toaster.css` | the component owns
its styles |
| **~** | check and cross geometry → `brand-loader.css` | coordinates
sit beside the SVG they describe |
| **~** | `--toast-morph-ease` and the inline stack curve | one
`--toast-settle-ease` for both |
| **−** | `richColors` and its 12 `--{tone}-{bg,text,border}` vars |
removing them changed no computed color |
| **−** | `aria-label` on the Notice dismiss | `Button` already names
icon buttons from the tooltip |
| **−** | `error-message.ts`, `error-notice.tsx`,
`utils/error-message.ts`, `error-message.stories.tsx` | identical copies
of #27692's files, which that PR ships with their own tests |
| **−** | 8 toast stories, and tests that pinned class names or Sonner's
own option forwarding | what's left covers tones, stacking, promises,
actions and keyboard use |
public surface unchanged
`Toaster` · `toast` · `Notice`
### Decisions
- **`sonner` pinned at 2.0.7 in the pnpm catalog** — `toaster.css`
overrides its private vars, so bumps should be deliberate; one line to
loosen.
- **dark success fill is `--notice-tint: 30%` instead of `#141815`** —
same rgb(20, 24, 21), now follows `--success-subtle`; one line to
revert.
- **light success rim stays a toast-only literal** — a theme token needs
a Foundations entry, and whether Notice should share it is a design
call.
### Watch
- **#27692 merge order** — this PR removes #27692's files from #28357.
If #27692 reaches main and #28357 merges main before this lands, merging
this would delete them from main too. Drop commit `df8ca985a2` in that
case.
### Not verified
- [ ] automated coverage for the stack layout: jsdom has no layout and
play functions don't run in CI, so I compared it by hand in a built
Storybook
- [ ] the scroll path for overflowing toast content has no test or story
check
---
> ██████████████████ **source** `+290 −403` — net −113
> ██████ **stories and tests** `+91 −735` — net −644
> █ **changeset** `+6 −6`
> █ **generated** `+5 −2`
This commit is contained in:
parent
65d05bd74c
commit
f4cbdb4d78
24 changed files with 687 additions and 1441 deletions
7
pnpm-lock.yaml
generated
7
pnpm-lock.yaml
generated
Loading…
Add table
Add a link
Reference in a new issue