From 5bd3d31dd6ff081099249ce638911584b6beac92 Mon Sep 17 00:00:00 2001 From: spinline Date: Wed, 11 Feb 2026 01:08:18 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20Tema=20Butonu=20Sidebar'a=20Ta=C5=9F?= =?UTF-8?q?=C4=B1nd=C4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - sidebar.rs: Tema state yönetimi ve UI butonu eklendi (profil alanının yanına) - statusbar.rs: Tema ile ilgili eski kodlar ve UI kaldırıldı - implementation_plan.md: Plan dosyası oluşturuldu - task.md: Görev tamamlandı olarak işaretlendi --- frontend/src/components/layout/sidebar.rs | 80 +++++++++++++++++++++ frontend/src/components/layout/statusbar.rs | 66 ----------------- 2 files changed, 80 insertions(+), 66 deletions(-) diff --git a/frontend/src/components/layout/sidebar.rs b/frontend/src/components/layout/sidebar.rs index 00e2234..87fd4a4 100644 --- a/frontend/src/components/layout/sidebar.rs +++ b/frontend/src/components/layout/sidebar.rs @@ -3,6 +3,9 @@ use leptos::task::spawn_local; use leptos_shadcn_button::{Button, ButtonVariant, ButtonSize}; use leptos_shadcn_avatar::{Avatar, AvatarFallback}; use leptos_shadcn_separator::Separator; +use leptos::html; +use leptos_use::storage::use_local_storage; +use ::codee::string::FromToStringCodec; #[component] pub fn Sidebar() -> impl IntoView { @@ -67,6 +70,37 @@ pub fn Sidebar() -> impl IntoView { username().chars().next().unwrap_or('?').to_uppercase().to_string() }; + // --- THEME LOGIC START --- + let (current_theme, set_current_theme, _) = use_local_storage::("vibetorrent_theme"); + + // Initialize with default if empty + let current_theme_val = current_theme.get(); + if current_theme_val.is_empty() { + set_current_theme.set("dark".to_string()); + } + + // Automatically sync theme to document attribute + Effect::new(move |_| { + let theme = current_theme.get().to_lowercase(); + if let Some(doc) = document().document_element() { + let _ = doc.set_attribute("data-theme", &theme); + // Also set class for Shadcn dark mode support + if theme == "dark" || theme == "dracula" || theme == "dim" || theme == "abyss" || theme == "sunset" || theme == "cyberpunk" || theme == "nord" || theme == "business" || theme == "night" || theme == "black" || theme == "luxury" || theme == "coffee" || theme == "forest" || theme == "halloween" || theme == "synthwave" { + let _ = doc.class_list().add_1("dark"); + } else { + let _ = doc.class_list().remove_1("dark"); + } + } + }); + + let theme_details_ref = NodeRef::::new(); + let close_details = move |node_ref: NodeRef| { + if let Some(el) = node_ref.get_untracked() { + el.set_open(false); + } + }; + // --- THEME LOGIC END --- + view! {
@@ -169,6 +203,52 @@ pub fn Sidebar() -> impl IntoView {
{username}
"Online"
+ + // --- THEME BUTTON --- +
+ + + + + + + +
- } - }).collect::>() - } - -
-