Open jasongerbes opened 1 month ago
Hey @emilkowalski, you're right that DrawerContext
can't currently be used externally.
My use case requires knowing the value of the direction
prop to position the Drawer.Handle
appropriately:
bottom
- show Drawer.Handle
at the top of the drawer.top
- show Drawer.Handle
at the bottom of the drawer.left
or right
- hide Drawer.Handle
and show Drawer.Close
instead.I'm currently using a custom DrawerContext
to share the direction
prop with children of the Drawer.Root
.
Here's the full implementation for context. It builds upon the shadcn/ui Drawer component.
This workaround is sufficient, so feel free to close this PR if there are specific issues with exporting DrawerContext
.
I also have a need to access useDrawerContext
to customize the behaviour of the Overlay. I have non-modal Drawer, which currently force hides the Overlay entirely. I still need the overlay to be visible on certain snap points. If I had access to the context, I could implement my own Overlay logic.
Is there anything blocking merging this? I have the exact use case as the author
Vaul doesn't currently export the
useDrawerContext
hook, which would be helpful for getting thedirection
of the<Drawer.Root>
to style the<Drawer.Content>
appropriately.For context, I'm updating my instance of the shadcn/ui Drawer component to support all directions (similar to the Sheet component).
This PR exports
useDrawerContext
andDrawerContext
, and includes some format fixes for the new JSDocs.