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

use direction props from radix.Flex #2696

Merged
merged 5 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
28 changes: 24 additions & 4 deletions reflex/components/radix/themes/layout/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,32 @@ def create(
class VStack(Stack):
"""A vertical stack component."""

def _apply_theme(self, theme: Component):
self.style.update({"flex_direction": "column"})
@classmethod
def create(cls, *children, **props) -> Component:
"""Create a new instance of the component.

Args:
*children: The children of the stack.
**props: The properties of the stack.

Returns:
The stack component.
"""
return super().create(*children, direction="column", **props)


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

def _apply_theme(self, theme: Component):
self.style.update({"flex_direction": "row"})
@classmethod
def create(cls, *children, **props) -> Component:
"""Create a new instance of the component.

Args:
*children: The children of the stack.
**props: The properties of the stack.

Returns:
The stack component.
"""
return super().create(*children, direction="row", **props)
36 changes: 28 additions & 8 deletions reflex/components/radix/themes/layout/stack.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,19 @@ class VStack(Stack):
def create( # type: ignore
cls,
*children,
spacing: Optional[LiteralSpacing] = "2",
align: Optional[LiteralAlign] = "start",
as_child: Optional[Union[Var[bool], bool]] = None,
direction: Optional[
Union[
Var[Literal["row", "column", "row-reverse", "column-reverse"]],
Literal["row", "column", "row-reverse", "column-reverse"],
]
] = None,
align: Optional[
Union[
Var[Literal["start", "center", "end", "baseline", "stretch"]],
Literal["start", "center", "end", "baseline", "stretch"],
]
] = None,
justify: Optional[
Union[
Var[Literal["start", "center", "end", "between"]],
Expand All @@ -197,6 +201,12 @@ class VStack(Stack):
Literal["nowrap", "wrap", "wrap-reverse"],
]
] = None,
spacing: Optional[
Union[
Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
] = None,
access_key: Optional[
Union[Var[Union[str, int, bool]], Union[str, int, bool]]
] = None,
Expand Down Expand Up @@ -294,12 +304,12 @@ class VStack(Stack):

Args:
*children: The children of the stack.
spacing: The spacing between each stack item.
align: The alignment of the stack items.
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
direction: How child items are layed out: "row" | "column" | "row-reverse" | "column-reverse"
align: Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch"
justify: Alignment of children along the cross axis: "start" | "center" | "end" | "between"
wrap: Whether children should wrap when they reach the end of their container: "nowrap" | "wrap" | "wrap-reverse"
spacing: Gap between children: "0" - "9"
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.
Expand Down Expand Up @@ -335,15 +345,19 @@ class HStack(Stack):
def create( # type: ignore
cls,
*children,
spacing: Optional[LiteralSpacing] = "2",
align: Optional[LiteralAlign] = "start",
as_child: Optional[Union[Var[bool], bool]] = None,
direction: Optional[
Union[
Var[Literal["row", "column", "row-reverse", "column-reverse"]],
Literal["row", "column", "row-reverse", "column-reverse"],
]
] = None,
align: Optional[
Union[
Var[Literal["start", "center", "end", "baseline", "stretch"]],
Literal["start", "center", "end", "baseline", "stretch"],
]
] = None,
justify: Optional[
Union[
Var[Literal["start", "center", "end", "between"]],
Expand All @@ -356,6 +370,12 @@ class HStack(Stack):
Literal["nowrap", "wrap", "wrap-reverse"],
]
] = None,
spacing: Optional[
Union[
Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
] = None,
access_key: Optional[
Union[Var[Union[str, int, bool]], Union[str, int, bool]]
] = None,
Expand Down Expand Up @@ -453,12 +473,12 @@ class HStack(Stack):

Args:
*children: The children of the stack.
spacing: The spacing between each stack item.
align: The alignment of the stack items.
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
direction: How child items are layed out: "row" | "column" | "row-reverse" | "column-reverse"
align: Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch"
justify: Alignment of children along the cross axis: "start" | "center" | "end" | "between"
wrap: Whether children should wrap when they reach the end of their container: "nowrap" | "wrap" | "wrap-reverse"
spacing: Gap between children: "0" - "9"
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.
Expand Down
Loading