feat: modified button and avatar properties

This commit is contained in:
luoxiao 2023-11-14 16:53:50 +08:00
parent 365a6686cd
commit 3fd3e1a7ac
2 changed files with 6 additions and 6 deletions

View file

@ -7,7 +7,7 @@ pub use theme::AvatarTheme;
#[component] #[component]
pub fn Avatar( pub fn Avatar(
#[prop(optional, into)] src: MaybeSignal<String>, #[prop(optional, into)] src: MaybeSignal<String>,
#[prop(optional, into)] circle: MaybeSignal<bool>, #[prop(optional, into)] round: MaybeSignal<bool>,
#[prop(default = MaybeSignal::Static(30), into)] size: MaybeSignal<u16>, #[prop(default = MaybeSignal::Static(30), into)] size: MaybeSignal<u16>,
) -> impl IntoView { ) -> impl IntoView {
let theme = use_theme(Theme::light); let theme = use_theme(Theme::light);
@ -16,7 +16,7 @@ pub fn Avatar(
css_vars.push_str(&format!("--thaw-size: {}px;", size.get())); css_vars.push_str(&format!("--thaw-size: {}px;", size.get()));
css_vars.push_str(&format!( css_vars.push_str(&format!(
"--thaw-border-radius: {};", "--thaw-border-radius: {};",
if circle.get() { "50%" } else { "3px" } if round.get() { "50%" } else { "3px" }
)); ));
theme.with(|theme| { theme.with(|theme| {
css_vars.push_str(&format!( css_vars.push_str(&format!(

View file

@ -28,7 +28,7 @@ pub enum ButtonColor {
} }
impl ButtonColor { impl ButtonColor {
pub fn theme_color(&self, theme: &Theme) -> String { fn theme_color(&self, theme: &Theme) -> String {
match self { match self {
ButtonColor::Primary => theme.common.color_primary.clone(), ButtonColor::Primary => theme.common.color_primary.clone(),
ButtonColor::Success => theme.common.color_success.clone(), ButtonColor::Success => theme.common.color_success.clone(),
@ -36,7 +36,7 @@ impl ButtonColor {
ButtonColor::Error => theme.common.color_error.clone(), ButtonColor::Error => theme.common.color_error.clone(),
} }
} }
pub fn theme_color_hover(&self, theme: &Theme) -> String { fn theme_color_hover(&self, theme: &Theme) -> String {
match self { match self {
ButtonColor::Primary => theme.common.color_primary_hover.clone(), ButtonColor::Primary => theme.common.color_primary_hover.clone(),
ButtonColor::Success => theme.common.color_success_hover.clone(), ButtonColor::Success => theme.common.color_success_hover.clone(),
@ -45,7 +45,7 @@ impl ButtonColor {
} }
} }
pub fn theme_color_active(&self, theme: &Theme) -> String { fn theme_color_active(&self, theme: &Theme) -> String {
match self { match self {
ButtonColor::Primary => theme.common.color_primary_active.clone(), ButtonColor::Primary => theme.common.color_primary_active.clone(),
ButtonColor::Success => theme.common.color_success_active.clone(), ButtonColor::Success => theme.common.color_success_active.clone(),
@ -65,7 +65,7 @@ pub fn Button(
#[prop(optional, into)] loading: MaybeSignal<bool>, #[prop(optional, into)] loading: MaybeSignal<bool>,
#[prop(optional, into)] disabled: MaybeSignal<bool>, #[prop(optional, into)] disabled: MaybeSignal<bool>,
#[prop(optional, into)] on_click: Option<Callback<ev::MouseEvent>>, #[prop(optional, into)] on_click: Option<Callback<ev::MouseEvent>>,
#[prop(optional)] children: Option<ChildrenFn>, #[prop(optional)] children: Option<Children>,
) -> impl IntoView { ) -> impl IntoView {
let theme = use_theme(Theme::light); let theme = use_theme(Theme::light);
let css_vars = create_memo(move |_| { let css_vars = create_memo(move |_| {