diff --git a/src/alert/alert.css b/src/alert/alert.css index 98e82ff..5dbcfc9 100644 --- a/src/alert/alert.css +++ b/src/alert/alert.css @@ -4,18 +4,24 @@ background-color: var(--background-color); border: 1px solid var(--border-color); border-radius: 3px; + line-height: 1.6; } .melt-alert__icon { position: absolute; top: 12px; - left: 8px; + left: 10px; + font-size: 24px; + color: var(--icon-color); } .melt-alert__header { font-size: 16px; + line-height: 19px; + font-weight: 500; } -.melt-alert__header + .alert-body__content { +.melt-alert__header + .melt-alert__content { margin-top: 8px; + font-size: 14px; } diff --git a/src/alert/mod.rs b/src/alert/mod.rs index 052648c..d00bbfc 100644 --- a/src/alert/mod.rs +++ b/src/alert/mod.rs @@ -1,6 +1,9 @@ +mod theme; + use crate::{theme::use_theme, utils::mount_style::mount_style, Icon, Theme}; use icondata::AiIcon; use leptos::*; +pub use theme::AlertTheme; #[derive(Clone)] pub enum AlertVariant { @@ -10,13 +13,27 @@ pub enum AlertVariant { } impl AlertVariant { - pub fn theme_border_color(&self, theme: &Theme) -> String { + pub fn theme_icon_color(&self, theme: &Theme) -> String { match self { AlertVariant::SUCCESS => theme.common.color_success.clone(), AlertVariant::WARNING => theme.common.color_warning.clone(), AlertVariant::ERROR => theme.common.color_error.clone(), } } + pub fn theme_background_color(&self, theme: &Theme) -> String { + match self { + AlertVariant::SUCCESS => theme.alert.success_background_color.clone(), + AlertVariant::WARNING => theme.alert.warning_background_color.clone(), + AlertVariant::ERROR => theme.alert.error_background_color.clone(), + } + } + pub fn theme_border_color(&self, theme: &Theme) -> String { + match self { + AlertVariant::SUCCESS => theme.alert.success_border_color.clone(), + AlertVariant::WARNING => theme.alert.warning_border_color.clone(), + AlertVariant::ERROR => theme.alert.error_border_color.clone(), + } + } } #[component] @@ -36,9 +53,18 @@ pub fn Alert( theme.with(|theme| { let variant = variant.get(); - let border_color = variant.theme_border_color(&theme); - css_vars.push_str(&format!("--background-color: {border_color}aa;")); - css_vars.push_str(&format!("--border-color: {border_color};")); + css_vars.push_str(&format!( + "--icon-color: {};", + variant.theme_icon_color(&theme) + )); + css_vars.push_str(&format!( + "--background-color: {};", + variant.theme_background_color(&theme) + )); + css_vars.push_str(&format!( + "--border-color: {};", + variant.theme_border_color(&theme) + )); }); css_vars @@ -70,7 +96,7 @@ pub fn Alert( } } } -