fix: add status_badge_class for badge styling, restore posts table backgrounds

This commit is contained in:
xfy 2026-06-04 16:17:41 +08:00
parent 58e9dbc5b7
commit c26c62558e
2 changed files with 9 additions and 2 deletions

View File

@ -68,6 +68,13 @@ impl Post {
PostStatus::Draft => "text-gray-400 dark:text-[#9b9c9d]",
}
}
pub fn status_badge_class(&self) -> &'static str {
match self.status {
PostStatus::Published => "bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300",
PostStatus::Draft => "bg-gray-100 dark:bg-[#333] text-gray-600 dark:text-[#9b9c9d]",
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]

View File

@ -105,7 +105,7 @@ pub fn Posts() -> Element {
fn PostRow(post: Post, deleting: bool, on_delete: EventHandler<i32>) -> Element {
let date_str = post.formatted_date();
let status_label = post.status_label();
let status_class = post.status_class();
let status_badge_class = post.status_badge_class();
rsx! {
tr { class: "border-b border-gray-100 dark:border-[#333] last:border-0 hover:bg-gray-50 dark:hover:bg-[#2a2a2a] transition-colors",
@ -117,7 +117,7 @@ fn PostRow(post: Post, deleting: bool, on_delete: EventHandler<i32>) -> Element
}
}
td { class: "px-4 py-3 text-center",
span { class: "inline-flex items-center px-2 py-0.5 rounded text-xs font-medium {status_class}",
span { class: "inline-flex items-center px-2 py-0.5 rounded text-xs font-medium {status_badge_class}",
"{status_label}"
}
}