synpad 0.1.0

A full-featured Matrix chat client built with Dioxus
use dioxus::prelude::*;

/// Thread summary indicator shown on messages that have threads.
/// Displays a reply count, latest sender, and an optional unread badge.
#[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}"
            }
        }
    }
}