From e5a27f82f9cebd7403845716e69d8f0a1af0f1b2 Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Sun, 26 Feb 2023 20:23:55 -0800 Subject: [PATCH] Restyle index table. --- notmuch/src/lib.rs | 10 ++++++---- web/index.html | 6 ++++++ web/src/lib.rs | 45 ++++++++++++++++++++++++++++++++++++--------- 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/notmuch/src/lib.rs b/notmuch/src/lib.rs index 5d5aa73..b3d2feb 100644 --- a/notmuch/src/lib.rs +++ b/notmuch/src/lib.rs @@ -425,14 +425,14 @@ pub struct SearchTags(pub Vec); pub struct ThreadSummary { pub thread: ThreadId, pub timestamp: UnixTime, - pub date_relative: String, /// user-friendly timestamp - pub matched: isize, + pub date_relative: String, /// number of matched messages - pub total: isize, + pub matched: isize, /// total messages in thread - pub authors: String, + pub total: isize, /// comma-separated names with | between matched and unmatched + pub authors: String, pub subject: String, pub tags: Vec, @@ -541,6 +541,8 @@ impl Notmuch { Ok(BufReader::new(child.stdout.take().unwrap()).lines()) } + // TODO(wathiede): implement tags() based on "notmuch search --output=tags '*'" + fn run_notmuch(&self, args: I) -> Result, NotmuchError> where I: IntoIterator, diff --git a/web/index.html b/web/index.html index 37663ac..876325c 100644 --- a/web/index.html +++ b/web/index.html @@ -6,6 +6,7 @@ + diff --git a/web/src/lib.rs b/web/src/lib.rs index 7988608..69bff0e 100644 --- a/web/src/lib.rs +++ b/web/src/lib.rs @@ -267,6 +267,10 @@ fn set_title(title: &str) { seed::document().set_title(&format!("lb: {}", title)); } +fn tags_chiclet(tags: &[String]) -> Node { + empty![] +} + fn view_search_results(query: &str, search_results: &SearchSummary) -> Node { if query.is_empty() { set_title("all mail"); @@ -276,20 +280,32 @@ fn view_search_results(query: &str, search_results: &SearchSummary) -> Node 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 { fn view_header(query: &str) -> Node { 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 { 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] + ] } // ------ ------