Fix comments on drawer (#2604)

* Fix comments on drawer

* Fix precommit

* Fix pyi

* Fix table invalid children

---------

Co-authored-by: Alek Petuskey <alekpetuskey@aleks-mbp.lan>
This commit is contained in:
Alek Petuskey 2024-02-13 22:10:18 -08:00 committed by GitHub
parent e729a315f8
commit eadbf1d3db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 28 deletions

View File

@ -6,12 +6,12 @@ from __future__ import annotations
from types import SimpleNamespace from types import SimpleNamespace
from typing import Any, Dict, List, Literal, Optional, Union from typing import Any, Dict, List, Literal, Optional, Union
from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName from reflex.components.radix.primitives.base import RadixPrimitiveComponent
from reflex.constants import EventTriggers from reflex.constants import EventTriggers
from reflex.vars import Var from reflex.vars import Var
class DrawerComponent(RadixPrimitiveComponentWithClassName): class DrawerComponent(RadixPrimitiveComponent):
"""A Drawer component.""" """A Drawer component."""
library = "vaul" library = "vaul"
@ -37,35 +37,28 @@ class DrawerRoot(DrawerComponent):
# Whether the drawer is open or not. # Whether the drawer is open or not.
open: Var[bool] open: Var[bool]
# Enable background scaling, # Enable background scaling, it requires an element with [vaul-drawer-wrapper] data attribute to scale its background.
# it requires an element with [vaul-drawer-wrapper] data attribute to scale its background.
should_scale_background: Var[bool] should_scale_background: Var[bool]
# Number between 0 and 1 that determines when the drawer should be closed. # Number between 0 and 1 that determines when the drawer should be closed.
close_threshold: Var[float] close_threshold: Var[float]
# Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up. Should go from least visible. # Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up. Should go from least visible. Also Accept px values, which doesn't take screen height into account.
# Also Accept px values, which doesn't take screen height into account.
snap_points: Optional[List[Union[str, float]]] snap_points: Optional[List[Union[str, float]]]
# Index of a snapPoint from which the overlay fade should be applied. # Index of a snapPoint from which the overlay fade should be applied. Defaults to the last snap point.
# Defaults to the last snap point.
# TODO: will it accept -1 then?
fade_from_index: Var[int] fade_from_index: Var[int]
# Duration for which the drawer is not draggable after scrolling content inside of the drawer. Defaults to 500ms # Duration for which the drawer is not draggable after scrolling content inside of the drawer. Defaults to 500ms
scroll_lock_timeout: Var[int] scroll_lock_timeout: Var[int]
# When `False`, it allows to interact with elements outside of the drawer without closing it. # When `False`, it allows to interact with elements outside of the drawer without closing it. Defaults to `True`.
# Defaults to `True`.
modal: Var[bool] modal: Var[bool]
# Direction of the drawer. Defaults to `"bottom"` # Direction of the drawer. Defaults to `"bottom"`
direction: Var[LiteralDirectionType] direction: Var[LiteralDirectionType]
# When `True`, it prevents scroll restoration # When `True`, it prevents scroll restoration. Defaults to `True`.
# when the drawer is closed after a navigation happens inside of it.
# Defaults to `True`.
preventScrollRestoration: Var[bool] preventScrollRestoration: Var[bool]
def get_event_triggers(self) -> Dict[str, Any]: def get_event_triggers(self) -> Dict[str, Any]:
@ -87,7 +80,8 @@ class DrawerTrigger(DrawerComponent):
alias = "Vaul" + tag alias = "Vaul" + tag
as_child: Var[bool] # Defaults to true, if the first child acts as the trigger.
as_child: Var[bool] = True # type: ignore
class DrawerPortal(DrawerComponent): class DrawerPortal(DrawerComponent):
@ -170,7 +164,7 @@ class DrawerOverlay(DrawerComponent):
"bottom": "0", "bottom": "0",
"top": "0", "top": "0",
"z_index": 50, "z_index": 50,
"background": "rgba(0, 0, 0, 0.8)", "background": "rgba(0, 0, 0, 0.5)",
} }
style = self.style or {} style = self.style or {}
base_style.update(style) base_style.update(style)

View File

