web: add buttons for just unread news and unread mail
This commit is contained in:
parent
81876d37ea
commit
28a5d9f219
@ -765,6 +765,7 @@ pub enum Msg {
|
|||||||
NextPage,
|
NextPage,
|
||||||
PreviousPage,
|
PreviousPage,
|
||||||
GoToSearchResults,
|
GoToSearchResults,
|
||||||
|
|
||||||
UpdateQuery(String),
|
UpdateQuery(String),
|
||||||
SearchQuery(String),
|
SearchQuery(String),
|
||||||
|
|
||||||
|
|||||||
@ -1212,47 +1212,68 @@ fn view_header(
|
|||||||
let query = Url::decode_uri_component(query).unwrap_or("".to_string());
|
let query = Url::decode_uri_component(query).unwrap_or("".to_string());
|
||||||
|
|
||||||
nav![
|
nav![
|
||||||
C!["flex", "px-4", "pt-4", "overflow-hidden"],
|
C!["flex", "flex-col"],
|
||||||
a![
|
div![
|
||||||
C![IF![is_error => "bg-red-500"], "rounded-r-none"],
|
C!["flex-auto", "flex"],
|
||||||
tw_classes::button(),
|
button![
|
||||||
span![i![C![
|
C![IF![is_error => "bg-red-500"], "rounded-none"],
|
||||||
"fa-solid",
|
tw_classes::button(),
|
||||||
"fa-arrow-rotate-right",
|
span![i![C![
|
||||||
IF![is_loading => "animate-spin"],
|
"fa-solid",
|
||||||
]]],
|
"fa-arrow-rotate-right",
|
||||||
ev(Ev::Click, |_| Msg::RefreshStart),
|
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![
|
div![
|
||||||
tw_classes::button(),
|
C!["flex-auto", "flex"],
|
||||||
C!["px-4", "rounded-none"],
|
input![
|
||||||
attrs! {
|
C!["grow", "text-black", "m-2", "p-1"],
|
||||||
At::Href => urls::search(unread_query(), 0)
|
attrs! {
|
||||||
},
|
At::Placeholder => "Search";
|
||||||
"Unread",
|
At::AutoFocus => auto_focus_search.as_at_value();
|
||||||
],
|
At::Value => query,
|
||||||
a![
|
},
|
||||||
tw_classes::button(),
|
input_ev(Ev::Input, |q| Msg::UpdateQuery(q)),
|
||||||
C!["px-4", "rounded-none"],
|
// Send search on enter.
|
||||||
attrs! {
|
keyboard_ev(Ev::KeyUp, move |e| if e.key_code() == 0x0d {
|
||||||
At::Href => urls::search("", 0)
|
Msg::SearchQuery(query)
|
||||||
},
|
} else {
|
||||||
"All",
|
Msg::Noop
|
||||||
],
|
}),
|
||||||
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
|
|
||||||
}),
|
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user