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