Sonner: replace the JS runtime with a pure Rust/Leptos toast system#33
Sonner: replace the JS runtime with a pure Rust/Leptos toast system#33krishpranav wants to merge 4 commits intorust-ui:mainfrom
Conversation
…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
a27dbde to
d35d843
Compare
There was a problem hiding this comment.
@krishpranav Thanks for the effort here — removing the JS files and lazy loader is exactly the right direction. That said, there are several issues that need to be fixed before this can be merged.
|
|
||
| provide_toaster(); | ||
| provide_sonner(); | ||
|
|
There was a problem hiding this comment.
Two separate toast systems now coexist. The issue explicitly asked to use toast_custom as the foundation rather than starting from scratch. Instead, this PR adds a brand-new SonnerContext / provide_sonner() running in parallel with the existing provide_toaster(). The goal was to consolidate — not duplicate. Please audit app_crates/registry/src/ui/toast_custom/ and build on top of it rather than introducing a second context.
| @@ -1,19 +1,415 @@ | |||
| use icons::{FileText, Lock, TriangleAlert, X}; | |||
| use leptos::prelude::*; | |||
There was a problem hiding this comment.
Wrong PR, but the work itself is welcome. This Dialog/Drawer content for page_to_fix was requested separately — please extract it into its own dedicated PR so it can be reviewed and merged independently from the Sonner changes.
| @@ -1,2 +1,3 @@ | |||
| pub mod drawer_tofix; | |||
| pub mod page_test; | |||
There was a problem hiding this comment.
Wrong PR. drawer_tofix belongs in the same dedicated PR as the page_to_fix Dialog/Drawer work — not here.
|
|
||
| /** The demo preview container - all component tests should scope within this */ | ||
| readonly preview: Locator; | ||
|
|
There was a problem hiding this comment.
Breaking change to shared test infrastructure. Removing the preview field from BasePage and converting it to a computed getter changes behavior for every test that inherits from BasePage. This is a non-trivial refactor that should be validated across all component tests — not bundled silently into a Sonner PR. If this change is needed for the Sonner tests, please scope it to a separate PR with a proper audit of the impact on other test files.
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:
app_crates/registry/src/ui/sonner.rsapp/src/shell.rspublic/components/sonner.js,sonner.min.js,sonner.css, andlazy_load_sonner.jsValidation:
The long full-file Playwright run against
tests/components/sonner.spec.tsis 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