Drawer rust port and demo fixes#31
Conversation
4c7236a to
28bdeb7
Compare
Drop vaul JS/CSS assets and move drawer behavior into Rust context and event handling. Also fix family demo text contrast and sync registry snapshots.
28bdeb7 to
6310eae
Compare
max-wells
left a comment
There was a problem hiding this comment.
Hey @krishpranav — really solid PR overall! Removing the JS/CSS runtime and moving everything into Rust is exactly the right direction for this project. The checklist in the description made review much easier too, thanks for that.
Three things to address before merge:
1. CSS — keep it as a standalone file
Rather than embedding the styles as a DRAWER_STYLE const in the .rs file, let's keep it as a standalone CSS file — easier to edit without a recompile and consistent with how we handle sonner.css.
Please:
- Restore
public/components/vaul_drawer.csswith the CSS content - Remove the
DRAWER_STYLEconst fromdrawer.rs - Add these two lines to
app/src/shell.rs(right after thesonner.cssblock):
<link rel="preload" href="/components/vaul_drawer.css" r#as="style" />
<link rel="stylesheet" href="/components/vaul_drawer.css" media="print" onload="this.media='all'" />2. Event listener cleanup — raw Closure lifetime
Raw wasm_bindgen::Closure values must be explicitly kept alive — if they're dropped early, the event listener silently becomes a no-op. Without proper cleanup you'll also get stale listeners accumulating if the drawer unmounts and remounts.
For any window.add_event_listener_with_callback calls using a manual Closure, either:
- Switch to
window_event_listener(ev::keydown, ...)which you're already using elsewhere in this file (Leptos handles cleanup automatically), or - Store the
Closureand registeron_cleanup(move || { ... remove_event_listener ... })to drop it properly
3. Minor — SCROLL_LOCK_TIMEOUT_MS type
This is typed as f64 but used as a duration. Should be u32, or just use Duration::from_millis(500) directly at the call site.
Once those are addressed this is good to merge!
|
@krishpranav — did a deeper pass comparing the Rust port line-by-line against the original 1.
|
|
@krishpranav — one more pass, 6 additional items not covered in the previous comment: 9.
|
Move drawer styles back to public/components/vaul_drawer.css and load it from shell. Remove inline style constant, keep animate/drag behavior aligned with the original vaul runtime, and fix timeout typing cleanup.
|
Great work @krishpranav — all 14 items are implemented and the port looks solid. Merging now, thanks! |
Description:
This branch ports the drawer runtime from JS to Rust/Leptos and keeps the docs page runnable at http://127.0.0.1:3000/docs/components/drawer. The main behavior now lives in app_crates/registry/src/ui/drawer.rs via DrawerContext + signals, not through injected
<script>/<link>assets.DrawerTriggerandDrawerClosecall context methods directly, and pointer drag, open/close sequencing, focus handling, keyboard handling, overlay/body-scroll behavior, and position/variant logic are handled in Rust.Demo + Visual Fixes:
http://127.0.0.1:3000/docs/components/drawerapp_crates/registry/src/demos/demo_drawer_family.rspublic/registry/styles/default/demo_drawer_family.mdtext-neutral-900) and close icon contrast was increased (text-neutral-700)Check list:
DrawerContext+ Rust open/close state: implementedDrawerTrigger/DrawerClosewired to context: implementedrequest_animation_frame+set_timeout): implementedposition,variant,dismissible,lock_body_scroll,show_overlay): present indrawer.rspublic/app/vaul_drawer.js,public/app/vaul_drawer.css)Validation Done in This Pass:
cargo build: passcargo clippy -- -D warnings: passcloses #30