Skip to content

Commit

Permalink
Added fill color for progress (#3926)
Browse files Browse the repository at this point in the history
* Added fill color for progress

* updated pyi file
  • Loading branch information
wassafshahzad authored Sep 17, 2024
1 parent 16d3962 commit abb884c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions reflex/components/radix/themes/components/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from reflex.components.component import Component
from reflex.components.core.breakpoints import Responsive
from reflex.style import Style
from reflex.vars.base import Var

from ..base import LiteralAccentColor, RadixThemesComponent
Expand Down Expand Up @@ -38,6 +39,21 @@ class Progress(RadixThemesComponent):
# The duration of the progress bar animation. Once the duration times out, the progress bar will start an indeterminate animation.
duration: Var[str]

# The color of the progress bar fill animation.
fill_color: Var[str]

@staticmethod
def _color_selector(color: str) -> Style:
"""Return a style object with the correct color and css selector.
Args:
color: Color of the fill part.
Returns:
Style: Style object with the correct css selector and color.
"""
return Style({".rt-ProgressIndicator": {"background_color": color}})

@classmethod
def create(cls, *children, **props) -> Component:
"""Create a Progress component.
Expand All @@ -50,6 +66,12 @@ def create(cls, *children, **props) -> Component:
The Progress Component.
"""
props.setdefault("width", "100%")
if "fill_color" in props:
color = props.get("fill_color", "")
style = props.get("style", {})
style = style | cls._color_selector(color)
props["style"] = style

return super().create(*children, **props)


Expand Down
2 changes: 2 additions & 0 deletions reflex/components/radix/themes/components/progress.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class Progress(RadixThemesComponent):
]
] = None,
duration: Optional[Union[Var[str], str]] = None,
fill_color: Optional[Union[Var[str], str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
Expand Down Expand Up @@ -162,6 +163,7 @@ class Progress(RadixThemesComponent):
high_contrast: Whether to render the progress bar with higher contrast color against background
radius: Override theme radius for progress bar: "none" | "small" | "medium" | "large" | "full"
duration: The duration of the progress bar animation. Once the duration times out, the progress bar will start an indeterminate animation.
fill_color: The color of the progress bar fill animation.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
Expand Down

0 comments on commit abb884c

Please sign in to comment.