Compare commits
11 Commits
release-20
...
release-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8fc3571848 | ||
|
|
792b6bc97b | ||
|
|
6efa6cd2d9 | ||
|
|
89caa17b92 | ||
|
|
47bb60d7d8 | ||
|
|
7730250b61 | ||
|
|
73d111124a | ||
|
|
670c5a653b | ||
|
|
9394a56e7d | ||
|
|
105388eec3 | ||
|
|
f5d9cb642c |
@@ -45,15 +45,8 @@
|
|||||||
--ring: oklch(0.556 0 0);
|
--ring: oklch(0.556 0 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@theme inline {
|
@theme inline {
|
||||||
--animate-shimmer: shimmer 2s infinite;
|
|
||||||
|
|
||||||
@keyframes shimmer {
|
|
||||||
100% {
|
|
||||||
transform: translateX(100%);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
--color-background: var(--background);
|
--color-background: var(--background);
|
||||||
--color-foreground: var(--foreground);
|
--color-foreground: var(--foreground);
|
||||||
--color-card: var(--card);
|
--color-card: var(--card);
|
||||||
@@ -83,7 +76,6 @@
|
|||||||
* {
|
* {
|
||||||
@apply border-border outline-ring/50;
|
@apply border-border outline-ring/50;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
@apply bg-background text-foreground;
|
@apply bg-background text-foreground;
|
||||||
}
|
}
|
||||||
@@ -96,4 +88,4 @@
|
|||||||
dialog {
|
dialog {
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,91 +0,0 @@
|
|||||||
use leptos::prelude::*;
|
|
||||||
use leptos::task::spawn_local;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
use crate::components::ui::button::{Button, ButtonVariant};
|
|
||||||
use crate::components::ui::card::{Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle};
|
|
||||||
use crate::components::ui::shimmer::Shimmer;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct CardData {
|
|
||||||
pub title: String,
|
|
||||||
pub description: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Simulates a database fetch with 1 second delay
|
|
||||||
#[server]
|
|
||||||
pub async fn fetch_card_data() -> Result<CardData, ServerFnError> {
|
|
||||||
// Simulate network/database latency (only on server)
|
|
||||||
#[cfg(feature = "ssr")]
|
|
||||||
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
|
|
||||||
|
|
||||||
Ok(CardData {
|
|
||||||
title: "Fetched Title".to_string(),
|
|
||||||
description: "This content was fetched from the server after a 1 second simulated delay. The shimmer effect automatically showed during the loading period.".to_string(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn DemoShimmer() -> impl IntoView {
|
|
||||||
// Loading state
|
|
||||||
let loading = RwSignal::new(false);
|
|
||||||
|
|
||||||
// Store fetched data
|
|
||||||
let card_data = RwSignal::new(None::<CardData>);
|
|
||||||
|
|
||||||
// Fetch handler using spawn_local for reliable repeated calls
|
|
||||||
let on_fetch = move |_| {
|
|
||||||
spawn_local(async move {
|
|
||||||
loading.set(true);
|
|
||||||
let result = fetch_card_data().await;
|
|
||||||
if let Ok(data) = result {
|
|
||||||
card_data.set(Some(data));
|
|
||||||
}
|
|
||||||
loading.set(false);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
view! {
|
|
||||||
<div class="flex flex-col gap-4">
|
|
||||||
<div class="flex gap-2">
|
|
||||||
<Button variant=ButtonVariant::Outline on:click=move |_| loading.set(!loading.get())>
|
|
||||||
"Toggle Loading"
|
|
||||||
</Button>
|
|
||||||
<Button variant=ButtonVariant::Default on:click=on_fetch>
|
|
||||||
"Fetch Data (1s)"
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Shimmer loading=Signal::from(loading)>
|
|
||||||
<Card class="max-w-lg lg:max-w-2xl">
|
|
||||||
<CardHeader>
|
|
||||||
<CardTitle>
|
|
||||||
{move || {
|
|
||||||
card_data.get().map(|data| data.title).unwrap_or_else(|| "Card Title".to_string())
|
|
||||||
}}
|
|
||||||
</CardTitle>
|
|
||||||
</CardHeader>
|
|
||||||
|
|
||||||
<CardContent>
|
|
||||||
<CardDescription>
|
|
||||||
{move || {
|
|
||||||
card_data
|
|
||||||
.get()
|
|
||||||
.map(|data| data.description)
|
|
||||||
.unwrap_or_else(|| {
|
|
||||||
"Click 'Toggle Loading' for manual control, or 'Fetch Data' to simulate a real server call with 1 second delay."
|
|
||||||
.to_string()
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
</CardDescription>
|
|
||||||
</CardContent>
|
|
||||||
|
|
||||||
<CardFooter class="justify-end">
|
|
||||||
<Button variant=ButtonVariant::Outline>"Cancel"</Button>
|
|
||||||
<Button>"Confirm"</Button>
|
|
||||||
</CardFooter>
|
|
||||||
</Card>
|
|
||||||
</Shimmer>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
pub mod demo_shimmer;
|
|
||||||
@@ -1,31 +1,5 @@
|
|||||||
use std::collections::hash_map::DefaultHasher;
|
// use leptos::prelude::*;
|
||||||
use std::hash::{Hash, Hasher};
|
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
|
||||||
|
|
||||||
const PREFIX: &str = "rust_ui"; // Must NOT contain "/" or "-"
|
pub fn use_random_id_for(prefix: &str) -> String {
|
||||||
|
format!("{}_{}", prefix, js_sys::Math::random().to_string().replace(".", ""))
|
||||||
pub fn use_random_id() -> String {
|
|
||||||
format!("_{PREFIX}_{}", generate_hash())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn use_random_id_for(element: &str) -> String {
|
|
||||||
format!("{}_{PREFIX}_{}", element, generate_hash())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn use_random_transition_name() -> String {
|
|
||||||
let random_id = use_random_id();
|
|
||||||
format!("view-transition-name: {random_id}")
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ========================================================== */
|
|
||||||
/* ✨ FUNCTIONS ✨ */
|
|
||||||
/* ========================================================== */
|
|
||||||
|
|
||||||
static COUNTER: AtomicUsize = AtomicUsize::new(1);
|
|
||||||
|
|
||||||
fn generate_hash() -> u64 {
|
|
||||||
let mut hasher = DefaultHasher::new();
|
|
||||||
let counter = COUNTER.fetch_add(1, Ordering::SeqCst);
|
|
||||||
counter.hash(&mut hasher);
|
|
||||||
hasher.finish()
|
|
||||||
}
|
|
||||||
@@ -3,20 +3,53 @@ use crate::components::layout::sidebar::Sidebar;
|
|||||||
use crate::components::layout::toolbar::Toolbar;
|
use crate::components::layout::toolbar::Toolbar;
|
||||||
use crate::components::layout::footer::Footer;
|
use crate::components::layout::footer::Footer;
|
||||||
use crate::components::ui::sidenav::{SidenavWrapper, Sidenav, SidenavInset};
|
use crate::components::ui::sidenav::{SidenavWrapper, Sidenav, SidenavInset};
|
||||||
|
use wasm_bindgen::JsCast;
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Protected(children: Children) -> impl IntoView {
|
pub fn Protected(children: Children) -> impl IntoView {
|
||||||
|
let (collapsed, set_collapsed) = signal(false);
|
||||||
|
|
||||||
|
// Responsive Sidebar Logic
|
||||||
|
Effect::new(move |_| {
|
||||||
|
let window = web_sys::window().expect("window missing");
|
||||||
|
|
||||||
|
// Initial check
|
||||||
|
let width = window.inner_width().unwrap().as_f64().unwrap_or(1920.0);
|
||||||
|
if width < 1280.0 {
|
||||||
|
set_collapsed.set(true);
|
||||||
|
} else {
|
||||||
|
set_collapsed.set(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Listener
|
||||||
|
let closure = wasm_bindgen::closure::Closure::<dyn FnMut(_)>::new(move |_: web_sys::Event| {
|
||||||
|
let window = web_sys::window().expect("window missing");
|
||||||
|
let width = window.inner_width().unwrap().as_f64().unwrap_or(1920.0);
|
||||||
|
if width < 1280.0 {
|
||||||
|
set_collapsed.set(true);
|
||||||
|
} else {
|
||||||
|
set_collapsed.set(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let _ = window.add_event_listener_with_callback("resize", closure.as_ref().unchecked_ref());
|
||||||
|
closure.forget(); // Leak memory intentionally for global listener (or store in a cleanup handle if needed, but for layout component it's fine)
|
||||||
|
});
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<SidenavWrapper attr:style="--sidenav-width:16rem; --sidenav-width-icon:3rem;">
|
<SidenavWrapper attr:style="--sidenav-width:16rem; --sidenav-width-icon:3rem;">
|
||||||
// Masaüstü Sidenav
|
// Masaüstü Sidenav
|
||||||
<Sidenav>
|
<Sidenav
|
||||||
|
data_collapsible=crate::components::ui::sidenav::SidenavCollapsible::Icon
|
||||||
|
data_state=if collapsed.get() { crate::components::ui::sidenav::SidenavState::Collapsed } else { crate::components::ui::sidenav::SidenavState::Expanded }
|
||||||
|
>
|
||||||
<Sidebar />
|
<Sidebar />
|
||||||
</Sidenav>
|
</Sidenav>
|
||||||
|
|
||||||
// İçerik Alanı
|
// İçerik Alanı
|
||||||
<SidenavInset class="flex flex-col h-screen overflow-hidden">
|
<SidenavInset class="flex flex-col h-screen overflow-hidden">
|
||||||
// Toolbar (Üst Bar)
|
// Toolbar (Üst Bar)
|
||||||
<Toolbar />
|
<Toolbar on_toggle_sidebar=Callback::new(move |_| set_collapsed.update(|c| *c = !*c)) />
|
||||||
|
|
||||||
// Ana İçerik
|
// Ana İçerik
|
||||||
<main class="flex-1 overflow-y-auto relative bg-background flex flex-col">
|
<main class="flex-1 overflow-y-auto relative bg-background flex flex-col">
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ pub fn Sidebar() -> impl IntoView {
|
|||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M15.362 5.214A8.252 8.252 0 0112 21 8.25 8.25 0 016.038 7.048 8.287 8.287 0 009 9.6a8.983 8.983 0 013.361-6.867 8.21 8.25 0 003 2.48z" />
|
<path stroke-linecap="round" stroke-linejoin="round" d="M15.362 5.214A8.252 8.252 0 0112 21 8.25 8.25 0 016.038 7.048 8.287 8.287 0 009 9.6a8.983 8.983 0 013.361-6.867 8.21 8.25 0 003 2.48z" />
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid flex-1 text-left text-sm leading-tight overflow-hidden">
|
<div class="grid flex-1 text-left text-sm leading-tight overflow-hidden group-data-[state=Collapsed]:hidden">
|
||||||
<span class="truncate font-semibold text-foreground text-base">"VibeTorrent"</span>
|
<span class="truncate font-semibold text-foreground text-base">"VibeTorrent"</span>
|
||||||
<span class="truncate text-[10px] text-muted-foreground opacity-70">"v3.0.0"</span>
|
<span class="truncate text-[10px] text-muted-foreground opacity-70">"v3.0.0"</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -150,26 +150,28 @@ pub fn Sidebar() -> impl IntoView {
|
|||||||
<div class="flex flex-col gap-4 p-4">
|
<div class="flex flex-col gap-4 p-4">
|
||||||
// Push Notification Toggle
|
// Push Notification Toggle
|
||||||
<div class="flex items-center justify-between px-2 py-1 bg-muted/20 rounded-md border border-border/50">
|
<div class="flex items-center justify-between px-2 py-1 bg-muted/20 rounded-md border border-border/50">
|
||||||
<div class="flex flex-col gap-0.5">
|
<div class="flex flex-col gap-0.5 group-data-[state=Collapsed]:hidden">
|
||||||
<span class="text-[10px] font-bold uppercase tracking-wider text-foreground/70">"Bildirimler"</span>
|
<span class="text-[10px] font-bold uppercase tracking-wider text-foreground/70">"Bildirimler"</span>
|
||||||
<span class="text-[9px] text-muted-foreground">"Web Push"</span>
|
<span class="text-[9px] text-muted-foreground">"Web Push"</span>
|
||||||
</div>
|
</div>
|
||||||
<Switch
|
<div class="group-data-[state=Collapsed]:hidden">
|
||||||
checked=Signal::from(store.push_enabled)
|
<Switch
|
||||||
on_checked_change=Callback::new(on_push_toggle)
|
checked=Signal::from(store.push_enabled)
|
||||||
/>
|
on_checked_change=Callback::new(on_push_toggle)
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-center gap-3 p-2 rounded-lg border bg-muted/30 shadow-xs overflow-hidden">
|
<div class="flex items-center gap-3 p-2 rounded-lg border bg-muted/30 shadow-xs overflow-hidden group-data-[state=Collapsed]:gap-0 group-data-[state=Collapsed]:justify-center group-data-[state=Collapsed]:p-0 group-data-[state=Collapsed]:border-none group-data-[state=Collapsed]:bg-transparent group-data-[state=Collapsed]:shadow-none">
|
||||||
<div class="h-8 w-8 rounded-full bg-primary text-primary-foreground flex items-center justify-center text-xs font-medium shrink-0 border border-primary-foreground/10">
|
<div class="h-8 w-8 rounded-full bg-primary text-primary-foreground flex items-center justify-center text-xs font-medium shrink-0 border border-primary-foreground/10">
|
||||||
{first_letter}
|
{first_letter}
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-1 overflow-hidden">
|
<div class="flex-1 overflow-hidden group-data-[state=Collapsed]:hidden">
|
||||||
<div class="font-medium text-[11px] truncate text-foreground leading-tight">{username}</div>
|
<div class="font-medium text-[11px] truncate text-foreground leading-tight">{username}</div>
|
||||||
<div class="text-[9px] text-muted-foreground truncate opacity-70">"Yönetici"</div>
|
<div class="text-[9px] text-muted-foreground truncate opacity-70">"Yönetici"</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-center gap-1">
|
<div class="flex items-center gap-1 group-data-[state=Collapsed]:hidden">
|
||||||
<ThemeToggle />
|
<ThemeToggle />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
@@ -217,8 +219,8 @@ fn SidebarItem(
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4 shrink-0">
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4 shrink-0">
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d=icon.clone() />
|
<path stroke-linecap="round" stroke-linejoin="round" d=icon.clone() />
|
||||||
</svg>
|
</svg>
|
||||||
<span class="flex-1 truncate">{label}</span>
|
<span class="flex-1 truncate group-data-[state=Collapsed]:hidden">{label}</span>
|
||||||
<span class="text-[10px] font-mono opacity-50">{count}</span>
|
<span class="text-[10px] font-mono opacity-50 group-data-[state=Collapsed]:hidden">{count}</span>
|
||||||
</SidenavMenuButton>
|
</SidenavMenuButton>
|
||||||
</SidenavMenuItem>
|
</SidenavMenuItem>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,38 @@
|
|||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use icons::{PanelLeft, Plus};
|
use icons::{PanelLeft, Plus};
|
||||||
use crate::components::torrent::add_torrent::AddTorrentDialogContent;
|
use crate::components::torrent::add_torrent::AddTorrentDialogContent;
|
||||||
use crate::components::ui::button::{ButtonVariant, ButtonSize};
|
use crate::components::ui::button::{Button, ButtonVariant, ButtonSize};
|
||||||
use crate::components::ui::sheet::{Sheet, SheetContent, SheetTrigger, SheetDirection};
|
use crate::components::ui::sheet::{Sheet, SheetContent, SheetTrigger, SheetDirection};
|
||||||
use crate::components::ui::dialog::{Dialog, DialogContent, DialogTrigger};
|
use crate::components::ui::dialog::{Dialog, DialogContent, DialogTrigger};
|
||||||
use crate::components::layout::sidebar::Sidebar;
|
use crate::components::layout::sidebar::Sidebar;
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Toolbar() -> impl IntoView {
|
pub fn Toolbar(
|
||||||
|
on_toggle_sidebar: Callback<()>,
|
||||||
|
) -> impl IntoView {
|
||||||
view! {
|
view! {
|
||||||
<div class="flex min-h-14 h-auto items-center border-b border-border bg-background px-4" style="padding-top: env(safe-area-inset-top);">
|
<div class="flex min-h-14 h-auto items-center border-b border-border bg-background px-4" style="padding-top: env(safe-area-inset-top);">
|
||||||
// Sol kısım: Menü butonu (Mobil) + Add Torrent
|
// Sol kısım: Menü butonu (Mobil) + Add Torrent
|
||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-3">
|
||||||
|
// Desktop Toggle
|
||||||
// --- MOBILE SHEET (SIDEBAR) ---
|
<div class="hidden lg:block">
|
||||||
|
<Button
|
||||||
|
variant=ButtonVariant::Ghost
|
||||||
|
size=ButtonSize::Icon
|
||||||
|
class="size-9"
|
||||||
|
on:click=move |_| { on_toggle_sidebar.run(()); }
|
||||||
|
>
|
||||||
|
<PanelLeft class="size-5" />
|
||||||
|
<span class="hidden">"Toggle Sidebar"</span>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
// Mobile Toggle (Sheet)
|
||||||
<div class="lg:hidden">
|
<div class="lg:hidden">
|
||||||
<Sheet>
|
<Sheet>
|
||||||
<SheetTrigger variant=ButtonVariant::Ghost size=ButtonSize::Icon class="size-9">
|
<SheetTrigger variant=ButtonVariant::Ghost size=ButtonSize::Icon class="size-9">
|
||||||
<PanelLeft class="size-5" />
|
<PanelLeft class="size-5" />
|
||||||
<span class="hidden">"Menüyü Aç"</span>
|
<span class="hidden">"Open Menu"</span>
|
||||||
</SheetTrigger>
|
</SheetTrigger>
|
||||||
<SheetContent
|
<SheetContent
|
||||||
direction=SheetDirection::Left
|
direction=SheetDirection::Left
|
||||||
|
|||||||
@@ -5,4 +5,3 @@ pub mod torrent;
|
|||||||
pub mod auth;
|
pub mod auth;
|
||||||
// pub mod toast; (Removed)
|
// pub mod toast; (Removed)
|
||||||
pub mod ui;
|
pub mod ui;
|
||||||
pub mod demos;
|
|
||||||
|
|||||||
@@ -1,178 +0,0 @@
|
|||||||
use leptos::prelude::*;
|
|
||||||
use crate::components::ui::sheet::*;
|
|
||||||
use crate::components::ui::tabs::*;
|
|
||||||
use crate::components::ui::skeleton::*;
|
|
||||||
use shared::Torrent;
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn TorrentDetailsSheet() -> impl IntoView {
|
|
||||||
let store = use_context::<crate::store::TorrentStore>().expect("store not provided");
|
|
||||||
|
|
||||||
// Setup an effect to open the sheet when a torrent is selected
|
|
||||||
Effect::new(move |_| {
|
|
||||||
if store.selected_torrent.get().is_some() {
|
|
||||||
if let Some(trigger) = document().get_element_by_id("torrent-details-trigger") {
|
|
||||||
use wasm_bindgen::JsCast;
|
|
||||||
let _ = trigger.dyn_into::<web_sys::HtmlElement>().map(|el| el.click());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let selected_torrent = Memo::new(move |_| {
|
|
||||||
let hash = store.selected_torrent.get()?;
|
|
||||||
store.torrents.with(|map| map.get(&hash).cloned())
|
|
||||||
});
|
|
||||||
|
|
||||||
view! {
|
|
||||||
<Sheet>
|
|
||||||
<SheetTrigger attr:id="torrent-details-trigger" class="hidden">""</SheetTrigger>
|
|
||||||
<SheetContent
|
|
||||||
direction=SheetDirection::Bottom
|
|
||||||
class="h-[80vh] sm:h-[60vh] rounded-t-xl sm:rounded-t-2xl p-0 flex flex-col gap-0 border-t border-border shadow-2xl"
|
|
||||||
hide_close_button=true
|
|
||||||
>
|
|
||||||
<div class="px-6 py-4 border-b flex items-center justify-between sticky top-0 bg-card z-10">
|
|
||||||
<div class="flex flex-col gap-1 min-w-0">
|
|
||||||
<Show when=move || selected_torrent.get().is_some() fallback=move || view! { <Skeleton class="h-6 w-48" /> }>
|
|
||||||
<h2 class="font-bold text-lg truncate">
|
|
||||||
{move || selected_torrent.get().map(|t| t.name).unwrap_or_default()}
|
|
||||||
</h2>
|
|
||||||
</Show>
|
|
||||||
<Show when=move || selected_torrent.get().is_some() fallback=move || view! { <Skeleton class="h-4 w-24" /> }>
|
|
||||||
<p class="text-xs text-muted-foreground uppercase tracking-widest font-semibold flex items-center gap-2">
|
|
||||||
{move || selected_torrent.get().map(|t| format!("{:?}", t.status)).unwrap_or_default()}
|
|
||||||
<span class="bg-primary/20 text-primary px-1.5 py-0.5 rounded text-[10px] lowercase">{move || selected_torrent.get().map(|t| format!("{:.1}%", t.percent_complete)).unwrap_or_default()}</span>
|
|
||||||
</p>
|
|
||||||
</Show>
|
|
||||||
</div>
|
|
||||||
// Custom close button that also resets store.selected_torrent
|
|
||||||
<SheetClose class="rounded-full p-2 hover:bg-muted transition-colors border-none shadow-none cursor-pointer">
|
|
||||||
<icons::X class="size-5 opacity-70" on:click=move |_| store.selected_torrent.set(None) />
|
|
||||||
</SheetClose>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex-1 overflow-hidden p-6">
|
|
||||||
<Tabs default_value="general" class="h-full flex flex-col">
|
|
||||||
<TabsList class="w-full justify-start rounded-none border-b bg-transparent p-0">
|
|
||||||
<TabsTrigger value="general" class="data-[state=active]:bg-transparent data-[state=active]:shadow-none data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none">
|
|
||||||
"Genel"
|
|
||||||
</TabsTrigger>
|
|
||||||
<TabsTrigger value="files" class="data-[state=active]:bg-transparent data-[state=active]:shadow-none data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none">
|
|
||||||
"Dosyalar"
|
|
||||||
</TabsTrigger>
|
|
||||||
<TabsTrigger value="trackers" class="data-[state=active]:bg-transparent data-[state=active]:shadow-none data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none">
|
|
||||||
"İzleyiciler"
|
|
||||||
</TabsTrigger>
|
|
||||||
<TabsTrigger value="peers" class="data-[state=active]:bg-transparent data-[state=active]:shadow-none data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none">
|
|
||||||
"Eşler"
|
|
||||||
</TabsTrigger>
|
|
||||||
</TabsList>
|
|
||||||
|
|
||||||
<div class="flex-1 overflow-y-auto mt-4 pb-12">
|
|
||||||
<TabsContent value="general" class="space-y-6 animate-in fade-in slide-in-from-bottom-2 duration-300">
|
|
||||||
<crate::components::ui::shimmer::Shimmer
|
|
||||||
loading=Signal::derive(move || selected_torrent.get().is_none())
|
|
||||||
shimmer_color="rgba(0,0,0,0.06)"
|
|
||||||
background_color="rgba(0,0,0,0.04)"
|
|
||||||
>
|
|
||||||
{move || {
|
|
||||||
let t = selected_torrent.get().unwrap_or_else(|| shared::Torrent {
|
|
||||||
hash: "----------------------------------------".to_string(),
|
|
||||||
name: "Yükleniyor...".to_string(),
|
|
||||||
size: 0,
|
|
||||||
completed: 0,
|
|
||||||
down_rate: 0,
|
|
||||||
up_rate: 0,
|
|
||||||
eta: 0,
|
|
||||||
percent_complete: 0.0,
|
|
||||||
status: shared::TorrentStatus::Downloading,
|
|
||||||
error_message: "".to_string(),
|
|
||||||
added_date: 0,
|
|
||||||
label: None,
|
|
||||||
});
|
|
||||||
|
|
||||||
view! {
|
|
||||||
<div class="grid grid-cols-2 md:grid-cols-4 gap-6">
|
|
||||||
<InfoItem label="İndirilen / Toplam" value=format!("{} / {}", format_bytes(t.completed), format_bytes(t.size)) />
|
|
||||||
<InfoItem label="İndirme Hızı" value=format_speed(t.down_rate) class="text-blue-500" />
|
|
||||||
<InfoItem label="Gönderme Hızı" value=format_speed(t.up_rate) class="text-green-500" />
|
|
||||||
<InfoItem label="Eklenme Tarihi" value=format_date(t.added_date) />
|
|
||||||
<InfoItem label="Kalan Süre" value=format_duration(t.eta) />
|
|
||||||
<InfoItem label="Hash" value=t.hash class="col-span-2 md:col-span-4 break-all font-mono text-xs" />
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
</crate::components::ui::shimmer::Shimmer>
|
|
||||||
</TabsContent>
|
|
||||||
|
|
||||||
<TabsContent value="files" class="h-full">
|
|
||||||
<div class="flex flex-col items-center justify-center h-48 opacity-60">
|
|
||||||
<icons::File class="size-12 mb-3 text-muted-foreground" />
|
|
||||||
<p class="text-sm font-medium">"Dosya listesi yakında eklenecek"</p>
|
|
||||||
</div>
|
|
||||||
</TabsContent>
|
|
||||||
|
|
||||||
<TabsContent value="trackers" class="h-full">
|
|
||||||
<div class="flex flex-col items-center justify-center h-48 opacity-60">
|
|
||||||
<icons::Settings2 class="size-12 mb-3 text-muted-foreground" />
|
|
||||||
<p class="text-sm font-medium">"İzleyici listesi yakında eklenecek"</p>
|
|
||||||
</div>
|
|
||||||
</TabsContent>
|
|
||||||
|
|
||||||
<TabsContent value="peers" class="h-full">
|
|
||||||
<div class="flex flex-col items-center justify-center h-48 opacity-60">
|
|
||||||
<icons::Users class="size-12 mb-3 text-muted-foreground" />
|
|
||||||
<p class="text-sm font-medium">"Eş listesi yakında eklenecek"</p>
|
|
||||||
</div>
|
|
||||||
</TabsContent>
|
|
||||||
</div>
|
|
||||||
</Tabs>
|
|
||||||
</div>
|
|
||||||
</SheetContent>
|
|
||||||
</Sheet>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
fn InfoItem(
|
|
||||||
label: &'static str,
|
|
||||||
value: String,
|
|
||||||
#[prop(optional)] class: &'static str
|
|
||||||
) -> impl IntoView {
|
|
||||||
view! {
|
|
||||||
<div class=tailwind_fuse::tw_merge!("flex flex-col gap-1", class)>
|
|
||||||
<span class="text-xs font-semibold text-muted-foreground uppercase opacity-80">{label}</span>
|
|
||||||
<span class="text-sm font-medium">{value}</span>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn format_bytes(bytes: i64) -> String {
|
|
||||||
const UNITS: [&str; 6] = ["B", "KB", "MB", "GB", "TB", "PB"];
|
|
||||||
if bytes < 1024 { return format!("{} B", bytes); }
|
|
||||||
let i = (bytes as f64).log2().div_euclid(10.0) as usize;
|
|
||||||
format!("{:.1} {}", (bytes as f64) / 1024_f64.powi(i as i32), UNITS[i])
|
|
||||||
}
|
|
||||||
|
|
||||||
fn format_speed(bytes_per_sec: i64) -> String {
|
|
||||||
if bytes_per_sec == 0 { return "0 B/s".to_string(); }
|
|
||||||
format!("{}/s", format_bytes(bytes_per_sec))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn format_duration(seconds: i64) -> String {
|
|
||||||
if seconds <= 0 { return "∞".to_string(); }
|
|
||||||
let days = seconds / 86400;
|
|
||||||
let hours = (seconds % 86400) / 3600;
|
|
||||||
let minutes = (seconds % 3600) / 60;
|
|
||||||
let secs = seconds % 60;
|
|
||||||
if days > 0 { format!("{}g {}s", days, hours) }
|
|
||||||
else if hours > 0 { format!("{}s {}d", hours, minutes) }
|
|
||||||
else if minutes > 0 { format!("{}d {}sn", minutes, secs) }
|
|
||||||
else { format!("{}sn", secs) }
|
|
||||||
}
|
|
||||||
|
|
||||||
fn format_date(timestamp: i64) -> String {
|
|
||||||
if timestamp <= 0 { return "N/A".to_string(); }
|
|
||||||
let dt = chrono::DateTime::from_timestamp(timestamp, 0);
|
|
||||||
match dt { Some(dt) => dt.format("%d/%m/%Y %H:%M").to_string(), None => "N/A".to_string() }
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,2 @@
|
|||||||
pub mod table;
|
pub mod table;
|
||||||
pub mod add_torrent;
|
pub mod add_torrent;
|
||||||
pub mod details;
|
|
||||||
|
|||||||
@@ -553,8 +553,6 @@ pub fn TorrentTable() -> impl IntoView {
|
|||||||
</div>
|
</div>
|
||||||
<div class="opacity-50">"VibeTorrent v3"</div>
|
<div class="opacity-50">"VibeTorrent v3"</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<crate::components::torrent::details::TorrentDetailsSheet />
|
|
||||||
</div>
|
</div>
|
||||||
}.into_any()
|
}.into_any()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,17 +3,13 @@ use leptos_ui::clx;
|
|||||||
|
|
||||||
mod components {
|
mod components {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
clx! {Card, div, "bg-card text-card-foreground flex flex-col gap-4 rounded-xl border py-6 shadow-sm"}
|
clx! {Card, div, "bg-card text-card-foreground flex flex-col gap-4 rounded-xl border py-6 shadow-sm"}
|
||||||
// TODO. Change data-slot=card-action by data-name="CardAction".
|
clx! {CardHeader, div, "@container/card-header flex flex-col items-start gap-1.5 px-6 [.border-b]:pb-6"}
|
||||||
clx! {CardHeader, div, "@container/card-header flex flex-col items-start gap-1.5 px-6 [.border-b]:pb-6 sm:grid sm:auto-rows-min sm:grid-rows-[auto_auto] has-data-[slot=card-action]:sm:grid-cols-[1fr_auto]"}
|
|
||||||
clx! {CardTitle, h2, "leading-none font-semibold"}
|
clx! {CardTitle, h2, "leading-none font-semibold"}
|
||||||
clx! {CardContent, div, "px-6"}
|
clx! {CardContent, div, "px-6"}
|
||||||
clx! {CardDescription, p, "text-muted-foreground text-sm"}
|
clx! {CardDescription, p, "text-muted-foreground text-sm"}
|
||||||
clx! {CardFooter, footer, "flex items-center px-6 [.border-t]:pt-6", "gap-2"}
|
clx! {CardFooter, footer, "flex items-center px-6 [.border-t]:pt-6", "gap-2"}
|
||||||
|
|
||||||
clx! {CardAction, div, "self-start sm:col-start-2 sm:row-span-2 sm:row-start-1 sm:justify-self-end"}
|
|
||||||
clx! {CardList, ul, "flex flex-col gap-4"}
|
|
||||||
clx! {CardItem, li, "flex items-center [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0"}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub use components::*;
|
pub use components::*;
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ pub fn ContextMenuTrigger(
|
|||||||
class=trigger_class
|
class=trigger_class
|
||||||
data-name="ContextMenuTrigger"
|
data-name="ContextMenuTrigger"
|
||||||
data-context-trigger=ctx.target_id
|
data-context-trigger=ctx.target_id
|
||||||
on:contextmenu=move |e: web_sys::MouseEvent| {
|
on:contextmenu=move |_e: web_sys::MouseEvent| {
|
||||||
if let Some(cb) = on_open {
|
if let Some(cb) = on_open {
|
||||||
cb.run(());
|
cb.run(());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// * Reuse @table.rs
|
// * Reuse @table.rs
|
||||||
pub use crate::components::ui::table::{
|
pub use crate::components::ui::table::{
|
||||||
Table as DataTable, TableBody as DataTableBody, TableCaption as DataTableCaption, TableCell as DataTableCell,
|
Table as DataTable, TableBody as DataTableBody, TableCell as DataTableCell,
|
||||||
TableFooter as DataTableFooter, TableHead as DataTableHead, TableHeader as DataTableHeader,
|
TableHead as DataTableHead, TableHeader as DataTableHeader,
|
||||||
TableRow as DataTableRow, TableWrapper as DataTableWrapper,
|
TableRow as DataTableRow, TableWrapper as DataTableWrapper,
|
||||||
};
|
};
|
||||||
@@ -5,7 +5,7 @@ use leptos_ui::clx;
|
|||||||
use tw_merge::*;
|
use tw_merge::*;
|
||||||
|
|
||||||
use crate::components::hooks::use_random::use_random_id_for;
|
use crate::components::hooks::use_random::use_random_id_for;
|
||||||
pub use crate::components::ui::separator::Separator as DropdownMenuSeparator;
|
// pub use crate::components::ui::separator::Separator as DropdownMenuSeparator;
|
||||||
|
|
||||||
mod components {
|
mod components {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
@@ -17,10 +17,8 @@ pub mod separator;
|
|||||||
pub mod sheet;
|
pub mod sheet;
|
||||||
pub mod sidenav;
|
pub mod sidenav;
|
||||||
pub mod skeleton;
|
pub mod skeleton;
|
||||||
pub mod shimmer;
|
|
||||||
pub mod svg_icon;
|
pub mod svg_icon;
|
||||||
pub mod switch;
|
pub mod switch;
|
||||||
pub mod table;
|
pub mod table;
|
||||||
pub mod tabs;
|
|
||||||
pub mod theme_toggle;
|
pub mod theme_toggle;
|
||||||
pub mod toast;
|
pub mod toast;
|
||||||
@@ -9,7 +9,7 @@ use crate::components::hooks::use_can_scroll_vertical::use_can_scroll_vertical;
|
|||||||
use crate::components::hooks::use_random::use_random_id_for;
|
use crate::components::hooks::use_random::use_random_id_for;
|
||||||
// * Reuse @select.rs
|
// * Reuse @select.rs
|
||||||
pub use crate::components::ui::select::{
|
pub use crate::components::ui::select::{
|
||||||
SelectGroup as MultiSelectGroup, SelectItem as MultiSelectItem, SelectLabel as MultiSelectLabel,
|
SelectGroup as MultiSelectGroup, SelectItem as MultiSelectItem,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Default)]
|
#[derive(Clone, Copy, PartialEq, Eq, Default)]
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ mod components {
|
|||||||
clx! {SheetFooter, footer, "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end"}
|
clx! {SheetFooter, footer, "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end"}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub use components::*;
|
// pub use components::*;
|
||||||
|
|
||||||
/* ========================================================== */
|
/* ========================================================== */
|
||||||
/* ✨ CONTEXT ✨ */
|
/* ✨ CONTEXT ✨ */
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
use leptos::prelude::*;
|
|
||||||
use tw_merge::*;
|
|
||||||
|
|
||||||
use crate::components::hooks::use_random::use_random_id_for;
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn Shimmer(
|
|
||||||
/// Controls shimmer visibility (works with any bool signal)
|
|
||||||
#[prop(into)]
|
|
||||||
loading: Signal<bool>,
|
|
||||||
|
|
||||||
/// Color of the shimmer wave (default: "rgba(255,255,255,0.15)")
|
|
||||||
#[prop(into, optional)]
|
|
||||||
shimmer_color: Option<String>,
|
|
||||||
|
|
||||||
/// Background color of shimmer blocks (default: "rgba(255,255,255,0.08)")
|
|
||||||
#[prop(into, optional)]
|
|
||||||
background_color: Option<String>,
|
|
||||||
|
|
||||||
/// Animation duration in seconds (default: 1.5)
|
|
||||||
#[prop(optional)]
|
|
||||||
duration: Option<f64>,
|
|
||||||
|
|
||||||
/// Fallback border-radius for text elements in px (default: 4)
|
|
||||||
#[prop(optional)]
|
|
||||||
fallback_border_radius: Option<f64>,
|
|
||||||
|
|
||||||
/// Additional classes
|
|
||||||
#[prop(into, optional)]
|
|
||||||
class: String,
|
|
||||||
|
|
||||||
/// Children to wrap
|
|
||||||
children: Children,
|
|
||||||
) -> impl IntoView {
|
|
||||||
let shimmer_id = use_random_id_for("Shimmer");
|
|
||||||
let merged_class = tw_merge!("relative", class);
|
|
||||||
|
|
||||||
view! {
|
|
||||||
<div
|
|
||||||
id=shimmer_id
|
|
||||||
class=merged_class
|
|
||||||
data-name="Shimmer"
|
|
||||||
data-shimmer-loading=move || loading.get().to_string()
|
|
||||||
data-shimmer-color=shimmer_color
|
|
||||||
data-shimmer-bg-color=background_color
|
|
||||||
data-shimmer-duration=duration.map(|d| d.to_string())
|
|
||||||
data-shimmer-fallback-radius=fallback_border_radius.map(|r| r.to_string())
|
|
||||||
>
|
|
||||||
{children()}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -145,7 +145,8 @@ pub fn Sidenav(
|
|||||||
data-name="Sidenav"
|
data-name="Sidenav"
|
||||||
data-sidenav=data_state.to_string()
|
data-sidenav=data_state.to_string()
|
||||||
data-side=data_side.to_string()
|
data-side=data_side.to_string()
|
||||||
class="hidden md:block group peer text-sidenav-foreground data-[state=Collapsed]:hidden"
|
data-collapsible=data_collapsible.to_string()
|
||||||
|
class="hidden md:block group peer text-sidenav-foreground group-data-[collapsible=Offcanvas]:data-[state=Collapsed]:hidden"
|
||||||
>
|
>
|
||||||
// * SidenavGap: This is what handles the sidenav gap on desktop
|
// * SidenavGap: This is what handles the sidenav gap on desktop
|
||||||
<div
|
<div
|
||||||
@@ -155,9 +156,9 @@ pub fn Sidenav(
|
|||||||
"group-data-[collapsible=Offcanvas]:w-0",
|
"group-data-[collapsible=Offcanvas]:w-0",
|
||||||
"group-data-[side=Right]:rotate-180",
|
"group-data-[side=Right]:rotate-180",
|
||||||
match variant {
|
match variant {
|
||||||
SidenavVariant::Sidenav => "group-data-[collapsible=Icon]:w-(--sidenav-width-icon)",
|
SidenavVariant::Sidenav => "group-data-[collapsible=Icon]:group-data-[state=Collapsed]:w-(--sidenav-width-icon)",
|
||||||
SidenavVariant::Floating | SidenavVariant::Inset =>
|
SidenavVariant::Floating | SidenavVariant::Inset =>
|
||||||
"group-data-[collapsible=Icon]:w-[calc(var(--sidenav-width-icon)+(--spacing(4)))]",
|
"group-data-[collapsible=Icon]:group-data-[state=Collapsed]:w-[calc(var(--sidenav-width-icon)+(--spacing(4)))]",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
/>
|
/>
|
||||||
@@ -171,9 +172,9 @@ pub fn Sidenav(
|
|||||||
SidenavSide::Right => "right-0 group-data-[collapsible=Offcanvas]:right-[calc(var(--sidenav-width)*-1)]"
|
SidenavSide::Right => "right-0 group-data-[collapsible=Offcanvas]:right-[calc(var(--sidenav-width)*-1)]"
|
||||||
},
|
},
|
||||||
match variant {
|
match variant {
|
||||||
SidenavVariant::Sidenav => "group-data-[collapsible=Icon]:w-(--sidenav-width-icon) group-data-[side=Left]:border-r group-data-[side=Right]:border-l",
|
SidenavVariant::Sidenav => "group-data-[collapsible=Icon]:group-data-[state=Collapsed]:w-(--sidenav-width-icon) group-data-[side=Left]:border-r group-data-[side=Right]:border-l",
|
||||||
SidenavVariant::Floating | SidenavVariant::Inset =>
|
SidenavVariant::Floating | SidenavVariant::Inset =>
|
||||||
"p-2 group-data-[collapsible=Icon]:w-[calc(var(--sidenav-width-icon)+(--spacing(4))+2px)]",
|
"p-2 group-data-[collapsible=Icon]:group-data-[state=Collapsed]:w-[calc(var(--sidenav-width-icon)+(--spacing(4))+2px)]",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,108 +0,0 @@
|
|||||||
use leptos::context::Provider;
|
|
||||||
use leptos::prelude::*;
|
|
||||||
use tw_merge::tw_merge;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct TabsContext {
|
|
||||||
pub active_tab: RwSignal<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn Tabs(
|
|
||||||
#[prop(into)] default_value: String,
|
|
||||||
children: Children,
|
|
||||||
#[prop(optional, into)] class: String,
|
|
||||||
) -> impl IntoView {
|
|
||||||
let active_tab = RwSignal::new(default_value);
|
|
||||||
let ctx = TabsContext { active_tab };
|
|
||||||
|
|
||||||
let merged_class = tw_merge!("w-full", &class);
|
|
||||||
|
|
||||||
view! {
|
|
||||||
<Provider value=ctx>
|
|
||||||
<div data-name="Tabs" class=merged_class>
|
|
||||||
{children()}
|
|
||||||
</div>
|
|
||||||
</Provider>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn TabsList(
|
|
||||||
children: Children,
|
|
||||||
#[prop(optional, into)] class: String,
|
|
||||||
) -> impl IntoView {
|
|
||||||
let merged_class = tw_merge!(
|
|
||||||
"inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
|
|
||||||
&class
|
|
||||||
);
|
|
||||||
|
|
||||||
view! {
|
|
||||||
<div data-name="TabsList" class=merged_class>
|
|
||||||
{children()}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn TabsTrigger(
|
|
||||||
#[prop(into)] value: String,
|
|
||||||
children: Children,
|
|
||||||
#[prop(optional, into)] class: String,
|
|
||||||
) -> impl IntoView {
|
|
||||||
let ctx = expect_context::<TabsContext>();
|
|
||||||
let v_clone = value.clone();
|
|
||||||
|
|
||||||
let is_active = Memo::new(move |_| ctx.active_tab.get() == v_clone);
|
|
||||||
|
|
||||||
let merged_class = move || tw_merge!(
|
|
||||||
"inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 cursor-pointer select-none",
|
|
||||||
if is_active.get() {
|
|
||||||
"bg-background text-foreground shadow-sm"
|
|
||||||
} else {
|
|
||||||
"hover:bg-background/50 hover:text-foreground"
|
|
||||||
},
|
|
||||||
&class
|
|
||||||
);
|
|
||||||
|
|
||||||
view! {
|
|
||||||
<button
|
|
||||||
data-name="TabsTrigger"
|
|
||||||
type="button"
|
|
||||||
class=merged_class
|
|
||||||
data-state=move || if is_active.get() { "active" } else { "inactive" }
|
|
||||||
on:click=move |_| ctx.active_tab.set(value.clone())
|
|
||||||
>
|
|
||||||
{children()}
|
|
||||||
</button>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn TabsContent(
|
|
||||||
#[prop(into)] value: String,
|
|
||||||
children: Children,
|
|
||||||
#[prop(optional, into)] class: String,
|
|
||||||
) -> impl IntoView {
|
|
||||||
let ctx = expect_context::<TabsContext>();
|
|
||||||
let v_clone = value.clone();
|
|
||||||
|
|
||||||
let is_active = Memo::new(move |_| ctx.active_tab.get() == v_clone);
|
|
||||||
|
|
||||||
let merged_class = move || tw_merge!(
|
|
||||||
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
||||||
if !is_active.get() { "hidden" } else { "" },
|
|
||||||
&class
|
|
||||||
);
|
|
||||||
|
|
||||||
view! {
|
|
||||||
<div
|
|
||||||
data-name="TabsContent"
|
|
||||||
class=merged_class
|
|
||||||
data-state=move || if is_active.get() { "active" } else { "inactive" }
|
|
||||||
tabindex=move || if is_active.get() { "0" } else { "-1" }
|
|
||||||
>
|
|
||||||
{children()}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -105,39 +105,29 @@ pub fn provide_torrent_store() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(data_str) = msg.data().as_string() {
|
if let Some(data_str) = msg.data().as_string() {
|
||||||
match BASE64.decode(&data_str) {
|
if let Ok(bytes) = BASE64.decode(&data_str) {
|
||||||
Ok(bytes) => {
|
if let Ok(event) = rmp_serde::from_slice::<AppEvent>(&bytes) {
|
||||||
match rmp_serde::from_slice::<AppEvent>(&bytes) {
|
match event {
|
||||||
Ok(event) => {
|
AppEvent::FullList(list, _) => {
|
||||||
match event {
|
torrents_for_sse.update(|map| {
|
||||||
AppEvent::FullList(list, _) => {
|
let new_hashes: std::collections::HashSet<String> = list.iter().map(|t| t.hash.clone()).collect();
|
||||||
torrents_for_sse.update(|map| {
|
map.retain(|hash, _| new_hashes.contains(hash));
|
||||||
let new_hashes: std::collections::HashSet<String> = list.iter().map(|t| t.hash.clone()).collect();
|
for new_torrent in list { map.insert(new_torrent.hash.clone(), new_torrent); }
|
||||||
map.retain(|hash, _| new_hashes.contains(hash));
|
});
|
||||||
for new_torrent in list { map.insert(new_torrent.hash.clone(), new_torrent); }
|
}
|
||||||
});
|
AppEvent::Update(patch) => {
|
||||||
}
|
if let Some(hash) = patch.hash.clone() {
|
||||||
AppEvent::Update(patch) => {
|
torrents_for_sse.update(|map| { if let Some(t) = map.get_mut(&hash) { t.apply(patch); } });
|
||||||
if let Some(hash) = patch.hash.clone() {
|
}
|
||||||
torrents_for_sse.update(|map| { if let Some(t) = map.get_mut(&hash) { t.apply(patch); } });
|
}
|
||||||
}
|
AppEvent::Stats(stats) => { global_stats_for_sse.set(stats); }
|
||||||
}
|
AppEvent::Notification(n) => {
|
||||||
AppEvent::Stats(stats) => { global_stats_for_sse.set(stats); }
|
show_toast(n.level.clone(), n.message.clone());
|
||||||
AppEvent::Notification(n) => {
|
if n.message.contains("tamamlandı") || n.level == shared::NotificationLevel::Error {
|
||||||
show_toast(n.level.clone(), n.message.clone());
|
show_browser_notification("VibeTorrent", &n.message);
|
||||||
if n.message.contains("tamamlandı") || n.level == shared::NotificationLevel::Error {
|
|
||||||
show_browser_notification("VibeTorrent", &n.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
Err(e) => {
|
|
||||||
log::error!("[SSE] Failed to deserialize AppEvent: {:?}", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
Err(e) => {
|
|
||||||
log::error!("[SSE] Failed to decode base64: {:?}", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -202,7 +192,7 @@ pub async fn subscribe_to_push_notifications() {
|
|||||||
let key_array = js_sys::Uint8Array::from(&decoded_key[..]);
|
let key_array = js_sys::Uint8Array::from(&decoded_key[..]);
|
||||||
|
|
||||||
// 3. Prepare Options
|
// 3. Prepare Options
|
||||||
let mut options = web_sys::PushSubscriptionOptionsInit::new();
|
let options = web_sys::PushSubscriptionOptionsInit::new();
|
||||||
options.set_user_visible_only(true);
|
options.set_user_visible_only(true);
|
||||||
options.set_application_server_key(&key_array.into());
|
options.set_application_server_key(&key_array.into());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user