Skip to content

Commit 87142cd

Browse files
committed
fix(leptos): some little issues on leptos
1 parent 84f121d commit 87142cd

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

crates/leptos/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ edition = "2024"
66
[dependencies]
77
leptos = { version = "0.8.2", default-features = false }
88
components-core = { package = "rustlanges-components-core", version = "0.1.0", path = "../core" }
9-
tailwind_fuse = { version = "0.3", features = ["variant", "tailwind_fuse_macro"] }
9+
tailwind_fuse = { version = "0.3", features = [
10+
"variant",
11+
"tailwind_fuse_macro",
12+
] }

crates/leptos/src/button.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,30 @@
11
use components_core::{BASE_CLASS, concat};
22
use leptos::prelude::*;
3-
use tailwind_fuse::{AsTailwindClass, TwVariant};
43

5-
#[derive(TwVariant, PartialEq)]
4+
#[derive(Default, Debug, PartialEq)]
65
pub enum Variant {
7-
#[tw(default, class = "rustlanges-button--primary")]
6+
#[default]
87
Primary,
9-
#[tw(class = "rustlanges-button--secondary")]
108
Secondary,
11-
#[tw(class = "rustlanges-button--text")]
129
Text,
13-
#[tw(class = "rustlanges-button--icon")]
1410
Icon,
1511
}
1612

17-
#[component]
13+
#[component(transparent)]
1814
pub fn Button(
1915
#[prop(into, optional)] variant: Variant,
2016
#[prop(into, optional)] label: String,
2117
#[prop(into, optional)] class: String,
22-
#[prop(into)] icon: Option<Children>,
18+
attrs: Vec<(&'static str, Attribute)>,
19+
icon: View<impl IntoView + Send + Sync>,
2320
) -> impl IntoView {
24-
let class = crate::tw!(
25-
variant,
26-
concat!("text-button ", BASE_CLASS, "-button"),
27-
class
28-
);
21+
let var = format!("{}{variant:?}", concat!(BASE_CLASS, "-button", "--"));
22+
let class = crate::tw!("text-button", var, concat!(BASE_CLASS, "-button"), class);
2923

3024
view! {
31-
<button class={class}>
25+
<button class={class} {..attrs}>
3226
{(variant != Variant::Icon).then_some(label)}
33-
{(variant == Variant::Icon).then(|| icon.map(|icon| icon())).flatten()}
27+
{(variant == Variant::Icon).then(|| icon.into_view())}
3428
</button>
3529
}
3630
}

crates/leptos/src/card.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use leptos::prelude::*;
33

44
#[component]
55
pub fn Card(
6-
#[prop(into)] child: Children,
6+
children: Children,
77
#[prop(into, optional)] class: String,
88
#[prop(into, optional, default = false)] clickable: bool,
99
#[prop(into, optional, default = false)] disabled: bool,
@@ -17,7 +17,7 @@ pub fn Card(
1717

1818
view! {
1919
<div class={class}>
20-
{child()}
20+
{children()}
2121
</div>
2222
}
2323
}

crates/leptos/src/input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn Input(
2828
{icon.map(|icon| view! { <span class={concat!(BASE_CLASS, "-input__icon")}>{icon()}</span> })}
2929
<input
3030
class={concat!(BASE_CLASS, "-input__inner")}
31-
disabled=disabled
31+
disabled=disabled.get()
3232
/>
3333
</div>
3434
{has_error.get().then_some(

0 commit comments

Comments
 (0)