@ -9,11 +9,11 @@ from reflex.event import EventChain, EventHandler, EventSpec
from reflex.style import Style from reflex.style import Style
from types import SimpleNamespace from types import SimpleNamespace
from typing import Any, Dict, List, Literal, Optional, Union from typing import Any, Dict, List, Literal, Optional, Union
from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName from reflex.components.radix.primitives.base import RadixPrimitiveComponent
from reflex.constants import EventTriggers from reflex.constants import EventTriggers
from reflex.vars import Var from reflex.vars import Var
class DrawerComponent(RadixPrimitiveComponentWithClassName): class DrawerComponent(RadixPrimitiveComponent):
@overload @overload
@classmethod @classmethod
def create( # type: ignore def create( # type: ignore
@ -182,11 +182,11 @@ class DrawerRoot(DrawerComponent):
should_scale_background: Enable background scaling, it requires an element with [vaul-drawer-wrapper] data attribute to scale its background. should_scale_background: Enable background scaling, it requires an element with [vaul-drawer-wrapper] data attribute to scale its background.
close_threshold: Number between 0 and 1 that determines when the drawer should be closed. close_threshold: Number between 0 and 1 that determines when the drawer should be closed.
snap_points: Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up. Should go from least visible. Also Accept px values, which doesn't take screen height into account. snap_points: Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up. Should go from least visible. Also Accept px values, which doesn't take screen height into account.
fade_from_index: Index of a snapPoint from which the overlay fade should be applied. Defaults to the last snap point. TODO: will it accept -1 then? fade_from_index: Index of a snapPoint from which the overlay fade should be applied. Defaults to the last snap point.
scroll_lock_timeout: Duration for which the drawer is not draggable after scrolling content inside of the drawer. Defaults to 500ms scroll_lock_timeout: Duration for which the drawer is not draggable after scrolling content inside of the drawer. Defaults to 500ms
modal: When `False`, it allows to interact with elements outside of the drawer without closing it. Defaults to `True`. modal: When `False`, it allows to interact with elements outside of the drawer without closing it. Defaults to `True`.
direction: Direction of the drawer. Defaults to `"bottom"` direction: Direction of the drawer. Defaults to `"bottom"`
preventScrollRestoration: When `True`, it prevents scroll restoration when the drawer is closed after a navigation happens inside of it. Defaults to `True`. preventScrollRestoration: When `True`, it prevents scroll restoration. Defaults to `True`.
as_child: Change the default rendered element for the one passed as a child. as_child: Change the default rendered element for the one passed as a child.
style: The style of the component. style: The style of the component.
key: A unique key for the component. key: A unique key for the component.
@ -879,11 +879,11 @@ class Drawer(SimpleNamespace):
should_scale_background: Enable background scaling, it requires an element with [vaul-drawer-wrapper] data attribute to scale its background. should_scale_background: Enable background scaling, it requires an element with [vaul-drawer-wrapper] data attribute to scale its background.
close_threshold: Number between 0 and 1 that determines when the drawer should be closed. close_threshold: Number between 0 and 1 that determines when the drawer should be closed.
snap_points: Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up. Should go from least visible. Also Accept px values, which doesn't take screen height into account. snap_points: Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up. Should go from least visible. Also Accept px values, which doesn't take screen height into account.
fade_from_index: Index of a snapPoint from which the overlay fade should be applied. Defaults to the last snap point. TODO: will it accept -1 then? fade_from_index: Index of a snapPoint from which the overlay fade should be applied. Defaults to the last snap point.
scroll_lock_timeout: Duration for which the drawer is not draggable after scrolling content inside of the drawer. Defaults to 500ms scroll_lock_timeout: Duration for which the drawer is not draggable after scrolling content inside of the drawer. Defaults to 500ms
modal: When `False`, it allows to interact with elements outside of the drawer without closing it. Defaults to `True`. modal: When `False`, it allows to interact with elements outside of the drawer without closing it. Defaults to `True`.
direction: Direction of the drawer. Defaults to `"bottom"` direction: Direction of the drawer. Defaults to `"bottom"`
preventScrollRestoration: When `True`, it prevents scroll restoration when the drawer is closed after a navigation happens inside of it. Defaults to `True`. preventScrollRestoration: When `True`, it prevents scroll restoration. Defaults to `True`.
as_child: Change the default rendered element for the one passed as a child. as_child: Change the default rendered element for the one passed as a child.
style: The style of the component. style: The style of the component.
key: A unique key for the component. key: A unique key for the component.