Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix radix radio cards component #3545

Merged
merged 4 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions reflex/components/radix/themes/components/radio_cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from types import SimpleNamespace
from typing import Literal, Union

from reflex.event import EventHandler
from reflex.vars import Var

from ..base import LiteralAccentColor, RadixThemesComponent
Expand All @@ -13,6 +14,9 @@ class RadioCardsRoot(RadixThemesComponent):

tag = "RadioCards.Root"

# Change the default rendered element for the one passed as a child, merging their props and behavior.
as_child: Var[bool]

# The size of the checkbox cards: "1" | "2" | "3"
size: Var[Literal["1", "2", "3"]]

Expand All @@ -31,12 +35,51 @@ class RadioCardsRoot(RadixThemesComponent):
# The gap between the checkbox cards:
gap: Var[Union[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]]]

default_value: Var[str]

# The controlled value of the radio item to check. Should be used in conjunction with onValueChange.
value: Var[str]

# The name of the group. Submitted with its owning form as part of a name/value pair.
name: Var[str]

# When true, prevents the user from interacting with radio items.
disabled: Var[bool]

# When true, indicates that the user must check a radio item before the owning form can be submitted.
required: Var[bool]

# The orientation of the component.
orientation: Var[Literal["horizontal", "vertical", "undefined"]]

# The reading direction of the radio group. If omitted,
# inherits globally from DirectionProvider or assumes LTR (left-to-right) reading mode.
dir: Var[Literal["ltr", "rtl"]]

# When true, keyboard navigation will loop from last item to first, and vice versa.
loop: Var[bool]

# Event handler called when the value changes.
on_value_change: EventHandler[lambda e0: [e0]]


class RadioCardsItem(RadixThemesComponent):
"""Item element for RadioCards component."""

tag = "RadioCards.Item"

# Change the default rendered element for the one passed as a child, merging their props and behavior.
as_child: Var[bool]

# The value given as data when submitted with a name.
value: Var[str]

# When true, prevents the user from interacting with the radio item.
disabled: Var[bool]

# When true, indicates that the user must check the radio item before the owning form can be submitted.
required: Var[bool]


class RadioCards(SimpleNamespace):
"""RadioCards components namespace."""
Expand Down
34 changes: 34 additions & 0 deletions reflex/components/radix/themes/components/radio_cards.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ from reflex.event import EventChain, EventHandler, EventSpec
from reflex.style import Style
from types import SimpleNamespace
from typing import Literal, Union
from reflex.event import EventHandler
from reflex.vars import Var
from ..base import LiteralAccentColor, RadixThemesComponent

Expand All @@ -18,6 +19,7 @@ class RadioCardsRoot(RadixThemesComponent):
def create( # type: ignore
cls,
*children,
as_child: Optional[Union[Var[bool], bool]] = None,
size: Optional[
Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]]
] = None,
Expand Down Expand Up @@ -99,6 +101,19 @@ class RadioCardsRoot(RadixThemesComponent):
Union[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]],
]
] = None,
default_value: Optional[Union[Var[str], str]] = None,
value: Optional[Union[Var[str], str]] = None,
name: Optional[Union[Var[str], str]] = None,
disabled: Optional[Union[Var[bool], bool]] = None,
required: Optional[Union[Var[bool], bool]] = None,
orientation: Optional[
Union[
Var[Literal["horizontal", "vertical", "undefined"]],
Literal["horizontal", "vertical", "undefined"],
]
] = None,
dir: Optional[Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]] = None,
loop: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
Expand Down Expand Up @@ -150,6 +165,9 @@ class RadioCardsRoot(RadixThemesComponent):
on_unmount: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_value_change: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
**props
) -> "RadioCardsRoot":
"""Create a new component instance.
Expand All @@ -159,12 +177,20 @@ class RadioCardsRoot(RadixThemesComponent):

Args:
*children: Child components.
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
size: The size of the checkbox cards: "1" | "2" | "3"
variant: Variant of button: "classic" | "surface" | "soft"
color_scheme: Override theme color for button
high_contrast: Uses a higher contrast color for the component.
columns: The number of columns:
gap: The gap between the checkbox cards:
value: The controlled value of the radio item to check. Should be used in conjunction with onValueChange.
name: The name of the group. Submitted with its owning form as part of a name/value pair.
disabled: When true, prevents the user from interacting with radio items.
required: When true, indicates that the user must check a radio item before the owning form can be submitted.
orientation: The orientation of the component.
dir: The reading direction of the radio group. If omitted, inherits globally from DirectionProvider or assumes LTR (left-to-right) reading mode.
loop: When true, keyboard navigation will loop from last item to first, and vice versa.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
Expand All @@ -184,6 +210,10 @@ class RadioCardsItem(RadixThemesComponent):
def create( # type: ignore
cls,
*children,
as_child: Optional[Union[Var[bool], bool]] = None,
value: Optional[Union[Var[str], str]] = None,
disabled: Optional[Union[Var[bool], bool]] = None,
required: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
Expand Down Expand Up @@ -244,6 +274,10 @@ class RadioCardsItem(RadixThemesComponent):

Args:
*children: Child components.
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
value: The value given as data when submitted with a name.
disabled: When true, prevents the user from interacting with the radio item.
required: When true, indicates that the user must check the radio item before the owning form can be submitted.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
Expand Down
Loading