yggdrasil/components/
empty_state.rs1use dioxus::prelude::*;
12use dioxus::router::components::Link;
13
14use crate::components::ui::BTN_PRIMARY;
15
16#[derive(Props, Clone, PartialEq)]
18pub struct EmptyStateAction {
19 #[props(into)]
21 pub label: String,
22 pub to: crate::router::Route,
24}
25
26#[component]
33pub fn EmptyState(
34 #[props(into, default = "还没有文章".to_string())]
36 title: String,
37 #[props(into, default = String::new())]
39 description: String,
40 #[props(into, default = "/images/xiaotiaoxiaogou_01.webp".to_string())]
42 image: String,
43 #[props(default)]
45 action: Option<EmptyStateAction>,
46) -> Element {
47 rsx! {
48 div { class: "flex flex-col items-center justify-center text-center py-20 px-4 page-enter",
49 img {
51 class: "w-48 h-auto rounded-lg select-none dark:brightness-90",
52 src: "{image}",
53 alt: "线条小狗插画",
54 draggable: "false",
55 }
56 h2 { class: "mt-8 text-2xl font-bold tracking-tight text-paper-primary",
58 "{title}"
59 }
60 if !description.is_empty() {
62 p { class: "mt-3 text-sm leading-relaxed text-paper-secondary max-w-md",
63 "{description}"
64 }
65 }
66 if let Some(act) = action {
68 Link { class: "{BTN_PRIMARY} mt-8", to: act.to, "{act.label}" }
69 }
70 }
71 }
72}