From ca1dd0caac80565196942a6a537d057ba02c931a Mon Sep 17 00:00:00 2001 From: spinline Date: Wed, 11 Feb 2026 00:17:22 +0300 Subject: [PATCH] =?UTF-8?q?refactor:=20t=C3=BCm=20bile=C5=9Fenler=20leptos?= =?UTF-8?q?-shadcn-ui'ye=20d=C3=B6n=C3=BC=C5=9Ft=C3=BCr=C3=BCld=C3=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - login.rs: Card, Input, Button, Label, Alert - setup.rs: Card, Input, Button, Label, Alert - add_torrent.rs: Dialog, Input, Button, Alert - toast.rs: Alert bileşeni ile - Cargo.toml: dialog, label, alert, toast, dropdown-menu, tooltip eklendi --- Cargo.lock | 98 +++++++++++++++++++ frontend/Cargo.toml | 8 +- frontend/src/components/auth/login.rs | 66 +++++++------ frontend/src/components/auth/setup.rs | 88 ++++++++--------- frontend/src/components/toast.rs | 44 +++++---- .../src/components/torrent/add_torrent.rs | 96 +++++++++--------- 6 files changed, 252 insertions(+), 148 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bc36dd8..b71b5c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1260,17 +1260,23 @@ dependencies = [ "gloo-timers", "js-sys", "leptos", + "leptos-shadcn-alert", "leptos-shadcn-avatar", "leptos-shadcn-badge", "leptos-shadcn-button", "leptos-shadcn-card", "leptos-shadcn-context-menu", + "leptos-shadcn-dialog", + "leptos-shadcn-dropdown-menu", "leptos-shadcn-input", + "leptos-shadcn-label", "leptos-shadcn-progress", "leptos-shadcn-scroll-area", "leptos-shadcn-separator", "leptos-shadcn-sheet", "leptos-shadcn-tabs", + "leptos-shadcn-toast", + "leptos-shadcn-tooltip", "leptos-use", "leptos_router", "log", @@ -2159,6 +2165,21 @@ dependencies = [ "send_wrapper", ] +[[package]] +name = "leptos-shadcn-alert" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884551df61ade405bdb61b0d5a92a3a88b3a7af7a2d283b8d3e942ae0d71309c" +dependencies = [ + "leptos", + "leptos-node-ref", + "leptos-shadcn-signal-management", + "leptos-struct-component", + "leptos-style", + "tailwind_fuse", + "web-sys", +] + [[package]] name = "leptos-shadcn-avatar" version = "0.8.1" @@ -2234,6 +2255,36 @@ dependencies = [ "web-sys", ] +[[package]] +name = "leptos-shadcn-dialog" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3fdbb636393b150c2db1e37d44a6832e9dde177ce2e81281932fefad8bde98e" +dependencies = [ + "leptos", + "leptos-node-ref", + "leptos-shadcn-signal-management", + "leptos-struct-component", + "leptos-style", + "tailwind_fuse", + "web-sys", +] + +[[package]] +name = "leptos-shadcn-dropdown-menu" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f50189623a176386a30443d281483c5aa6cc34dc45fa11c3e53bd187ffccde21" +dependencies = [ + "leptos", + "leptos-node-ref", + "leptos-shadcn-signal-management", + "leptos-struct-component", + "leptos-style", + "tailwind_fuse", + "web-sys", +] + [[package]] name = "leptos-shadcn-input" version = "0.8.1" @@ -2250,6 +2301,21 @@ dependencies = [ "web-sys", ] +[[package]] +name = "leptos-shadcn-label" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e7cad4b5fae11df9bf3b1d4265a56509a9bb7d3a8580e7487f398b733eadf0c" +dependencies = [ + "leptos", + "leptos-node-ref", + "leptos-shadcn-signal-management", + "leptos-struct-component", + "leptos-style", + "tailwind_fuse", + "web-sys", +] + [[package]] name = "leptos-shadcn-progress" version = "0.8.1" @@ -2339,6 +2405,38 @@ dependencies = [ "web-sys", ] +[[package]] +name = "leptos-shadcn-toast" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3315f7ed844e3286704cc7b57db7209cad592c11eee770f5dc48ebdc92d66cfb" +dependencies = [ + "gloo-timers", + "leptos", + "leptos-node-ref", + "leptos-shadcn-signal-management", + "leptos-struct-component", + "leptos-style", + "tailwind_fuse", + "uuid", + "web-sys", +] + +[[package]] +name = "leptos-shadcn-tooltip" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e41d37932d700444e1d3a21f10f198c3c9e76dde3fd78d58da4b5a099939fd7" +dependencies = [ + "leptos", + "leptos-node-ref", + "leptos-shadcn-signal-management", + "leptos-struct-component", + "leptos-style", + "tailwind_fuse", + "web-sys", +] + [[package]] name = "leptos-struct-component" version = "0.2.0" diff --git a/frontend/Cargo.toml b/frontend/Cargo.toml index ed0b321..5a52764 100644 --- a/frontend/Cargo.toml +++ b/frontend/Cargo.toml @@ -45,4 +45,10 @@ leptos-shadcn-progress = "0.8" leptos-shadcn-avatar = "0.8" leptos-shadcn-sheet = "0.8" leptos-shadcn-tabs = "0.8" -leptos-shadcn-scroll-area = "0.8" \ No newline at end of file +leptos-shadcn-scroll-area = "0.8" +leptos-shadcn-dialog = "0.8" +leptos-shadcn-label = "0.8" +leptos-shadcn-alert = "0.8" +leptos-shadcn-toast = "0.8" +leptos-shadcn-dropdown-menu = "0.8" +leptos-shadcn-tooltip = "0.8" \ No newline at end of file diff --git a/frontend/src/components/auth/login.rs b/frontend/src/components/auth/login.rs index 676b9c1..85db36f 100644 --- a/frontend/src/components/auth/login.rs +++ b/frontend/src/components/auth/login.rs @@ -1,5 +1,10 @@ use leptos::prelude::*; use leptos::task::spawn_local; +use leptos_shadcn_card::{Card, CardHeader, CardContent}; +use leptos_shadcn_input::Input; +use leptos_shadcn_button::Button; +use leptos_shadcn_label::Label; +use leptos_shadcn_alert::{Alert, AlertDescription, AlertVariant}; #[component] pub fn Login() -> impl IntoView { @@ -32,8 +37,8 @@ pub fn Login() -> impl IntoView { view! {
-
-
+ +
@@ -42,56 +47,53 @@ pub fn Login() -> impl IntoView {

"VibeTorrent"

"Hesabınıza giriş yapın"

-
+ -
+
- - "Kullanıcı Adı" +
- - "Şifre" +
-
- {move || error.0.get().unwrap_or_default()} -
+ + + {move || error.0.get().unwrap_or_default()} + +
- +
-
-
+ +
} } \ No newline at end of file diff --git a/frontend/src/components/auth/setup.rs b/frontend/src/components/auth/setup.rs index f1972a7..fc49575 100644 --- a/frontend/src/components/auth/setup.rs +++ b/frontend/src/components/auth/setup.rs @@ -1,5 +1,10 @@ use leptos::prelude::*; use leptos::task::spawn_local; +use leptos_shadcn_card::{Card, CardHeader, CardContent}; +use leptos_shadcn_input::Input; +use leptos_shadcn_button::Button; +use leptos_shadcn_label::Label; +use leptos_shadcn_alert::{Alert, AlertDescription, AlertVariant}; #[component] pub fn Setup() -> impl IntoView { @@ -48,8 +53,8 @@ pub fn Setup() -> impl IntoView { view! {
-
-
+ +
@@ -57,74 +62,63 @@ pub fn Setup() -> impl IntoView {

"VibeTorrent Kurulumu"

"Yönetici hesabınızı oluşturun"

-
+ -
+
- - "Yönetici Kullanıcı Adı" +
- - "Şifre" +
- - "Şifre Onay" +
-
- {move || error.0.get().unwrap_or_default()} -
+ + + {move || error.0.get().unwrap_or_default()} + +
- +
-
-
+ +
} } diff --git a/frontend/src/components/toast.rs b/frontend/src/components/toast.rs index a14d259..bc35e3d 100644 --- a/frontend/src/components/toast.rs +++ b/frontend/src/components/toast.rs @@ -1,30 +1,22 @@ use leptos::prelude::*; use shared::NotificationLevel; +use leptos_shadcn_alert::{Alert, AlertVariant}; // ============================================================================ -// Toast Components - Shadcn Style +// Toast Components - Using ShadCN Alert // ============================================================================ -/// Returns the Shadcn class for the notification level -fn get_toast_class(level: &NotificationLevel) -> &'static str { +fn level_to_variant(level: &NotificationLevel) -> AlertVariant { match level { - NotificationLevel::Info => "group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-4 shadow-lg transition-all bg-background text-foreground border-border", - NotificationLevel::Success => "group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-4 shadow-lg transition-all bg-background text-foreground border-primary/50 text-primary", - NotificationLevel::Warning => "group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-4 shadow-lg transition-all bg-yellow-50 dark:bg-yellow-900/20 text-yellow-600 dark:text-yellow-500 border-yellow-200 dark:border-yellow-900", - NotificationLevel::Error => "group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-4 shadow-lg transition-all destructive group border-destructive bg-destructive text-destructive-foreground", + NotificationLevel::Info => AlertVariant::Default, + NotificationLevel::Success => AlertVariant::Success, + NotificationLevel::Warning => AlertVariant::Warning, + NotificationLevel::Error => AlertVariant::Destructive, } } -/// Individual toast item component -#[component] -fn ToastItem( - level: NotificationLevel, - message: String, -) -> impl IntoView { - let toast_class = get_toast_class(&level); - - // Icons - let icon_svg = match level { +fn level_icon(level: &NotificationLevel) -> impl IntoView { + match level { NotificationLevel::Info => view! { @@ -45,15 +37,25 @@ fn ToastItem( }.into_any(), - }; + } +} + +/// Individual toast item component +#[component] +fn ToastItem( + level: NotificationLevel, + message: String, +) -> impl IntoView { + let variant = level_to_variant(&level); + let icon = level_icon(&level); view! { -
+
- {icon_svg} + {icon}
{message}
-
+ } } diff --git a/frontend/src/components/torrent/add_torrent.rs b/frontend/src/components/torrent/add_torrent.rs index 6a64750..ace38f3 100644 --- a/frontend/src/components/torrent/add_torrent.rs +++ b/frontend/src/components/torrent/add_torrent.rs @@ -1,6 +1,9 @@ use leptos::prelude::*; -use leptos::html; use leptos::task::spawn_local; +use leptos_shadcn_dialog::{Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter}; +use leptos_shadcn_input::Input; +use leptos_shadcn_button::{Button, ButtonVariant}; +use leptos_shadcn_alert::{Alert, AlertDescription, AlertVariant}; use crate::store::TorrentStore; use crate::api; @@ -11,16 +14,10 @@ pub fn AddTorrentDialog( let store = use_context::().expect("TorrentStore not provided"); let notifications = store.notifications; - let dialog_ref = NodeRef::::new(); let uri = signal(String::new()); let is_loading = signal(false); let error_msg = signal(Option::::None); - - Effect::new(move |_| { - if let Some(dialog) = dialog_ref.get() { - let _ = dialog.show_modal(); - } - }); + let is_open = signal(true); let handle_submit = move |ev: web_sys::SubmitEvent| { ev.prevent_default(); @@ -44,9 +41,7 @@ pub fn AddTorrentDialog( shared::NotificationLevel::Success, "Torrent başarıyla eklendi" ); - if let Some(dialog) = dialog_ref.get() { - dialog.close(); - } + is_open.1.set(false); on_close.run(()); } Err(e) => { @@ -58,51 +53,58 @@ pub fn AddTorrentDialog( }); }; - let handle_cancel = move |_| { - if let Some(dialog) = dialog_ref.get() { - dialog.close(); - } - on_close.run(()); - }; view! { - - - - + + } } \ No newline at end of file