mirror of
https://github.com/adoyle0/thaw.git
synced 2025-02-02 08:34:15 -05:00
✨ feat: button add round
This commit is contained in:
parent
51bae90332
commit
60a1f589f5
3 changed files with 24 additions and 3 deletions
|
@ -32,6 +32,8 @@ pub fn DemoButton(cx: Scope) -> impl IntoView {
|
||||||
<Button color=ButtonColor::ERROR icon=leptos_icons::AiIcon::AiCloseOutlined>
|
<Button color=ButtonColor::ERROR icon=leptos_icons::AiIcon::AiCloseOutlined>
|
||||||
"ERROR Color Icon"
|
"ERROR Color Icon"
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button color=ButtonColor::ERROR icon=leptos_icons::AiIcon::AiCloseOutlined round=true>
|
||||||
|
</Button>
|
||||||
</Space>
|
</Space>
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -31,3 +31,8 @@
|
||||||
.melt-button--link:hover {
|
.melt-button--link:hover {
|
||||||
color: var(--font-color-hover);
|
color: var(--font-color-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.melt-button--round {
|
||||||
|
padding: 0 10px;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
|
@ -39,8 +39,9 @@ pub fn Button(
|
||||||
cx: Scope,
|
cx: Scope,
|
||||||
#[prop(optional, into)] type_: MaybeSignal<ButtonType>,
|
#[prop(optional, into)] type_: MaybeSignal<ButtonType>,
|
||||||
#[prop(optional, into)] color: MaybeSignal<ButtonColor>,
|
#[prop(optional, into)] color: MaybeSignal<ButtonColor>,
|
||||||
|
#[prop(optional, into)] round: MaybeSignal<bool>,
|
||||||
#[prop(optional, into)] icon: Option<leptos_icons::Icon>,
|
#[prop(optional, into)] icon: Option<leptos_icons::Icon>,
|
||||||
children: Children,
|
#[prop(optional)] children: Option<Children>,
|
||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
let theme = use_theme(cx, Theme::light);
|
let theme = use_theme(cx, Theme::light);
|
||||||
let css_vars = create_memo(cx, move |_| {
|
let css_vars = create_memo(cx, move |_| {
|
||||||
|
@ -62,23 +63,36 @@ pub fn Button(
|
||||||
});
|
});
|
||||||
let class_name = mount_style("button", || style_sheet_str!("./src/button/button.css"));
|
let class_name = mount_style("button", || style_sheet_str!("./src/button/button.css"));
|
||||||
|
|
||||||
|
let icon_style= if children.is_some() {
|
||||||
|
"margin-right: 6px"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
};
|
||||||
|
|
||||||
view! {cx, class=class_name,
|
view! {cx, class=class_name,
|
||||||
<button
|
<button
|
||||||
class:melt-button=true
|
class:melt-button=true
|
||||||
class=("melt-button--text", move || type_.get() == ButtonType::TEXT)
|
class=("melt-button--text", move || type_.get() == ButtonType::TEXT)
|
||||||
class=("melt-button--link", move || type_.get() == ButtonType::LINK)
|
class=("melt-button--link", move || type_.get() == ButtonType::LINK)
|
||||||
|
class=("melt-button--round", move || round.get())
|
||||||
style=move || css_vars.get()
|
style=move || css_vars.get()
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
if let Some(icon) = icon {
|
if let Some(icon) = icon {
|
||||||
view!{cx,
|
view!{cx,
|
||||||
<LeptosIcon icon=icon style="margin-right: 6px"/>
|
<LeptosIcon icon=icon style=icon_style/>
|
||||||
}.into()
|
}.into()
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{children(cx)}
|
{
|
||||||
|
if let Some(children) = children {
|
||||||
|
children(cx).into()
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue