web: add buttons for just unread news and unread mail

This commit is contained in:
Bill Thiede 2025-04-13 20:52:34 -07:00
parent 81876d37ea
commit 28a5d9f219
2 changed files with 62 additions and 40 deletions

View File

@ -765,6 +765,7 @@ pub enum Msg {
NextPage,
PreviousPage,
GoToSearchResults,
UpdateQuery(String),
SearchQuery(String),

View File

@ -1212,47 +1212,68 @@ fn view_header(
let query = Url::decode_uri_component(query).unwrap_or("".to_string());
nav![
C!["flex", "px-4", "pt-4", "overflow-hidden"],
a![
C![IF![is_error => "bg-red-500"], "rounded-r-none"],
tw_classes::button(),
span![i![C![
"fa-solid",
"fa-arrow-rotate-right",
IF![is_loading => "animate-spin"],
]]],
ev(Ev::Click, |_| Msg::RefreshStart),
C!["flex", "flex-col"],
div![
C!["flex-auto", "flex"],
button![
C![IF![is_error => "bg-red-500"], "rounded-none"],
tw_classes::button(),
span![i![C![
"fa-solid",
"fa-arrow-rotate-right",
IF![is_loading => "animate-spin"],
]]],
ev(Ev::Click, |_| Msg::RefreshStart),
],
button![
tw_classes::button(),
C!["grow", "rounded-none"],
"All",
ev(Ev::Click, |_| Msg::SearchQuery(String::new())),
],
button![
tw_classes::button(),
C!["grow", "rounded-none"],
span![i![C!["far", "fa-envelope"]]],
" Unread",
ev(Ev::Click, |_| Msg::SearchQuery("is:unread".to_string())),
],
button![
tw_classes::button(),
C!["grow", "rounded-none"],
span![i![C!["far", "fa-envelope"]]],
" News",
ev(Ev::Click, |_| Msg::SearchQuery(
"is:unread is:news".to_string()
)),
],
button![
tw_classes::button(),
C!["grow", "rounded-none"],
span![i![C!["far", "fa-envelope"]]],
" Mail",
ev(Ev::Click, |_| Msg::SearchQuery(
"is:unread is:mail".to_string()
)),
],
],
a![
tw_classes::button(),
C!["px-4", "rounded-none"],
attrs! {
At::Href => urls::search(unread_query(), 0)
},
"Unread",
],
a![
tw_classes::button(),
C!["px-4", "rounded-none"],
attrs! {
At::Href => urls::search("", 0)
},
"All",
],
input![
C!["grow", "pl-2", "text-black", "rounded-r"],
attrs! {
At::Placeholder => "Search";
At::AutoFocus => auto_focus_search.as_at_value();
At::Value => query,
},
input_ev(Ev::Input, |q| Msg::UpdateQuery(q)),
// Send search on enter.
keyboard_ev(Ev::KeyUp, move |e| if e.key_code() == 0x0d {
Msg::SearchQuery(query)
} else {
Msg::Noop
}),
div![
C!["flex-auto", "flex"],
input![
C!["grow", "text-black", "m-2", "p-1"],
attrs! {
At::Placeholder => "Search";
At::AutoFocus => auto_focus_search.as_at_value();
At::Value => query,
},
input_ev(Ev::Input, |q| Msg::UpdateQuery(q)),
// Send search on enter.
keyboard_ev(Ev::KeyUp, move |e| if e.key_code() == 0x0d {
Msg::SearchQuery(query)
} else {
Msg::Noop
}),
]
]
]
}