feat: add SuspenseWrapper component for SSR

This commit is contained in:
xfy 2026-06-03 14:14:45 +08:00
parent 5e449013d6
commit 60a2cd49ab
2 changed files with 22 additions and 0 deletions

View File

@ -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;

View File

@ -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}
}
}
}