Skip to content

Commit

Permalink
remove references to Cond (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
adhami3310 authored Jan 18, 2025
1 parent 9691b12 commit 5ef9729
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 84 deletions.
1 change: 0 additions & 1 deletion reflex_chakra/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
code = Code.create
collapse = Collapse.create
color_mode_button = ColorModeButton.create
color_mode_icon = ColorModeIcon.create
color_mode_switch = ColorModeSwitch.create
component = Component.create
container = Container.create
Expand Down
2 changes: 1 addition & 1 deletion reflex_chakra/components/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .checkbox import Checkbox, CheckboxGroup
from .colormodeswitch import (
ColorModeButton,
ColorModeIcon,
color_mode_icon,
ColorModeScript,
ColorModeSwitch,
)
Expand Down
37 changes: 16 additions & 21 deletions reflex_chakra/components/forms/colormodeswitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from reflex_chakra.components import ChakraComponent
from reflex_chakra.components.media.icon import Icon
from reflex.components.component import BaseComponent
from reflex.components.core.cond import Cond, color_mode_cond
from reflex.components.core.cond import color_mode_cond
from reflex.style import LIGHT_COLOR_MODE, color_mode, toggle_color_mode

from .button import Button
Expand All @@ -30,28 +30,23 @@
DEFAULT_DARK_ICON: Icon = Icon.create(tag="moon")


class ColorModeIcon(Cond):
"""Displays the current color mode as an icon."""
def color_mode_icon(
light_component: BaseComponent | None = None,
dark_component: BaseComponent | None = None,
):
"""Create an icon component based on color_mode.
@classmethod
def create(
cls,
light_component: BaseComponent | None = None,
dark_component: BaseComponent | None = None,
):
"""Create an icon component based on color_mode.
Args:
light_component: the component to display when color mode is default
dark_component: the component to display when color mode is dark (non-default)
Args:
light_component: the component to display when color mode is default
dark_component: the component to display when color mode is dark (non-default)
Returns:
The conditionally rendered component
"""
return color_mode_cond(
light=light_component or DEFAULT_LIGHT_ICON,
dark=dark_component or DEFAULT_DARK_ICON,
)
Returns:
The conditionally rendered component
"""
return color_mode_cond(
light=light_component or DEFAULT_LIGHT_ICON,
dark=dark_component or DEFAULT_DARK_ICON,
)


class ColorModeSwitch(Switch):
Expand Down
73 changes: 12 additions & 61 deletions reflex_chakra/components/forms/colormodeswitch.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ from typing import Any, Callable, Dict, Literal, Optional, Union, overload
from reflex_chakra.components import ChakraComponent
from reflex_chakra.components.media.icon import Icon
from reflex.components.component import BaseComponent
from reflex.components.core.cond import Cond
from reflex.event import EventHandler, EventSpec
from reflex.style import Style
from reflex.vars import Var
Expand All @@ -19,68 +18,20 @@ from .switch import Switch
DEFAULT_LIGHT_ICON: Icon
DEFAULT_DARK_ICON: Icon

class ColorModeIcon(Cond):
@overload
@classmethod
def create( # type: ignore
cls,
*children,
cond: Optional[Union[Var[Any], Any]] = None,
comp1: Optional[BaseComponent] = None,
comp2: Optional[BaseComponent] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_blur: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
on_click: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
on_context_menu: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
] = None,
on_double_click: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
] = None,
on_focus: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
on_mount: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
on_mouse_down: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
] = None,
on_mouse_enter: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
] = None,
on_mouse_leave: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
] = None,
on_mouse_move: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
] = None,
on_mouse_out: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
] = None,
on_mouse_over: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
] = None,
on_mouse_up: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
] = None,
on_scroll: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
on_unmount: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
] = None,
**props,
) -> "ColorModeIcon":
"""Create an icon component based on color_mode.
def color_mode_icon(
light_component: Optional[Union[BaseComponent, None]] = None,
dark_component: Optional[Union[BaseComponent, None]] = None,
):
"""Create an icon component based on color_mode.
Args:
light_component: the component to display when color mode is default
dark_component: the component to display when color mode is dark (non-default)
Args:
light_component: the component to display when color mode is default
dark_component: the component to display when color mode is dark (non-default)
Returns:
The conditionally rendered component
"""
...
Returns:
The conditionally rendered component
"""
...

class ColorModeSwitch(Switch):
@overload
Expand Down

0 comments on commit 5ef9729

Please sign in to comment.