Restyle index table.

This commit is contained in:
2023-02-26 20:23:55 -08:00
parent 19ee6f338d
commit e5a27f82f9
3 changed files with 48 additions and 13 deletions

View File

@@ -267,6 +267,10 @@ fn set_title(title: &str) {
seed::document().set_title(&format!("lb: {}", title));
}
fn tags_chiclet(tags: &[String]) -> Node<Msg> {
empty![]
}
fn view_search_results(query: &str, search_results: &SearchSummary) -> Node<Msg> {
if query.is_empty() {
set_title("all mail");
@@ -276,20 +280,32 @@ fn view_search_results(query: &str, search_results: &SearchSummary) -> Node<Msg>
let rows = search_results.0.iter().map(|r| {
let tid = r.thread.clone();
tr![
td![],
td![
C!["from"],
&r.authors,
IF!(r.total>1 => small![" ", r.total.to_string()]),
IF!(r.tags.contains(&"attachment".to_string()) => "📎"),
],
td![&r.subject],
td![&r.date_relative],
td![C!["subject"], tags_chiclet(&r.tags), &r.subject],
td![C!["date"], &r.date_relative],
ev(Ev::Click, move |_| Msg::ShowRequest(tid)),
]
});
div![table![
tr![th!["tid"], th!["From"], th!["Subject"], th!["Date"]],
rows
C![
"table",
"index",
"is-fullwidth",
"is-hoverable",
"is-narrow",
"is-striped",
],
thead![tr![
th![C!["from"], "From"],
th![C!["subject"], "Subject"],
th![C!["date"], "Date"]
]],
tbody![rows]
]]
}
@@ -343,13 +359,20 @@ fn view_debug_thread_node(thread_node: &ThreadNode) -> Node<Msg> {
fn view_header(query: &str) -> Node<Msg> {
let query = query.to_string();
div![
button![
nav![
C!["navbar"],
a![
C!["navbar-item", "button",],
"Unread",
ev(Ev::Click, |_| Msg::SearchRequest("is:unread".to_string())),
],
button!["All", ev(Ev::Click, |_| Msg::SearchRequest("".to_string())),],
a![
C!["navbar-item", "button"],
"All",
ev(Ev::Click, |_| Msg::SearchRequest("".to_string())),
],
input![
C!["navbar-item", "input"],
attrs! {
At::Placeholder => "Search";
At::AutoFocus => true.as_at_value();
@@ -373,7 +396,11 @@ fn view(model: &Model) -> Node<Msg> {
Context::Thread(thread_set) => view_thread(thread_set),
Context::Search(search_results) => view_search_results(&model.query, search_results),
};
div![view_header(&model.query), content]
section![
C!["section"],
div![C!["container"], view_header(&model.query), content]
]
}
// ------ ------