diff --git a/examples/basic/src/demo_button.rs b/examples/basic/src/demo_button.rs index c69c16a..10fd25f 100644 --- a/examples/basic/src/demo_button.rs +++ b/examples/basic/src/demo_button.rs @@ -14,6 +14,9 @@ pub fn DemoButton(cx: Scope) -> impl IntoView { + diff --git a/src/button/button.css b/src/button/button.css index be9dee3..249bdd4 100644 --- a/src/button/button.css +++ b/src/button/button.css @@ -13,10 +13,16 @@ border-color: var(--border-color-hover); } -.melt-button--text { +.melt-button--text, +.melt-button--link { border: none; } .melt-button--text:hover { color: var(--font-color-hover); + background-color: #f2f2f2; +} + +.melt-button--link:hover { + color: var(--font-color-hover); } \ No newline at end of file diff --git a/src/button/mod.rs b/src/button/mod.rs index e954182..5cb90ef 100644 --- a/src/button/mod.rs +++ b/src/button/mod.rs @@ -4,12 +4,13 @@ use leptos::*; use stylers::style_sheet_str; pub use theme::ButtonTheme; -#[derive(Default, PartialEq, Clone)] +#[derive(Default, PartialEq, Clone, Copy)] pub enum ButtonType { #[default] PRIMARY, SOLID, TEXT, + LINK, } #[derive(Default, Clone)] @@ -40,33 +41,30 @@ pub fn Button( children: Children, ) -> impl IntoView { let theme = use_theme(cx, Theme::light); - let css_vars; - { - let type_ = type_.clone().get(); - css_vars = create_memo(cx, move |_| { - let mut css_vars = String::new(); - let theme = theme.get(); - let bg_color = color.get().theme_color(&theme); - if type_ == ButtonType::PRIMARY { - css_vars.push_str(&format!("--background-color: {bg_color};")); - css_vars.push_str(&format!("--font-color: #fff;")); - css_vars.push_str(&format!("--border-color: {bg_color};")); - css_vars.push_str(&format!("--border-color-hover: {bg_color};")); - } else { - css_vars.push_str(&format!("--font-color-hover: {bg_color};")); - css_vars.push_str(&format!("--border-color: #555a;")); - css_vars.push_str(&format!("--border-color-hover: #555;")); - } + let css_vars = create_memo(cx, move |_| { + let mut css_vars = String::new(); + let theme = theme.get(); + let bg_color = color.get().theme_color(&theme); + if type_.get() == ButtonType::PRIMARY { + css_vars.push_str(&format!("--background-color: {bg_color};")); + css_vars.push_str(&format!("--font-color: #fff;")); + css_vars.push_str(&format!("--border-color: {bg_color};")); + css_vars.push_str(&format!("--border-color-hover: {bg_color};")); + } else { + css_vars.push_str(&format!("--font-color-hover: {bg_color};")); + css_vars.push_str(&format!("--border-color: #555a;")); + css_vars.push_str(&format!("--border-color-hover: #555;")); + } - css_vars - }); - } + css_vars + }); let class_name = mount_style("button", || style_sheet_str!("./src/button/button.css")); view! {cx, class=class_name,