From b04a7dab84a3f617d713013b09e6ff61a067168d Mon Sep 17 00:00:00 2001 From: Manas Gupta <53006261+Manas1820@users.noreply.github.com> Date: Sat, 13 Jul 2024 01:59:21 +0530 Subject: [PATCH] Update Radial Bar Component (#3662) * add: radial bar properties * add: generate new pyi file * style: fix linting --------- Co-authored-by: coolstorm --- reflex/components/recharts/polar.py | 18 ++++++++++++++++-- reflex/components/recharts/polar.pyi | 23 ++++++++++++++++++++++- reflex/constants/event.py | 2 ++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/reflex/components/recharts/polar.py b/reflex/components/recharts/polar.py index 4588c4bf0..b58b720c7 100644 --- a/reflex/components/recharts/polar.py +++ b/reflex/components/recharts/polar.py @@ -156,10 +156,22 @@ class RadialBar(Recharts): label: Var[Union[bool, Dict[str, Any]]] # If false set, background sector will not be drawn. - background: Var[bool] + background: Var[Union[bool, Dict[str, Any]]] + + # If set false, animation of radial bars will be disabled. By default true in CSR, and false in SSR + is_animation_active: Var[bool] + + # Specifies when the animation should begin, the unit of this option is ms. By default 0 + animation_begin: Var[int] + + # Specifies the duration of animation, the unit of this option is ms. By default 1500 + animation_duration: Var[int] + + # The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. By default 'ease' + animation_easing: Var[LiteralAnimationEasing] # Valid children components - _valid_children: List[str] = ["LabelList"] + _valid_children: List[str] = ["Cell", "LabelList"] def get_event_triggers(self) -> dict[str, Union[Var, Any]]: """Get the event triggers that pass the component's value to the handler. @@ -174,6 +186,8 @@ class RadialBar(Recharts): EventTriggers.ON_MOUSE_OUT: lambda: [], EventTriggers.ON_MOUSE_ENTER: lambda: [], EventTriggers.ON_MOUSE_LEAVE: lambda: [], + EventTriggers.ON_ANIMATION_START: lambda: [], + EventTriggers.ON_ANIMATION_END: lambda: [], } diff --git a/reflex/components/recharts/polar.pyi b/reflex/components/recharts/polar.pyi index 0a7a1b5d3..7cd9e86c1 100644 --- a/reflex/components/recharts/polar.pyi +++ b/reflex/components/recharts/polar.pyi @@ -242,13 +242,30 @@ class RadialBar(Recharts): label: Optional[ Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]] ] = None, - background: Optional[Union[Var[bool], bool]] = None, + background: Optional[ + Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]] + ] = None, + is_animation_active: Optional[Union[Var[bool], bool]] = None, + animation_begin: Optional[Union[Var[int], int]] = None, + animation_duration: Optional[Union[Var[int], int]] = None, + animation_easing: Optional[ + Union[ + Var[Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]], + Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"], + ] + ] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + on_animation_end: Optional[ + Union[EventHandler, EventSpec, list, Callable, BaseVar] + ] = None, + on_animation_start: Optional[ + Union[EventHandler, EventSpec, list, Callable, BaseVar] + ] = None, on_click: Optional[ Union[EventHandler, EventSpec, list, Callable, BaseVar] ] = None, @@ -278,6 +295,10 @@ class RadialBar(Recharts): legend_type: Type of legend label: If false set, labels will not be drawn. background: If false set, background sector will not be drawn. + is_animation_active: If set false, animation of radial bars will be disabled. By default true in CSR, and false in SSR + animation_begin: Specifies when the animation should begin, the unit of this option is ms. By default 0 + animation_duration: Specifies the duration of animation, the unit of this option is ms. By default 1500 + animation_easing: The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. By default 'ease' style: The style of the component. key: A unique key for the component. id: The id for the component. diff --git a/reflex/constants/event.py b/reflex/constants/event.py index 16a2c6a5c..351a1ac52 100644 --- a/reflex/constants/event.py +++ b/reflex/constants/event.py @@ -95,3 +95,5 @@ class EventTriggers(SimpleNamespace): ON_CLEAR_SERVER_ERRORS = "on_clear_server_errors" ON_VALUE_COMMIT = "on_value_commit" ON_SELECT = "on_select" + ON_ANIMATION_START = "on_animation_start" + ON_ANIMATION_END = "on_animation_end"