Skip to main content

yggdrasil/components/skeletons/
comment_skeleton.rs

1//! 评论列表骨架屏
2//!
3//! 在评论数据加载期间展示评论条目占位,结构和间距与真实评论列表一致。
4
5use crate::components::skeletons::atoms::*;
6use dioxus::prelude::*;
7
8/// 评论列表骨架屏组件。
9///
10/// 渲染若干条评论条目占位,包含头像、作者名与内容行,样式与真实评论项对齐。
11#[component]
12pub fn CommentListSkeleton() -> Element {
13    rsx! {
14        div { class: "divide-y divide-gray-100 dark:divide-gray-700",
15            // 第一条评论占位(顶层评论)
16            div { class: "py-4",
17                div { class: "flex gap-3",
18                    SkeletonBox { class: "w-8 h-8 rounded-full shrink-0 mt-0.5" }
19                    div { class: "flex-1 space-y-2",
20                        SkeletonBox { class: "h-4 w-24 rounded" }
21                        SkeletonBox { class: "h-3.5 w-full rounded" }
22                        SkeletonBox { class: "h-3.5 w-2/3 rounded" }
23                    }
24                }
25            }
26            // 第二条评论占位(子回复,缩进 ml-6 即 24px)
27            div { class: "py-4 ml-6",
28                div { class: "flex gap-3",
29                    SkeletonBox { class: "w-8 h-8 rounded-full shrink-0 mt-0.5" }
30                    div { class: "flex-1 space-y-2",
31                        SkeletonBox { class: "h-4 w-20 rounded" }
32                        SkeletonBox { class: "h-3.5 w-3/4 rounded" }
33                    }
34                }
35            }
36            // 第三条评论占位(另一条顶层评论)
37            div { class: "py-4",
38                div { class: "flex gap-3",
39                    SkeletonBox { class: "w-8 h-8 rounded-full shrink-0 mt-0.5" }
40                    div { class: "flex-1 space-y-2",
41                        SkeletonBox { class: "h-4 w-28 rounded" }
42                        SkeletonBox { class: "h-3.5 w-full rounded" }
43                        SkeletonBox { class: "h-3.5 w-1/2 rounded" }
44                    }
45                }
46            }
47        }
48    }
49}