yggdrasil/components/skeletons/
atoms.rs1use leptos::prelude::*;
6
7#[component]
17pub fn SkeletonBox(
18 #[prop(into)] class: String,
19 #[prop(optional, into)] style: Option<&'static str>,
20 #[prop(default = true)] animate: bool,
21) -> impl IntoView {
22 view! {
23 <div
24 class=format!("skeleton {class}")
25 data-static=(!animate).then_some("true")
26 style=style.unwrap_or("")
27 ></div>
28 }
29}
30
31#[component]
35pub fn AdminPageHeadSkeleton(
36 title_width: &'static str,
37 subtitle_width: &'static str,
38 #[prop(optional)] class: Option<&'static str>,
39 #[prop(optional, into)] actions: Option<ViewFn>,
40) -> impl IntoView {
41 let extra = class.unwrap_or_default();
42 view! {
43 <div class=format!("admin-page-head {extra}")>
44 <div>
45 <SkeletonBox class=format!("h-7 {title_width} rounded-md")/>
46 <SkeletonBox class=format!("h-3.5 {subtitle_width} rounded mt-2")/>
47 </div>
48 {actions.map(|actions| view! { <div class="admin-page-actions">{actions.run()}</div> })}
49 </div>
50 }
51}