feat: add the Toast primitive#14
Open
ivanbanov wants to merge 2 commits into
Open
Conversation
Anatomy: Toast.Provider / Toast.Viewport / Toast (Root, Title, Description, Action, Close). A status live-region toast that auto-dismisses after its duration and pauses timers while the viewport is hovered or focused. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the Toast primitive as two packages:
@dunky.dev/toast— the framework-free core: state machine, connect, and the behavior contract.@dunky.dev/react-toast— the thin React binding (compound components over the core machine).A declarative, Radix-style toast — one component per toast, not an imperative toaster store. Each toast owns its open/close state (controlled and uncontrolled), announces as a status live region, auto-dismisses after its duration (
Infinity= persistent), and pauses every timer while the viewport is hovered or focused. Resuming restarts the full duration — a documented deviation from Radix that keeps the timer contract inside the state machine.Anatomy
Behavior
role="status"with politeness driven by the toast type:foreground->aria-live="assertive",background->aria-live="polite";aria-atomicannounces the whole toast on update.role="region"landmark labelled by the provider'slabel, toasts as a list inside it).tabindex="-1"), so the user keeps their place and the focus-derived pause stays truthful.onOpenChange.Test plan
pnpm test:ci— 119 tests, 9 files, all passingpnpm typecheckpnpm lintpnpm format:checkpnpm build🤖 Generated with Claude Code