diff --git a/migrations/2024-05-16-220659_add_album_images/down.sql b/migrations/2024-05-16-220659_add_album_images/down.sql new file mode 100644 index 0000000..118e9b5 --- /dev/null +++ b/migrations/2024-05-16-220659_add_album_images/down.sql @@ -0,0 +1 @@ +ALTER TABLE albums DROP COLUMN image_path; diff --git a/migrations/2024-05-16-220659_add_album_images/up.sql b/migrations/2024-05-16-220659_add_album_images/up.sql new file mode 100644 index 0000000..b9f26dc --- /dev/null +++ b/migrations/2024-05-16-220659_add_album_images/up.sql @@ -0,0 +1 @@ +ALTER TABLE albums ADD COLUMN image_path VARCHAR; diff --git a/src/app.rs b/src/app.rs index 9fbbf2d..67a6c7a 100644 --- a/src/app.rs +++ b/src/app.rs @@ -14,6 +14,10 @@ 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); + let upload_open = create_rw_signal(false); + view! { // injects a stylesheet into the document // id=leptos means cargo-leptos will hot-reload this stylesheet @@ -33,7 +37,11 @@ pub fn App() -> impl IntoView { }>
- + }> + + + + @@ -50,22 +58,13 @@ use crate::components::upload::*; /// 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 upload_open = create_rw_signal(false); - let (dashboard_open, set_dashboard_open) = create_signal(true); - +fn HomePage(play_status: RwSignal, upload_open: RwSignal) -> impl IntoView { view! {
- - } - > - - + + // This will render the child route components + diff --git a/src/components/sidebar.rs b/src/components/sidebar.rs index 710d634..91c3a44 100644 --- a/src/components/sidebar.rs +++ b/src/components/sidebar.rs @@ -4,29 +4,31 @@ use leptos_icons::*; use crate::components::upload::*; #[component] -pub fn Sidebar(setter: WriteSignal, active: ReadSignal, upload_open: RwSignal) -> impl IntoView { - let open_dashboard = move |_| { - setter.update(|value| *value = true); - log!("open dashboard"); - }; - let open_search = move |_| { - setter.update(|value| *value = false); - log!("open search"); - }; +pub fn Sidebar(upload_open: RwSignal) -> impl IntoView { + use leptos_router::use_location; + let location = use_location(); + + let on_dashboard = Signal::derive( + move || location.pathname.get().starts_with("/dashboard") || location.pathname.get() == "/", + ); + + let on_search = Signal::derive( + move || location.pathname.get().starts_with("/search"), + ); view! {