yggdrasil/components/comments/
card.rs1use dioxus::prelude::*;
11
12use crate::components::ui::UserAvatar;
13
14#[component]
33pub fn CommentCardShell(
34 depth: i32,
35 #[props(default)] muted: bool,
36 avatar_url: String,
37 author_name: String,
38 author_element: Element,
39 author_badge: Element,
40 timestamp: Element,
41 status_badge: Element,
42 content_html: String,
43 #[props(default)] content_extra_class: &'static str,
44 children: Element,
45) -> Element {
46 let is_child = depth > 0;
47
48 rsx! {
49 div {
50 class: "py-3.5 transition-colors",
51 class: if muted { "opacity-75 transition-opacity" } else { "" },
52 class: if is_child { "border-l-2 border-[var(--color-paper-border)]/50 pl-3.5 sm:pl-4.5 my-1" } else { "" },
53 style: if depth > 1 { format!("margin-left: {}px;", (depth.min(5) - 1) * 16) } else { String::new() },
54
55 div { class: "flex items-start gap-3",
56 UserAvatar {
57 name: author_name,
58 avatar_url: Some(avatar_url),
59 class: "w-8 h-8 rounded-full shrink-0 object-cover ring-1 ring-[var(--color-paper-border)]/60 bg-[var(--color-paper-entry)] mt-0.5",
60 }
61
62 div { class: "flex-1 min-w-0",
63 div { class: "flex items-center gap-2 text-xs mb-1 flex-wrap",
64 {author_element}
65 {author_badge}
66 span { class: "text-paper-tertiary", "·" }
67 {timestamp}
68 {status_badge}
69 }
70
71 div {
72 class: if content_extra_class.is_empty() {
73 "prose prose-sm dark:prose-invert max-w-none text-paper-secondary leading-relaxed".to_string()
74 } else {
75 format!("prose prose-sm dark:prose-invert max-w-none text-paper-secondary {content_extra_class} leading-relaxed")
76 },
77 dangerous_inner_html: "{content_html}",
78 }
79
80 {children}
81 }
82 }
83 }
84 }
85}