Skip to content

Sonner: replace the JS runtime with a pure Rust/Leptos toast system#33

Open
krishpranav wants to merge 4 commits intorust-ui:mainfrom
krishpranav:feat/issue-29-sonner-rust-port
Open

Sonner: replace the JS runtime with a pure Rust/Leptos toast system#33
krishpranav wants to merge 4 commits intorust-ui:mainfrom
krishpranav:feat/issue-29-sonner-rust-port

Conversation

@krishpranav
Copy link
Copy Markdown
Contributor

Description:

The Sonner docs were still hanging off a bundled JS runtime and lazy loader.
This patch moves the toast state machine, rendering, timers, stacking, and interaction flow into Rust/Leptos and cleans up the demo wiring around it.

What changed:

  • Replaced the Sonner JS runtime with a Rust/Leptos implementation in app_crates/registry/src/ui/sonner.rs
  • Removed Sonner asset loading from app/src/shell.rs
  • Deleted public/components/sonner.js, sonner.min.js, sonner.css, and lazy_load_sonner.js
  • Added reactive toast context, Rust click handlers, auto-dismiss timers, swipe dismissal, stacking, and variant handling
  • Updated the Sonner demos so the default, positions, and variants previews render against the Rust implementation directly
  • Added stable demo preview selectors and tightened the Sonner Playwright page objects around those demos
  • Refreshed the Sonner registry markdown snapshots

Validation:

cargo build
cargo clippy -- -D warnings
cd e2e && PORT=3000 npx playwright test tests/components/sonner.spec.ts --workers=1 --grep "Loading variant should NOT have duration track"
cd e2e && PORT=3000 npx playwright test tests/components/sonner.spec.ts --workers=1 --grep "BOTTOM position: stacked toasts should expand UPWARD on hover|all toasts should have scale\\(1\\) when expanded|progress bar should resume after mouse leave"
cd e2e && PORT=3000 npx playwright test tests/components/sonner.spec.ts --workers=1 --grep "Sonner Positions Page"

The long full-file Playwright run against tests/components/sonner.spec.ts is still unstable in this local runner after extended sequential execution, but the Rust implementation, demo wiring, and the targeted Sonner slices above pass cleanly.

Fixes #29

max-wells and others added 4 commits April 22, 2026 19:02
…ions to bust poisoned cache

add_cache_headers was applying long cache headers to SSR HTML fallback responses
when static files were temporarily missing during rebuild, causing browsers to cache
HTML as JS for up to 7 days. Guard added to skip caching on text/html responses.
Remove sonner.js, sonner.min.js, sonner.css, and lazy_load_sonner.js
entirely. Toast state, auto-dismiss timers, stacking, and position
logic now live in a RwSignal<Vec<ToastData>> provided via Leptos
context.

SonnerTrigger no longer reads data-* attributes on click — it calls
show_toast() directly. SonnerToaster renders toasts as Leptos
components with CSS-only enter/exit animations. No JS runtime
dependency remains in this component.

Fixes rust-ui#29
@krishpranav krishpranav force-pushed the feat/issue-29-sonner-rust-port branch from a27dbde to d35d843 Compare April 22, 2026 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace sonner.js + lazy loader with a pure Rust toast system

2 participants