diff --git a/frontend/src/components/context_menu.rs b/frontend/src/components/context_menu.rs index 3e07341..c38457e 100644 --- a/frontend/src/components/context_menu.rs +++ b/frontend/src/components/context_menu.rs @@ -10,26 +10,33 @@ pub fn TorrentContextMenu( on_action: Callback<(String, String)>, ) -> impl IntoView { let hash = torrent_hash.clone(); + let on_action_stored = StoredValue::new(on_action); + let on_click = move |action: &str| { - on_action.run((action.to_string(), hash.clone())); + on_action_stored.get_value().run((action.to_string(), hash.clone())); }; + let start_click = { let on_click = on_click.clone(); move |_| on_click("start") }; + let stop_click = { let on_click = on_click.clone(); move |_| on_click("stop") }; + let delete_click = { let on_click = on_click.clone(); move |_| on_click("delete") }; + let delete_data_click = { let on_click = on_click.clone(); move |_| on_click("delete_with_data") }; + view! { {children()} - + "Başlat" - + "Durdur" - + "Sil" - + "Verilerle Birlikte Sil" diff --git a/frontend/src/components/ui/select.rs b/frontend/src/components/ui/select.rs index 206c990..273d996 100644 --- a/frontend/src/components/ui/select.rs +++ b/frontend/src/components/ui/select.rs @@ -1,9 +1,7 @@ -use icons::{ChevronDown, ChevronUp}; -use leptos::context::Provider; use leptos::prelude::*; -use tw_merge::*; -use crate::components::hooks::use_can_scroll_vertical::use_can_scroll_vertical; -use crate::components::hooks::use_random::use_random_id_for; + +#[component] pub fn SelectGroup(children: Children) -> impl IntoView { view! {
{children()}
} } +#[component] pub fn SelectItem(children: Children) -> impl IntoView { view! {
{children()}
} } #[derive(Clone, Copy, PartialEq, Eq, Default, Debug)] #[allow(dead_code)] @@ -11,55 +9,26 @@ pub enum SelectPosition { #[default] Below, Above } #[component] pub fn SelectValue(#[prop(optional, into)] placeholder: String) -> impl IntoView { - let _ = placeholder; - view! { "Select..." } + view! { {placeholder} } } #[component] -pub fn SelectOption( - children: Children, - #[prop(optional, into)] class: String, - #[prop(default = false.into(), into)] aria_selected: Signal, - #[prop(optional, into)] value: Option, -) -> impl IntoView { - let _ = (class, aria_selected, value); +pub fn SelectOption(children: Children, #[prop(optional, into)] value: Option) -> impl IntoView { + let _ = value; view! {
{children()}
} } -#[derive(Clone)] -struct SelectContext {} - #[component] -pub fn Select( - children: Children, - #[prop(optional, into)] class: String, - #[prop(optional, into)] default_value: Option, - #[prop(optional)] on_change: Option>>, -) -> impl IntoView { - let _ = (class, default_value, on_change); - view! { {children()} } +pub fn Select(children: Children) -> impl IntoView { + view! {
{children()}
} } #[component] -pub fn SelectTrigger(children: Children, #[prop(optional, into)] class: String, #[prop(optional, into)] id: String) -> impl IntoView { - let _ = (class, id); +pub fn SelectTrigger(children: Children) -> impl IntoView { view! { } } #[component] -pub fn SelectContent( - children: Children, - #[prop(optional, into)] class: String, - #[prop(default = SelectPosition::default())] position: SelectPosition, - #[prop(optional)] on_close: Option>, -) -> impl IntoView { - let _ = (class, position, on_close); - let (on_scroll, can_scroll_up, can_scroll_down) = use_can_scroll_vertical(); - view! { -
-
- {children()} -
-
- } +pub fn SelectContent(children: Children) -> impl IntoView { + view! {
{children()}
} } diff --git a/frontend/src/components/ui/separator.rs b/frontend/src/components/ui/separator.rs index 6d86960..ae044a0 100644 --- a/frontend/src/components/ui/separator.rs +++ b/frontend/src/components/ui/separator.rs @@ -2,7 +2,6 @@ use leptos::prelude::*; use tailwind_fuse::tw_merge; #[derive(Clone, Copy, PartialEq, Eq, Default, Debug)] -#[allow(dead_code)] pub enum SeparatorOrientation { #[default] Horizontal, Vertical } #[component] @@ -10,13 +9,13 @@ pub fn Separator( #[prop(into, optional)] orientation: Signal, #[prop(into, optional)] class: String, ) -> impl IntoView { - let class = tw_merge!( + let class_signal = move || tw_merge!( "shrink-0 bg-border", - move || match orientation.get() { + match orientation.get() { SeparatorOrientation::Horizontal => "h-[1px] w-full", SeparatorOrientation::Vertical => "h-full w-[1px]", }, - class + class.clone() ); - view! {
} + view! {
} } diff --git a/frontend/src/components/ui/sidenav.rs b/frontend/src/components/ui/sidenav.rs index 723cc1d..deb3127 100644 --- a/frontend/src/components/ui/sidenav.rs +++ b/frontend/src/components/ui/sidenav.rs @@ -1,24 +1,15 @@ use leptos::prelude::*; use tw_merge::tw_merge; -use crate::components::hooks::use_random::use_random_id_for; -#[derive(Clone, Copy, strum::AsRefStr, strum::Display)] +#[derive(Clone, Copy, PartialEq, Eq, Default)] #[allow(dead_code)] -pub enum SidenavSide { Left, Right } - -#[derive(Clone, Copy, strum::AsRefStr, strum::Display)] -#[allow(dead_code)] -pub enum SidenavCollapsible { Off, Icon } +pub enum SidenavState { #[default] Expanded, Collapsed } #[derive(Clone)] pub struct SidenavContext { pub state: RwSignal, } -#[derive(Clone, Copy, PartialEq, Eq, Default)] -#[allow(dead_code)] -pub enum SidenavState { #[default] Expanded, Collapsed } - #[component] pub fn SidenavWrapper(children: Children, #[prop(optional, into)] class: String) -> impl IntoView { let state = RwSignal::new(SidenavState::Expanded); @@ -30,15 +21,15 @@ pub fn SidenavWrapper(children: Children, #[prop(optional, into)] class: String) #[component] pub fn Sidenav(children: Children, #[prop(optional, into)] class: String) -> impl IntoView { let ctx = expect_context::(); - let class = tw_merge!( + let class_signal = move || tw_merge!( "hidden md:flex flex-col border-r bg-card transition-all duration-300", - move || match ctx.state.get() { + match ctx.state.get() { SidenavState::Expanded => "w-[var(--sidenav-width)]", SidenavState::Collapsed => "w-[var(--sidenav-width-icon)]", }, - class + class.clone() ); - view! { } + view! { } } #[component] @@ -47,19 +38,32 @@ pub fn SidenavInset(children: Children, #[prop(optional, into)] class: String) - view! {
{children()}
} } -#[component] -pub fn SidenavLink(children: Children, #[prop(into)] href: String, #[prop(optional, into)] class: String) -> impl IntoView { - let _ = (href, class); - view! {
{children()}
} -} +#[component] pub fn SidenavHeader(children: Children) -> impl IntoView { view! {
{children()}
} } +#[component] pub fn SidenavContent(children: Children) -> impl IntoView { view! {
{children()}
} } +#[component] pub fn SidenavFooter(children: Children) -> impl IntoView { view! {
{children()}
} } +#[component] pub fn SidenavGroup(children: Children) -> impl IntoView { view! {
{children()}
} } +#[component] pub fn SidenavGroupLabel(children: Children) -> impl IntoView { view! {
{children()}
} } +#[component] pub fn SidenavGroupContent(children: Children) -> impl IntoView { view! {
{children()}
} } +#[component] pub fn SidenavMenu(children: Children) -> impl IntoView { view! { } } +#[component] pub fn SidenavMenuItem(children: Children) -> impl IntoView { view! {
{children()}
} } + +#[derive(Clone, Copy, PartialEq, Eq, Default)] +pub enum SidenavMenuButtonVariant { #[default] Default, Outline } #[component] -pub fn SidenavTrigger(children: Children) -> impl IntoView { - let _ = children; - let ctx = expect_context::(); - view! { - - } +pub fn SidenavMenuButton( + children: Children, + #[prop(into, optional)] variant: Signal, + #[prop(into, optional)] class: String, +) -> impl IntoView { + let class_signal = move || tw_merge!( + "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground", + if variant.get() == SidenavMenuButtonVariant::Outline { "border border-input bg-background shadow-xs" } else { "" }, + class.clone() + ); + view! { } +} + +#[component] pub fn SidenavLink(children: Children, #[prop(into)] href: String) -> impl IntoView { + view! { {children()} } }