Skip to content

Commit ac36bfc

Browse files
authored
Radix 3.0 (reflex-dev#3159)
1 parent ebb0e79 commit ac36bfc

40 files changed

Lines changed: 2631 additions & 590 deletions

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def index():
123123
rx.button("Generate Image", on_click=State.get_image, width="25em"),
124124
rx.cond(
125125
State.processing,
126-
rx.chakra.circular_progress(is_indeterminate=True),
126+
rx.spinner(),
127127
rx.cond(
128128
State.complete,
129129
rx.image(src=State.image_url, width="20em"),

‎integration/test_navigation.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from reflex.testing import AppHarness
99

10-
from .utils import poll_for_navigation
10+
from .utils import SessionStorage, poll_for_navigation
1111

1212

1313
def NavigationApp():
@@ -66,6 +66,10 @@ async def test_navigation_app(navigation_app: AppHarness):
6666
assert navigation_app.app_instance is not None, "app is not running"
6767
driver = navigation_app.frontend()
6868

69+
ss = SessionStorage(driver)
70+
token = AppHarness._poll_for(lambda: ss.get("token") is not None)
71+
assert token is not None
72+
6973
internal_link = driver.find_element(By.ID, "internal")
7074

7175
with poll_for_navigation(driver):

‎reflex/.templates/web/utils/state.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,8 @@ export const getRefValue = (ref) => {
691691
if (ref.current.type == "checkbox") {
692692
return ref.current.checked; // chakra
693693
} else if (
694-
ref.current.className?.includes("rt-CheckboxButton") ||
695-
ref.current.className?.includes("rt-SwitchButton")
694+
ref.current.className?.includes("rt-CheckboxRoot") ||
695+
ref.current.className?.includes("rt-SwitchRoot")
696696
) {
697697
return ref.current.ariaChecked == "true"; // radix
698698
} else if (ref.current.className?.includes("rt-SliderRoot")) {

‎reflex/__init__.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"select",
8282
"slider",
8383
"spacer",
84+
"spinner",
8485
"stack",
8586
"switch",
8687
"table",

‎reflex/__init__.pyi‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ from reflex.components import section as section
6969
from reflex.components import select as select
7070
from reflex.components import slider as slider
7171
from reflex.components import spacer as spacer
72+
from reflex.components import spinner as spinner
7273
from reflex.components import stack as stack
7374
from reflex.components import switch as switch
7475
from reflex.components import table as table

‎reflex/components/radix/primitives/form.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from reflex.components.component import Component, ComponentNamespace
88
from reflex.components.el.elements.forms import Form as HTMLForm
9-
from reflex.components.radix.themes.components.text_field import TextFieldInput
9+
from reflex.components.radix.themes.components.text_field import TextFieldRoot
1010
from reflex.constants.event import EventTriggers
1111
from reflex.vars import Var
1212

@@ -108,9 +108,9 @@ def create(cls, *children, **props):
108108
f"FormControl can only have at most one child, got {len(children)} children"
109109
)
110110
for child in children:
111-
if not isinstance(child, TextFieldInput):
111+
if not isinstance(child, TextFieldRoot):
112112
raise TypeError(
113-
"Only Radix TextFieldInput is allowed as child of FormControl"
113+
"Only Radix TextFieldRoot is allowed as child of FormControl"
114114
)
115115
return super().create(*children, **props)
116116

‎reflex/components/radix/primitives/form.pyi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ from reflex.style import Style
1010
from typing import Any, Dict, Literal
1111
from reflex.components.component import Component, ComponentNamespace
1212
from reflex.components.el.elements.forms import Form as HTMLForm
13-
from reflex.components.radix.themes.components.text_field import TextFieldInput
13+
from reflex.components.radix.themes.components.text_field import TextFieldRoot
1414
from reflex.constants.event import EventTriggers
1515
from reflex.vars import Var
1616
from .base import RadixPrimitiveComponentWithClassName

‎reflex/components/radix/themes/base.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,17 @@ class CommonMarginProps(Component):
7373
ml: Var[LiteralSpacing]
7474

7575

76+
class RadixLoadingProp(Component):
77+
"""Base class for components that can be in a loading state."""
78+
79+
# If set, show an rx.spinner instead of the component children.
80+
loading: Var[bool]
81+
82+
7683
class RadixThemesComponent(Component):
7784
"""Base class for all @radix-ui/themes components."""
7885

79-
library = "@radix-ui/themes@^2.0.0"
86+
library = "@radix-ui/themes@^3.0.0"
8087

8188
# "Fake" prop color_scheme is used to avoid shadowing CSS prop "color".
8289
_rename_props: Dict[str, str] = {"colorScheme": "color"}

‎reflex/components/radix/themes/base.pyi‎

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,84 @@ class CommonMarginProps(Component):
176176
"""
177177
...
178178

179+
class RadixLoadingProp(Component):
180+
@overload
181+
@classmethod
182+
def create( # type: ignore
183+
cls,
184+
*children,
185+
loading: Optional[Union[Var[bool], bool]] = None,
186+
style: Optional[Style] = None,
187+
key: Optional[Any] = None,
188+
id: Optional[Any] = None,
189+
class_name: Optional[Any] = None,
190+
autofocus: Optional[bool] = None,
191+
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
192+
on_blur: Optional[
193+
Union[EventHandler, EventSpec, list, function, BaseVar]
194+
] = None,
195+
on_click: Optional[
196+
Union[EventHandler, EventSpec, list, function, BaseVar]
197+
] = None,
198+
on_context_menu: Optional[
199+
Union[EventHandler, EventSpec, list, function, BaseVar]
200+
] = None,
201+
on_double_click: Optional[
202+
Union[EventHandler, EventSpec, list, function, BaseVar]
203+
] = None,
204+
on_focus: Optional[
205+
Union[EventHandler, EventSpec, list, function, BaseVar]
206+
] = None,
207+
on_mount: Optional[
208+
Union[EventHandler, EventSpec, list, function, BaseVar]
209+
] = None,
210+
on_mouse_down: Optional[
211+
Union[EventHandler, EventSpec, list, function, BaseVar]
212+
] = None,
213+
on_mouse_enter: Optional[
214+
Union[EventHandler, EventSpec, list, function, BaseVar]
215+
] = None,
216+
on_mouse_leave: Optional[
217+
Union[EventHandler, EventSpec, list, function, BaseVar]
218+
] = None,
219+
on_mouse_move: Optional[
220+
Union[EventHandler, EventSpec, list, function, BaseVar]
221+
] = None,
222+
on_mouse_out: Optional[
223+
Union[EventHandler, EventSpec, list, function, BaseVar]
224+
] = None,
225+
on_mouse_over: Optional[
226+
Union[EventHandler, EventSpec, list, function, BaseVar]
227+
] = None,
228+
on_mouse_up: Optional[
229+
Union[EventHandler, EventSpec, list, function, BaseVar]
230+
] = None,
231+
on_scroll: Optional[
232+
Union[EventHandler, EventSpec, list, function, BaseVar]
233+
] = None,
234+
on_unmount: Optional[
235+
Union[EventHandler, EventSpec, list, function, BaseVar]
236+
] = None,
237+
**props
238+
) -> "RadixLoadingProp":
239+
"""Create the component.
240+
241+
Args:
242+
*children: The children of the component.
243+
loading: If set, show an rx.spinner instead of the component children.
244+
style: The style of the component.
245+
key: A unique key for the component.
246+
id: The id for the component.
247+
class_name: The class name for the component.
248+
autofocus: Whether the component should take the focus once the page is loaded
249+
custom_attrs: custom attribute
250+
**props: The props of the component.
251+
252+
Returns:
253+
The component.
254+
"""
255+
...
256+
179257
class RadixThemesComponent(Component):
180258
@overload
181259
@classmethod

‎reflex/components/radix/themes/color_mode.pyi‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ class ColorModeButton(Button):
417417
title: Optional[
418418
Union[Var[Union[str, int, bool]], Union[str, int, bool]]
419419
] = None,
420+
loading: Optional[Union[Var[bool], bool]] = None,
420421
style: Optional[Style] = None,
421422
key: Optional[Any] = None,
422423
id: Optional[Any] = None,
@@ -507,6 +508,7 @@ class ColorModeButton(Button):
507508
spell_check: Defines whether the element may be checked for spelling errors.
508509
tab_index: Defines the position of the current element in the tabbing order.
509510
title: Defines a tooltip for the element.
511+
loading: If set, show an rx.spinner instead of the component children.
510512
style: The style of the component.
511513
key: A unique key for the component.
512514
id: The id for the component.

0 commit comments

Comments
 (0)