From 756a7cab2327b3fc0baa4f4db9262b42bf81142a Mon Sep 17 00:00:00 2001 From: Tom Gotsman Date: Tue, 29 Oct 2024 16:55:12 +0000 Subject: [PATCH] add missing props of drawer --- reflex/components/radix/primitives/drawer.py | 44 ++++++++++++++----- .../radix/themes/components/hover_card.py | 3 ++ 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/reflex/components/radix/primitives/drawer.py b/reflex/components/radix/primitives/drawer.py index 6fe4d10dd..74f0be7d7 100644 --- a/reflex/components/radix/primitives/drawer.py +++ b/reflex/components/radix/primitives/drawer.py @@ -33,14 +33,29 @@ class DrawerRoot(DrawerComponent): alias = "Vaul" + tag + # The open state of the drawer when it is initially rendered. Use when you do not need to control its open state. + default_open: Var[bool] + # Whether the drawer is open or not. open: Var[bool] - # Enable background scaling, it requires an element with [vaul-drawer-wrapper] data attribute to scale its background. - should_scale_background: Var[bool] + # Fires when the drawer is opened. + on_open_change: EventHandler[identity_event(bool)] - # Number between 0 and 1 that determines when the drawer should be closed. - close_threshold: Var[float] + # When `False`, it allows to interact with elements outside of the drawer without closing it. Defaults to `True`. + modal: Var[bool] + + # Direction of the drawer. This adjust the animations and the drag direction. Defaults to `"bottom"` + direction: Var[LiteralDirectionType] + + # Gets triggered after the open or close animation ends, it receives an open argument with the open state of the drawer by the time the function was triggered. + on_animation_end: EventHandler[identity_event(bool)] + + # When false dragging, clicking outside, pressing esc, etc. will not close the drawer. Use this in combination with the open prop, otherwise you won't be able to open/close the drawer. + dismissible: Var[bool] + + # When true dragging will only be possible by the handle. + handle_only: Var[bool] # 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: Optional[List[Union[str, float]]] @@ -51,17 +66,15 @@ class DrawerRoot(DrawerComponent): # Duration for which the drawer is not draggable after scrolling content inside of the drawer. Defaults to 500ms scroll_lock_timeout: Var[int] - # When `False`, it allows to interact with elements outside of the drawer without closing it. Defaults to `True`. - modal: Var[bool] - - # Direction of the drawer. Defaults to `"bottom"` - direction: Var[LiteralDirectionType] - # When `True`, it prevents scroll restoration. Defaults to `True`. preventScrollRestoration: Var[bool] - # Fires when the drawer is opened. - on_open_change: EventHandler[identity_event(bool)] + # Enable background scaling, it requires an element with [vaul-drawer-wrapper] data attribute to scale its background. + should_scale_background: Var[bool] + + # Number between 0 and 1 that determines when the drawer should be closed. + close_threshold: Var[float] + class DrawerTrigger(DrawerComponent): @@ -262,6 +275,12 @@ class DrawerDescription(DrawerComponent): base_style.update(style) return {"css": base_style} +class DrawerHandle(DrawerComponent): + """A description for the drawer.""" + + tag = "Drawer.Handle" + + alias = "Vaul" + tag class Drawer(ComponentNamespace): """A namespace for Drawer components.""" @@ -274,6 +293,7 @@ class Drawer(ComponentNamespace): close = staticmethod(DrawerClose.create) title = staticmethod(DrawerTitle.create) description = staticmethod(DrawerDescription.create) + handle = staticmethod(DrawerHandle.create) drawer = Drawer() diff --git a/reflex/components/radix/themes/components/hover_card.py b/reflex/components/radix/themes/components/hover_card.py index 84d76aaae..9b6ad0c6b 100644 --- a/reflex/components/radix/themes/components/hover_card.py +++ b/reflex/components/radix/themes/components/hover_card.py @@ -67,6 +67,9 @@ class HoverCardContent(elements.Div, RadixThemesComponent): # The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless sticky: Var[Literal["partial", "always"]] + # Whether to hide the content when the trigger becomes fully occluded. + hide_when_detached: Var[bool] + # Hovercard size "1" - "3" size: Var[Responsive[Literal["1", "2", "3"]]]