Use nested routing for navigation

Remove dashboard_open signal
Use <a> tags to navigate to new pages
Add dashboard and search to nested routing
This commit is contained in:
2024-05-12 11:00:47 -04:00
parent 60ad643669
commit ff43b3f7e8
3 changed files with 28 additions and 27 deletions

View File

@ -14,6 +14,9 @@ pub fn App() -> impl IntoView {
// Provides context that manages stylesheets, titles, meta tags, etc.
provide_meta_context();
let play_status = PlayStatus::default();
let play_status = create_rw_signal(play_status);
view! {
// injects a stylesheet into the document <head>
// id=leptos means cargo-leptos will hot-reload this stylesheet
@ -33,7 +36,11 @@ pub fn App() -> impl IntoView {
}>
<main>
<Routes>
<Route path="" view=HomePage/>
<Route path="" view=move || view! { <HomePage play_status=play_status/> }>
<Route path="" view=Dashboard />
<Route path="dashboard" view=Dashboard />
<Route path="search" view=Search />
</Route>
<Route path="/login" view=Login />
<Route path="/signup" view=Signup />
</Routes>
@ -49,21 +56,12 @@ use crate::components::personal::*;
/// Renders the home page of your application.
#[component]
fn HomePage() -> impl IntoView {
let play_status = PlayStatus::default();
let play_status = create_rw_signal(play_status);
let (dashboard_open, set_dashboard_open) = create_signal(true);
fn HomePage(play_status: RwSignal<PlayStatus>) -> impl IntoView {
view! {
<div class="home-container">
<Sidebar setter=set_dashboard_open active=dashboard_open />
<Show
when=move || {dashboard_open() == true}
fallback=move || view! { <Search /> }
>
<Dashboard />
</Show>
<Sidebar />
// This <Outlet /> will render the child route components
<Outlet />
<Personal />
<PlayBar status=play_status/>
<Queue status=play_status/>