upub_web/components/
navigation.rs1use leptos::prelude::*;
2use crate::prelude::*;
3
4#[component]
5pub fn Breadcrumb(
6 #[prop(optional)]
7 back: bool,
8 children: Children,
9) -> impl IntoView {
10 view! {
11 <div class="tl-header w-100 center" >
12 {if back { Some(view! {
13 <a class="breadcrumb mr-1" href="javascript:history.back()" ><b>"<<"</b></a>
14 })} else { None }}
15 <b>{crate::NAME}</b>" :: "{children()}
16 </div>
17 }
18}
19
20#[component]
21pub fn Navigator(notifications: ReadSignal<u64>) -> impl IntoView {
22 let auth = use_context::<Auth>().expect("missing auth context");
23 let list_controls = use_context::<ListControls>().expect("missing list control context");
24 let (query, set_query) = signal("".to_string());
25 view! {
26 <form action={move|| format!("/web/search?q={}", query.get())}>
27 <table class="align">
28 <tr>
29 <td class="w-100">
30 <input type="text" placeholder="search" class="w-100" on:input=move |ev| {
31 set_query.set(event_target_value(&ev))
32 } />
33 </td>
34 <td>
35 <a href={move|| format!("/web/search?q={}", query.get())}><input type="submit" value="go" /></a>
36 </td>
37 </tr>
38 </table>
39 </form>
40 <table class="align w-100">
41 <tr><td colspan="2"><a href="/web/home"><input class="w-100" type="submit" class:hidden=move || !auth.present() value="home feed" /></a></td></tr>
42 <tr><td colspan="2"><a href="/web/threads"><input class="w-100" type="submit" value="threads" /></a></td></tr>
43 <tr>
44 <td><a href="/web/global"><input class="w-100" type="submit" value="global" /></a></td>
45 <td><a href="/web/local"><input class="w-100" type="submit" value="local" /></a></td>
46 </tr>
47 <tr class:hidden=move || !auth.present() >
48 <td><a href="/web/lists"><input class="w-100" type="submit" value="lists" /></a></td>
49 <td>
50 <select
51 name="active list"
52 id="active-list"
53 class="w-100 center"
54 on:change:target=move |ev| {
55 let value = Some(ev.target().value()).filter(|x| !x.is_empty());
56 list_controls.set_active.set(value);
57 }
58 prop:value=move || list_controls.active.get().unwrap_or_default()
59 >
60 <option value="" selected>"--"</option>
61 <For
62 each=move || list_controls.available.get()
63 key=move |x| x.clone()
64 let(id)
65 >
66 <option value={id}>{list_controls.list_name(&id)}</option>
67 </For>
68 </select>
69 </td>
70 </tr>
71 <tr>
72 <td class="w-50"><a href="/web/about"><input class="w-100" type="submit" value="about" /></a></td>
73 <td class="w-50"><a href="/web/config"><input class="w-100" type="submit" value="config" /></a></td>
74 </tr>
75 <tr><td colspan="2"><a href="/web/notifications"><input class="w-100" type="submit" class:hidden=move || !auth.present() value=move || format!("notifications [{}]", notifications.get()) /></a></td></tr>
76 <tr><td colspan="2"><a href="/web/explore"><input class="w-100" type="submit" class:hidden=move || !auth.present() value="explore" /></a></td></tr>
77 </table>
78 }
79}