feat: The variant property of the progress component is changed to color

This commit is contained in:
luoxiao 2023-11-16 09:06:24 +08:00
parent ff71eb7929
commit d13928e97d
2 changed files with 14 additions and 14 deletions

View file

@ -14,9 +14,9 @@ pub fn ProgressPage() -> impl IntoView {
<Progress percentage show_indicator=false/>
<Progress percentage />
<Progress percentage indicator_placement=ProgressIndicatorPlacement::Inside/>
<Progress percentage variant=ProgressVariant::Success/>
<Progress percentage variant=ProgressVariant::Warning/>
<Progress percentage variant=ProgressVariant::Error/>
<Progress percentage color=ProgressColor::Success/>
<Progress percentage color=ProgressColor::Warning/>
<Progress percentage color=ProgressColor::Error/>
<Space>
<Button on_click=move |_| percentage.update(|v| *v -= 10.0)>
"-10%"
@ -37,9 +37,9 @@ pub fn ProgressPage() -> impl IntoView {
<Progress percentage show_indicator=false/>
<Progress percentage />
<Progress percentage indicator_placement=ProgressIndicatorPlacement::Inside/>
<Progress percentage variant=ProgressVariant::Success/>
<Progress percentage variant=ProgressVariant::Warning/>
<Progress percentage variant=ProgressVariant::Error/>
<Progress percentage color=ProgressColor::Success/>
<Progress percentage color=ProgressColor::Warning/>
<Progress percentage color=ProgressColor::Error/>
<Space>
<Button on_click=move |_| percentage.update(|v| *v -= 10.0)>
"-10%"
@ -76,10 +76,10 @@ pub fn ProgressPage() -> impl IntoView {
<td>"Percentage value."</td>
</tr>
<tr>
<td>"variant"</td>
<td>"MaybeSignal<ProgressVariant>"</td>
<td>"ProgressVariant::Primary"</td>
<td>"Progress variant."</td>
<td>"color"</td>
<td>"MaybeSignal<ProgressColor>"</td>
<td>"ProgressColor::Primary"</td>
<td>"Progress color."</td>
</tr>
<tr>
<td>"show_indicator"</td>

View file

@ -23,7 +23,7 @@ impl ProgressIndicatorPlacement {
}
#[derive(Default, Clone)]
pub enum ProgressVariant {
pub enum ProgressColor {
#[default]
Primary,
Success,
@ -31,7 +31,7 @@ pub enum ProgressVariant {
Error,
}
impl ProgressVariant {
impl ProgressColor {
fn theme_background_color(&self, theme: &Theme) -> String {
match self {
Self::Primary => theme.common.color_primary.clone(),
@ -45,7 +45,7 @@ impl ProgressVariant {
#[component]
pub fn Progress(
#[prop(into, optional)] percentage: MaybeSignal<f32>,
#[prop(into, optional)] variant: MaybeSignal<ProgressVariant>,
#[prop(into, optional)] color: MaybeSignal<ProgressColor>,
#[prop(into, default = MaybeSignal::Static(true))] show_indicator: MaybeSignal<bool>,
#[prop(into, optional)] indicator_placement: MaybeSignal<ProgressIndicatorPlacement>,
) -> impl IntoView {
@ -60,7 +60,7 @@ pub fn Progress(
));
css_vars.push_str(&format!(
"--thaw-inner-background-color: {};",
variant.get().theme_background_color(theme)
color.get().theme_background_color(theme)
));
});
css_vars