app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

commit 3d49c420f8047b9ebb700afd01ea2a32e36b9865
parent 0fd5440ae09738080c9b4851a7a1946dcc71e83a
Author: triesap <triesap@radroots.dev>
Date:   Wed, 21 Jan 2026 20:00:41 +0000

ui: add portal primitive

- add portal component with wasm mount support

- add mount alias for wasm and native targets

- add unit test for target availability

- add leptos and web-sys deps for portal

Diffstat:
Mcrates/ui-primitives/Cargo.toml | 4++++
Mcrates/ui-primitives/src/lib.rs | 4++++
Acrates/ui-primitives/src/portal.rs | 31+++++++++++++++++++++++++++++++
3 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/crates/ui-primitives/Cargo.toml b/crates/ui-primitives/Cargo.toml @@ -11,3 +11,7 @@ crate-type = ["rlib"] [dependencies] radroots-app-ui-core = { path = "../ui-core" } +leptos = { workspace = true, features = ["csr"] } + +[target.'cfg(target_arch = "wasm32")'.dependencies] +web-sys = { workspace = true, features = ["Element"] } diff --git a/crates/ui-primitives/src/lib.rs b/crates/ui-primitives/src/lib.rs @@ -1 +1,5 @@ #![forbid(unsafe_code)] + +mod portal; + +pub use portal::{RadrootsAppUiPortal, RadrootsAppUiPortalMount}; diff --git a/crates/ui-primitives/src/portal.rs b/crates/ui-primitives/src/portal.rs @@ -0,0 +1,31 @@ +use leptos::prelude::*; + +#[cfg(target_arch = "wasm32")] +pub type RadrootsAppUiPortalMount = web_sys::Element; + +#[cfg(not(target_arch = "wasm32"))] +pub type RadrootsAppUiPortalMount = (); + +#[component] +pub fn RadrootsAppUiPortal( + #[prop(into, optional)] mount: Option<RadrootsAppUiPortalMount>, + children: Children, +) -> impl IntoView { + #[cfg(target_arch = "wasm32")] + { + view! { <Portal mount=mount>{children()}</Portal> } + } + #[cfg(not(target_arch = "wasm32"))] + { + let _ = mount; + children() + } +} + +#[cfg(test)] +mod tests { + #[test] + fn portal_availability_matches_target() { + assert!(!cfg!(target_arch = "wasm32")); + } +}