Fix rx.progress to support max
prop (#2601)
This commit is contained in:
parent
5e9b472d1b
commit
fccb73ee70
@ -55,6 +55,9 @@ class ProgressIndicator(ProgressComponent):
|
|||||||
# The current progress value.
|
# The current progress value.
|
||||||
value: Var[Optional[int]]
|
value: Var[Optional[int]]
|
||||||
|
|
||||||
|
# The maximum progress value.
|
||||||
|
max: Var[Optional[int]]
|
||||||
|
|
||||||
def _apply_theme(self, theme: Component):
|
def _apply_theme(self, theme: Component):
|
||||||
self.style = Style(
|
self.style = Style(
|
||||||
{
|
{
|
||||||
@ -65,7 +68,7 @@ class ProgressIndicator(ProgressComponent):
|
|||||||
"&[data_state='loading']": {
|
"&[data_state='loading']": {
|
||||||
"transition": f"transform {DEFAULT_ANIMATION_DURATION}ms linear",
|
"transition": f"transform {DEFAULT_ANIMATION_DURATION}ms linear",
|
||||||
},
|
},
|
||||||
"transform": f"translateX(calc(-100% + {self.value}%))", # type: ignore
|
"transform": f"translateX(calc(-100% + ({self.value} / {self.max} * 100%)))", # type: ignore
|
||||||
"boxShadow": "inset 0 0 0 1px var(--gray-a5)",
|
"boxShadow": "inset 0 0 0 1px var(--gray-a5)",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -92,7 +95,9 @@ class Progress(SimpleNamespace):
|
|||||||
style.update({"width": width})
|
style.update({"width": width})
|
||||||
|
|
||||||
return ProgressRoot.create(
|
return ProgressRoot.create(
|
||||||
ProgressIndicator.create(value=props.get("value")),
|
ProgressIndicator.create(
|
||||||
|
value=props.get("value"), max=props.get("max", 100)
|
||||||
|
),
|
||||||
**props,
|
**props,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -188,6 +188,7 @@ class ProgressIndicator(ProgressComponent):
|
|||||||
cls,
|
cls,
|
||||||
*children,
|
*children,
|
||||||
value: Optional[Union[Var[Optional[int]], Optional[int]]] = None,
|
value: Optional[Union[Var[Optional[int]], Optional[int]]] = None,
|
||||||
|
max: Optional[Union[Var[Optional[int]], Optional[int]]] = None,
|
||||||
as_child: Optional[Union[Var[bool], bool]] = None,
|
as_child: Optional[Union[Var[bool], bool]] = None,
|
||||||
style: Optional[Style] = None,
|
style: Optional[Style] = None,
|
||||||
key: Optional[Any] = None,
|
key: Optional[Any] = None,
|
||||||
@ -247,6 +248,7 @@ class ProgressIndicator(ProgressComponent):
|
|||||||
Args:
|
Args:
|
||||||
*children: The children of the component.
|
*children: The children of the component.
|
||||||
value: The current progress value.
|
value: The current progress value.
|
||||||
|
max: The maximum progress value.
|
||||||
as_child: Change the default rendered element for the one passed as a child.
|
as_child: Change the default rendered element for the one passed as a child.
|
||||||
style: The style of the component.
|
style: The style of the component.
|
||||||
key: A unique key for the component.
|
key: A unique key for the component.
|
||||||
|
Loading…
Reference in New Issue
Block a user