add other files
This commit is contained in:
parent
d0fd3bd9f2
commit
1294ffaa94
@ -165,16 +165,18 @@ class ConnectionToaster(Toaster):
|
||||
class ConnectionBanner(Component):
|
||||
"""A connection banner component."""
|
||||
|
||||
@classmethod
|
||||
def create(cls, comp: Optional[Component] = None) -> Component:
|
||||
"""Create a connection banner component.
|
||||
# The component to render when there's a server connection error.
|
||||
comp: Var[Optional[Component]] = None
|
||||
|
||||
Args:
|
||||
comp: The component to render when there's a server connection error.
|
||||
@classmethod
|
||||
def create(cls, **props) -> Component:
|
||||
"""Create a connection banner component.
|
||||
|
||||
Returns:
|
||||
The connection banner component.
|
||||
"""
|
||||
comp = props.pop("comp", None)
|
||||
|
||||
if not comp:
|
||||
comp = Flex.create(
|
||||
Text.create(
|
||||
@ -195,16 +197,18 @@ class ConnectionBanner(Component):
|
||||
class ConnectionModal(Component):
|
||||
"""A connection status modal window."""
|
||||
|
||||
@classmethod
|
||||
def create(cls, comp: Optional[Component] = None) -> Component:
|
||||
"""Create a connection banner component.
|
||||
# The component to render when there's a server connection error.
|
||||
comp: Var[Optional[Component]] = None
|
||||
|
||||
Args:
|
||||
comp: The component to render when there's a server connection error.
|
||||
@classmethod
|
||||
def create(cls, **props) -> Component:
|
||||
"""Create a connection banner component.
|
||||
|
||||
Returns:
|
||||
The connection banner component.
|
||||
"""
|
||||
comp = props.pop("comp", None)
|
||||
|
||||
if not comp:
|
||||
comp = Text.create(*default_connection_error())
|
||||
return cond(
|
||||
|
@ -193,6 +193,12 @@ class AccordionItem(AccordionComponent):
|
||||
# When true, prevents the user from interacting with the item.
|
||||
disabled: Var[bool]
|
||||
|
||||
# The header of the accordion item.
|
||||
header: Var[Optional[Component | Var]] = None
|
||||
|
||||
# The content of the accordion item.
|
||||
content: Var[Optional[Component | Var]] = None
|
||||
|
||||
_valid_children: List[str] = [
|
||||
"AccordionHeader",
|
||||
"AccordionTrigger",
|
||||
@ -205,21 +211,20 @@ class AccordionItem(AccordionComponent):
|
||||
def create(
|
||||
cls,
|
||||
*children,
|
||||
header: Optional[Component | Var] = None,
|
||||
content: Optional[Component | Var] = None,
|
||||
**props,
|
||||
) -> Component:
|
||||
"""Create an accordion item.
|
||||
|
||||
Args:
|
||||
*children: The list of children to use if header and content are not provided.
|
||||
header: The header of the accordion item.
|
||||
content: The content of the accordion item.
|
||||
**props: Additional properties to apply to the accordion item.
|
||||
|
||||
Returns:
|
||||
The accordion item.
|
||||
"""
|
||||
header = props.pop("header", None)
|
||||
content = props.pop("content", None)
|
||||
|
||||
# The item requires a value to toggle (use a random unique name if not provided).
|
||||
value = props.pop("value", get_uuid_string_var())
|
||||
|
||||
|
@ -17,7 +17,7 @@ rx.text(
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Dict, List, Literal, get_args
|
||||
from typing import Dict, List, Literal, get_args, Optional
|
||||
|
||||
from reflex.components.component import BaseComponent
|
||||
from reflex.components.core.cond import Cond, color_mode_cond, cond
|
||||
@ -96,23 +96,28 @@ def _set_static_default(props, position, prop, default):
|
||||
class ColorModeIconButton(IconButton):
|
||||
"""Icon Button for toggling light / dark mode via toggle_color_mode."""
|
||||
|
||||
# The position of the icon button. Follow document flow if None.
|
||||
position: Var[Optional[LiteralPosition]] = None
|
||||
|
||||
# Allow picking the "system" value for the color mode.
|
||||
allow_system: Var[bool] = False
|
||||
|
||||
@classmethod
|
||||
def create(
|
||||
cls,
|
||||
position: LiteralPosition | None = None,
|
||||
allow_system: bool = False,
|
||||
**props,
|
||||
):
|
||||
"""Create a icon button component that calls toggle_color_mode on click.
|
||||
|
||||
Args:
|
||||
position: The position of the icon button. Follow document flow if None.
|
||||
allow_system: Allow picking the "system" value for the color mode.
|
||||
**props: The props to pass to the component.
|
||||
|
||||
Returns:
|
||||
The button component.
|
||||
"""
|
||||
position = props.pop("position", None)
|
||||
allow_system = props.pop("allow_system", None)
|
||||
|
||||
# position is used to set nice defaults for positioning the icon button
|
||||
if isinstance(position, Var):
|
||||
_set_var_default(props, position, "position", "fixed", position)
|
||||
|
@ -180,16 +180,17 @@ class HighLevelSelect(SelectRoot):
|
||||
position: Var[Literal["item-aligned", "popper"]]
|
||||
|
||||
@classmethod
|
||||
def create(cls, items: Union[List[str], Var[List[str]]], **props) -> Component:
|
||||
def create(cls, **props) -> Component:
|
||||
"""Create a select component.
|
||||
|
||||
Args:
|
||||
items: The items of the select.
|
||||
**props: Additional properties to apply to the select component.
|
||||
|
||||
Returns:
|
||||
The select component.
|
||||
"""
|
||||
items = props.pop("items")
|
||||
|
||||
trigger_prop_list = [
|
||||
"placeholder",
|
||||
"variant",
|
||||
|
@ -61,6 +61,9 @@ class Slider(RadixThemesComponent):
|
||||
# The name of the slider. Submitted with its owning form as part of a name/value pair.
|
||||
name: Var[str]
|
||||
|
||||
# The width of the slider.
|
||||
width: Var[Optional[str]] = "100%"
|
||||
|
||||
# The minimum value of the slider.
|
||||
min: Var[Union[float, int]]
|
||||
|
||||
@ -89,20 +92,19 @@ class Slider(RadixThemesComponent):
|
||||
def create(
|
||||
cls,
|
||||
*children,
|
||||
width: Optional[str] = "100%",
|
||||
**props,
|
||||
) -> Component:
|
||||
"""Create a Slider component.
|
||||
|
||||
Args:
|
||||
*children: The children of the component.
|
||||
width: The width of the slider.
|
||||
**props: The properties of the component.
|
||||
|
||||
Returns:
|
||||
The component.
|
||||
"""
|
||||
default_value = props.pop("default_value", [50])
|
||||
width = props.pop("width", "100%")
|
||||
|
||||
if isinstance(default_value, Var):
|
||||
if issubclass(default_value._var_type, (int, float)):
|
||||
|
@ -12,20 +12,22 @@ from .flex import Flex, LiteralFlexDirection
|
||||
class Stack(Flex):
|
||||
"""A stack component."""
|
||||
|
||||
# The spacing between each stack item.
|
||||
spacing: LiteralSpacing = "3"
|
||||
|
||||
# The alignment of the stack items.
|
||||
align: LiteralAlign = "start"
|
||||
|
||||
@classmethod
|
||||
def create(
|
||||
cls,
|
||||
*children,
|
||||
spacing: LiteralSpacing = "3",
|
||||
align: LiteralAlign = "start",
|
||||
**props,
|
||||
) -> Component:
|
||||
"""Create a new instance of the component.
|
||||
|
||||
Args:
|
||||
*children: The children of the stack.
|
||||
spacing: The spacing between each stack item.
|
||||
align: The alignment of the stack items.
|
||||
**props: The properties of the stack.
|
||||
|
||||
Returns:
|
||||
@ -39,8 +41,6 @@ class Stack(Flex):
|
||||
|
||||
return super().create(
|
||||
*children,
|
||||
spacing=spacing,
|
||||
align=align,
|
||||
**props,
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user