diff --git a/frontend/src/components/layout/statusbar.rs b/frontend/src/components/layout/statusbar.rs index 709f9e4..d37c726 100644 --- a/frontend/src/components/layout/statusbar.rs +++ b/frontend/src/components/layout/statusbar.rs @@ -1,6 +1,6 @@ use leptos::*; -use wasm_bindgen::JsCast; use shared::GlobalLimitRequest; +use wasm_bindgen::JsCast; fn format_bytes(bytes: i64) -> String { const UNITS: [&str; 6] = ["B", "KB", "MB", "GB", "TB", "PB"]; @@ -27,6 +27,24 @@ pub fn StatusBar() -> impl IntoView { let store = use_context::().expect("store not provided"); let stats = store.global_stats; + let (current_theme, set_current_theme) = create_signal("light".to_string()); + + create_effect(move |_| { + if let Some(win) = web_sys::window() { + if let Some(storage) = win.local_storage().ok().flatten() { + if let Ok(Some(stored_theme)) = storage.get_item("vibetorrent_theme") { + set_current_theme.set(stored_theme.clone()); + if let Some(doc) = win.document() { + let _ = doc + .document_element() + .unwrap() + .set_attribute("data-theme", &stored_theme); + } + } + } + } + }); + // Preset limits in bytes/s let limits: Vec<(i64, &str)> = vec![ (0, "Unlimited"), @@ -83,17 +101,21 @@ pub fn StatusBar() -> impl IntoView { let close_dropdown = move || { if let Some(doc) = web_sys::window().and_then(|w| w.document()) { if let Some(active) = doc.active_element() { - let _ = active.dyn_into::().map(|el| el.blur()); + let _ = active + .dyn_into::() + .map(|el| el.blur()); } } }; // Global listener to force blur on touchstart (for iOS "tap outside" closing) let force_blur = move |_| { - if let Some(doc) = web_sys::window().and_then(|w| w.document()) { + if let Some(doc) = web_sys::window().and_then(|w| w.document()) { if let Some(active) = doc.active_element() { // If something is focused, blur it to close dropdowns - let _ = active.dyn_into::().map(|el| el.blur()); + let _ = active + .dyn_into::() + .map(|el| el.blur()); } } }; @@ -103,7 +125,7 @@ pub fn StatusBar() -> impl IntoView {
// --- DOWNLOAD SPEED DROPDOWN --- - -
// --- UPLOAD SPEED DROPDOWN --- - -