chore(web): component for tl nav
This commit is contained in:
parent
f8b135d242
commit
1e6d11b5dc
2 changed files with 26 additions and 17 deletions
|
@ -89,6 +89,29 @@ pub fn LoginBox(
|
|||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn TimelineNavigation() -> impl IntoView {
|
||||
let auth = use_context::<Signal<Option<Auth>>>().expect("missing auth context");
|
||||
view! {
|
||||
<a href="/web/home" >
|
||||
<input class="w-100"
|
||||
type="submit"
|
||||
class:hidden=move || !auth.get().present()
|
||||
class:active=move || use_location().pathname.get().ends_with("/home")
|
||||
value="home timeline"
|
||||
/>
|
||||
</a>
|
||||
<a href="/web/server" >
|
||||
<input
|
||||
class="w-100"
|
||||
class:active=move || use_location().pathname.get().ends_with("/server")
|
||||
type="submit"
|
||||
value="server timeline"
|
||||
/>
|
||||
</a>
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn PostBox() -> impl IntoView {
|
||||
let auth = use_context::<Signal<Option<Auth>>>().expect("missing auth context");
|
||||
|
|
|
@ -3,7 +3,8 @@ use leptos_router::*;
|
|||
|
||||
use leptos_use::{use_cookie, utils::JsonCodec};
|
||||
use upub_web::{
|
||||
URL_BASE, context::Timeline, About, Auth, LoginBox, MaybeToken, ObjectPage, PostBox, TimelineFeed, UserPage
|
||||
URL_BASE, context::Timeline, About, Auth, LoginBox, MaybeToken, ObjectPage, PostBox,
|
||||
TimelineFeed, TimelineNavigation, UserPage
|
||||
};
|
||||
|
||||
fn main() {
|
||||
|
@ -63,22 +64,7 @@ fn main() {
|
|||
rx=cookie
|
||||
/>
|
||||
<hr class="mt-1 mb-1" />
|
||||
<a href="/web/home" >
|
||||
<input class="w-100"
|
||||
type="submit"
|
||||
class:hidden=move || !cookie.get().present()
|
||||
class:active=move || use_location().pathname.get().ends_with("/home")
|
||||
value="home timeline"
|
||||
/>
|
||||
</a>
|
||||
<a href="/web/server" >
|
||||
<input
|
||||
class="w-100"
|
||||
class:active=move || use_location().pathname.get().ends_with("/server")
|
||||
type="submit"
|
||||
value="server timeline"
|
||||
/>
|
||||
</a>
|
||||
<TimelineNavigation />
|
||||
<hr class="mt-1 mb-1" />
|
||||
<PostBox />
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue