mirror of
https://github.com/adoyle0/thaw.git
synced 2025-01-22 22:09:22 -05:00
✨ feat: button add icon
This commit is contained in:
parent
b71aab36b4
commit
51bae90332
4 changed files with 21 additions and 1 deletions
|
@ -8,3 +8,4 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
leptos = { version = "0.2.5", features = ["stable"] }
|
leptos = { version = "0.2.5", features = ["stable"] }
|
||||||
melt-ui = { path = "../../" }
|
melt-ui = { path = "../../" }
|
||||||
|
leptos-icons = { git = "https://github.com/Carlosted/leptos-icons.git", features = ["AiCloseOutlined", "AiCheckOutlined"] }
|
|
@ -29,6 +29,9 @@ pub fn DemoButton(cx: Scope) -> impl IntoView {
|
||||||
<Button color=ButtonColor::ERROR>
|
<Button color=ButtonColor::ERROR>
|
||||||
"ERROR Color"
|
"ERROR Color"
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button color=ButtonColor::ERROR icon=leptos_icons::AiIcon::AiCloseOutlined>
|
||||||
|
"ERROR Color Icon"
|
||||||
|
</Button>
|
||||||
</Space>
|
</Space>
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,6 +6,11 @@
|
||||||
border: 1px solid var(--border-color);
|
border: 1px solid var(--border-color);
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.melt-button:hover {
|
.melt-button:hover {
|
||||||
|
@ -25,4 +30,4 @@
|
||||||
|
|
||||||
.melt-button--link:hover {
|
.melt-button--link:hover {
|
||||||
color: var(--font-color-hover);
|
color: var(--font-color-hover);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
mod theme;
|
mod theme;
|
||||||
use crate::{theme::*, utils::mount_style::mount_style};
|
use crate::{theme::*, utils::mount_style::mount_style};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
|
use leptos_icons::*;
|
||||||
use stylers::style_sheet_str;
|
use stylers::style_sheet_str;
|
||||||
pub use theme::ButtonTheme;
|
pub use theme::ButtonTheme;
|
||||||
|
|
||||||
|
@ -38,6 +39,7 @@ 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)] icon: Option<leptos_icons::Icon>,
|
||||||
children: Children,
|
children: Children,
|
||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
let theme = use_theme(cx, Theme::light);
|
let theme = use_theme(cx, Theme::light);
|
||||||
|
@ -67,6 +69,15 @@ pub fn Button(
|
||||||
class=("melt-button--link", move || type_.get() == ButtonType::LINK)
|
class=("melt-button--link", move || type_.get() == ButtonType::LINK)
|
||||||
style=move || css_vars.get()
|
style=move || css_vars.get()
|
||||||
>
|
>
|
||||||
|
{
|
||||||
|
if let Some(icon) = icon {
|
||||||
|
view!{cx,
|
||||||
|
<LeptosIcon icon=icon style="margin-right: 6px"/>
|
||||||
|
}.into()
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
{children(cx)}
|
{children(cx)}
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue