From a53af0048000b313025da9038edefd5ead387c8f Mon Sep 17 00:00:00 2001 From: Martin Xu <15661672+martinxu9@users.noreply.github.com> Date: Thu, 11 Jan 2024 11:26:43 -0800 Subject: [PATCH] Clean up Radix Avatar components props (#2375) * clean up some props for some radix components * pyi --- reflex/components/radix/themes/components/avatar.py | 10 +++++++--- reflex/components/radix/themes/components/avatar.pyi | 8 +++++--- reflex/components/radix/themes/components/badge.py | 12 +++++------- reflex/components/radix/themes/components/badge.pyi | 10 ++++------ reflex/components/radix/themes/components/dialog.py | 2 +- reflex/components/radix/themes/components/dialog.pyi | 2 +- .../components/radix/themes/components/iconbutton.py | 2 +- .../radix/themes/components/iconbutton.pyi | 2 +- 8 files changed, 25 insertions(+), 23 deletions(-) diff --git a/reflex/components/radix/themes/components/avatar.py b/reflex/components/radix/themes/components/avatar.py index 4d4b265b2..f2f154433 100644 --- a/reflex/components/radix/themes/components/avatar.py +++ b/reflex/components/radix/themes/components/avatar.py @@ -11,8 +11,6 @@ from ..base import ( RadixThemesComponent, ) -LiteralSwitchSize = Literal["1", "2", "3", "4"] - class Avatar(CommonMarginProps, RadixThemesComponent): """A toggle switch alternative to the checkbox.""" @@ -22,7 +20,7 @@ class Avatar(CommonMarginProps, RadixThemesComponent): # The variant of the avatar variant: Var[Literal["solid", "soft"]] - # The size of the avatar + # The size of the avatar: "1" - "9" size: Var[LiteralSize] # Color theme of the avatar @@ -33,3 +31,9 @@ class Avatar(CommonMarginProps, RadixThemesComponent): # Override theme radius for avatar: "none" | "small" | "medium" | "large" | "full" radius: Var[LiteralRadius] + + # The src of the avatar image + src: Var[str] + + # The rendered fallback text + fallback: Var[str] diff --git a/reflex/components/radix/themes/components/avatar.pyi b/reflex/components/radix/themes/components/avatar.pyi index 3212f30cb..d91c6954c 100644 --- a/reflex/components/radix/themes/components/avatar.pyi +++ b/reflex/components/radix/themes/components/avatar.pyi @@ -17,8 +17,6 @@ from ..base import ( RadixThemesComponent, ) -LiteralSwitchSize = Literal["1", "2", "3", "4"] - class Avatar(CommonMarginProps, RadixThemesComponent): @overload @classmethod @@ -104,6 +102,8 @@ class Avatar(CommonMarginProps, RadixThemesComponent): Literal["none", "small", "medium", "large", "full"], ] ] = None, + src: Optional[Union[Var[str], str]] = None, + fallback: Optional[Union[Var[str], str]] = None, m: Optional[ Union[ Var[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], @@ -209,9 +209,11 @@ class Avatar(CommonMarginProps, RadixThemesComponent): color: map to CSS default color property. color_scheme: map to radix color property. variant: The variant of the avatar - size: The size of the avatar + size: The size of the avatar: "1" - "9" high_contrast: Whether to render the avatar with higher contrast color against background radius: Override theme radius for avatar: "none" | "small" | "medium" | "large" | "full" + src: The src of the avatar image + fallback: The rendered fallback text m: Margin: "0" - "9" mx: Margin horizontal: "0" - "9" my: Margin vertical: "0" - "9" diff --git a/reflex/components/radix/themes/components/badge.py b/reflex/components/radix/themes/components/badge.py index a390c6142..46abff91d 100644 --- a/reflex/components/radix/themes/components/badge.py +++ b/reflex/components/radix/themes/components/badge.py @@ -11,25 +11,23 @@ from ..base import ( RadixThemesComponent, ) -LiteralSwitchSize = Literal["1", "2", "3", "4"] - class Badge(el.Span, CommonMarginProps, RadixThemesComponent): """A toggle switch alternative to the checkbox.""" tag = "Badge" - # The variant of the avatar + # The variant of the badge variant: Var[Literal["solid", "soft", "surface", "outline"]] - # The size of the avatar + # The size of the badge size: Var[Literal["1", "2"]] - # Color theme of the avatar + # Color theme of the badge color: Var[LiteralAccentColor] - # Whether to render the avatar with higher contrast color against background + # Whether to render the badge with higher contrast color against background high_contrast: Var[bool] - # Override theme radius for avatar: "none" | "small" | "medium" | "large" | "full" + # Override theme radius for badge: "none" | "small" | "medium" | "large" | "full" radius: Var[LiteralRadius] diff --git a/reflex/components/radix/themes/components/badge.pyi b/reflex/components/radix/themes/components/badge.pyi index 9f7353523..be6da716b 100644 --- a/reflex/components/radix/themes/components/badge.pyi +++ b/reflex/components/radix/themes/components/badge.pyi @@ -17,8 +17,6 @@ from ..base import ( RadixThemesComponent, ) -LiteralSwitchSize = Literal["1", "2", "3", "4"] - class Badge(el.Span, CommonMarginProps, RadixThemesComponent): @overload @classmethod @@ -249,10 +247,10 @@ class Badge(el.Span, CommonMarginProps, RadixThemesComponent): *children: Child components. color: map to CSS default color property. color_scheme: map to radix color property. - variant: The variant of the avatar - size: The size of the avatar - high_contrast: Whether to render the avatar with higher contrast color against background - radius: Override theme radius for avatar: "none" | "small" | "medium" | "large" | "full" + variant: The variant of the badge + size: The size of the badge + high_contrast: Whether to render the badge with higher contrast color against background + radius: Override theme radius for badge: "none" | "small" | "medium" | "large" | "full" access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. diff --git a/reflex/components/radix/themes/components/dialog.py b/reflex/components/radix/themes/components/dialog.py index fd33463f7..14e494497 100644 --- a/reflex/components/radix/themes/components/dialog.py +++ b/reflex/components/radix/themes/components/dialog.py @@ -50,7 +50,7 @@ class DialogContent(el.Div, CommonMarginProps, RadixThemesComponent): tag = "Dialog.Content" - # Button size "1" - "4" + # DialogContent size "1" - "4" size: Var[Literal[1, 2, 3, 4]] def get_event_triggers(self) -> Dict[str, Any]: diff --git a/reflex/components/radix/themes/components/dialog.pyi b/reflex/components/radix/themes/components/dialog.pyi index 930eec19e..4b3ee6d66 100644 --- a/reflex/components/radix/themes/components/dialog.pyi +++ b/reflex/components/radix/themes/components/dialog.pyi @@ -832,7 +832,7 @@ class DialogContent(el.Div, CommonMarginProps, RadixThemesComponent): *children: Child components. color: map to CSS default color property. color_scheme: map to radix color property. - size: Button size "1" - "4" + size: DialogContent size "1" - "4" access_key: Provides a hint for generating a keyboard shortcut for the current element. auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user. content_editable: Indicates whether the element's content is editable. diff --git a/reflex/components/radix/themes/components/iconbutton.py b/reflex/components/radix/themes/components/iconbutton.py index 3a9e958f4..1f7954a16 100644 --- a/reflex/components/radix/themes/components/iconbutton.py +++ b/reflex/components/radix/themes/components/iconbutton.py @@ -26,7 +26,7 @@ class IconButton(el.Button, CommonMarginProps, RadixThemesComponent): # Button size "1" - "4" size: Var[LiteralButtonSize] - # Variant of button: "solid" | "soft" | "outline" | "ghost" + # Variant of button: "classic" | "solid" | "soft" | "surface" | "outline" | "ghost" variant: Var[LiteralVariant] # Override theme color for button diff --git a/reflex/components/radix/themes/components/iconbutton.pyi b/reflex/components/radix/themes/components/iconbutton.pyi index 9e7fe409b..0a48d6a8a 100644 --- a/reflex/components/radix/themes/components/iconbutton.pyi +++ b/reflex/components/radix/themes/components/iconbutton.pyi @@ -282,7 +282,7 @@ class IconButton(el.Button, CommonMarginProps, RadixThemesComponent): color_scheme: map to radix color property. as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. size: Button size "1" - "4" - variant: Variant of button: "solid" | "soft" | "outline" | "ghost" + variant: Variant of button: "classic" | "solid" | "soft" | "surface" | "outline" | "ghost" high_contrast: Whether to render the button with higher contrast color against background radius: Override theme radius for button: "none" | "small" | "medium" | "large" | "full" auto_focus: Automatically focuses the button when the page loads