Skip to content

Commit f50b782

Browse files
LendemorYummy-Yums
authored andcommitted
use direction props from radix.Flex (reflex-dev#2696)
* use direction props from radix.Flex * override direction props * test no var * confirm no var * add comment for reflex-web
1 parent 3db878c commit f50b782

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

reflex/components/radix/themes/layout/stack.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
from __future__ import annotations
44

55
from reflex.components.component import Component
6+
from reflex.vars import Var
67

78
from ..base import LiteralAlign, LiteralSpacing
8-
from .flex import Flex
9+
from .flex import Flex, LiteralFlexDirection
910

1011

1112
class Stack(Flex):
@@ -41,12 +42,12 @@ def create(
4142
class VStack(Stack):
4243
"""A vertical stack component."""
4344

44-
def _apply_theme(self, theme: Component):
45-
self.style.update({"flex_direction": "column"})
45+
# The direction of the stack.
46+
direction: Var[LiteralFlexDirection] = "column" # type: ignore
4647

4748

4849
class HStack(Stack):
4950
"""A horizontal stack component."""
5051

51-
def _apply_theme(self, theme: Component):
52-
self.style.update({"flex_direction": "row"})
52+
# The direction of the stack.
53+
direction: Var[LiteralFlexDirection] = "row" # type: ignore

reflex/components/radix/themes/layout/stack.pyi

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ from reflex.vars import Var, BaseVar, ComputedVar
88
from reflex.event import EventChain, EventHandler, EventSpec
99
from reflex.style import Style
1010
from reflex.components.component import Component
11+
from reflex.vars import Var
1112
from ..base import LiteralAlign, LiteralSpacing
12-
from .flex import Flex
13+
from .flex import Flex, LiteralFlexDirection
1314

1415
class Stack(Flex):
1516
@overload
@@ -178,13 +179,13 @@ class VStack(Stack):
178179
*children,
179180
spacing: Optional[LiteralSpacing] = "2",
180181
align: Optional[LiteralAlign] = "start",
181-
as_child: Optional[Union[Var[bool], bool]] = None,
182182
direction: Optional[
183183
Union[
184184
Var[Literal["row", "column", "row-reverse", "column-reverse"]],
185185
Literal["row", "column", "row-reverse", "column-reverse"],
186186
]
187187
] = None,
188+
as_child: Optional[Union[Var[bool], bool]] = None,
188189
justify: Optional[
189190
Union[
190191
Var[Literal["start", "center", "end", "between"]],
@@ -296,8 +297,8 @@ class VStack(Stack):
296297
*children: The children of the stack.
297298
spacing: The spacing between each stack item.
298299
align: The alignment of the stack items.
299-
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
300300
direction: How child items are layed out: "row" | "column" | "row-reverse" | "column-reverse"
301+
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
301302
justify: Alignment of children along the cross axis: "start" | "center" | "end" | "between"
302303
wrap: Whether children should wrap when they reach the end of their container: "nowrap" | "wrap" | "wrap-reverse"
303304
access_key: Provides a hint for generating a keyboard shortcut for the current element.
@@ -337,13 +338,13 @@ class HStack(Stack):
337338
*children,
338339
spacing: Optional[LiteralSpacing] = "2",
339340
align: Optional[LiteralAlign] = "start",
340-
as_child: Optional[Union[Var[bool], bool]] = None,
341341
direction: Optional[
342342
Union[
343343
Var[Literal["row", "column", "row-reverse", "column-reverse"]],
344344
Literal["row", "column", "row-reverse", "column-reverse"],
345345
]
346346
] = None,
347+
as_child: Optional[Union[Var[bool], bool]] = None,
347348
justify: Optional[
348349
Union[
349350
Var[Literal["start", "center", "end", "between"]],
@@ -455,8 +456,8 @@ class HStack(Stack):
455456
*children: The children of the stack.
456457
spacing: The spacing between each stack item.
457458
align: The alignment of the stack items.
458-
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
459459
direction: How child items are layed out: "row" | "column" | "row-reverse" | "column-reverse"
460+
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
460461
justify: Alignment of children along the cross axis: "start" | "center" | "end" | "between"
461462
wrap: Whether children should wrap when they reach the end of their container: "nowrap" | "wrap" | "wrap-reverse"
462463
access_key: Provides a hint for generating a keyboard shortcut for the current element.

0 commit comments

Comments
 (0)