diff --git a/src/components/mod.rs b/src/components/mod.rs index 1c76c23..5a53425 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -6,4 +6,5 @@ pub mod nav; pub mod page_layout; pub mod post; pub mod post_card; +pub mod suspense_wrapper; pub mod write_skeleton; diff --git a/src/components/suspense_wrapper.rs b/src/components/suspense_wrapper.rs new file mode 100644 index 0000000..79f4f88 --- /dev/null +++ b/src/components/suspense_wrapper.rs @@ -0,0 +1,21 @@ +use dioxus::prelude::*; + +/// Wraps children in a SuspenseBoundary with a loading skeleton fallback. +/// Used for pages that fetch data via `use_server_future`. +#[component] +pub fn SuspenseWrapper(children: Element) -> Element { + rsx! { + SuspenseBoundary { + fallback: |_| rsx! { + div { class: "animate-pulse py-6 space-y-4", + div { class: "h-10 w-3/4 bg-paper-tertiary rounded" } + div { class: "h-4 w-32 bg-paper-tertiary rounded" } + div { class: "h-4 w-full bg-paper-tertiary rounded mt-8" } + div { class: "h-4 w-full bg-paper-tertiary rounded" } + div { class: "h-4 w-2/3 bg-paper-tertiary rounded" } + } + }, + {children} + } + } +}