use dioxus::prelude::*;
#[component]
pub fn ThreadSummary(
reply_count: u32,
latest_sender: String,
#[props(default = 0)]
unread_count: u32,
) -> Element {
let reply_text = if reply_count == 1 {
"1 reply".to_string()
} else {
let count = reply_count;
format!("{} replies", count)
};
let latest_text = format!("Latest from {}", latest_sender);
let badge_display = if unread_count > 99 {
"99+".to_string()
} else {
unread_count.to_string()
};
rsx! {
button {
class: "thread-summary",
div {
class: "thread-summary__icon",
"\u{1F4AC}"
}
span {
class: "thread-summary__text",
"{reply_text}"
}
if unread_count > 0 {
span {
class: "thread-summary__unread-badge",
"{badge_display}"
}
}
span {
class: "thread-summary__latest",
"{latest_text}"
}
}
}
}