From 2e28c0b3fe8b8e2736b662fc4d660b900e124b12 Mon Sep 17 00:00:00 2001 From: ArpitaGanatra Date: Thu, 18 Jul 2024 15:17:59 +0530 Subject: [PATCH] fix: drawer --- packages/ui/package.json | 2 +- packages/ui/src/components/drawer/drawer.tsx | 35 ++++++++++++++++---- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/packages/ui/package.json b/packages/ui/package.json index 99f1a3b..794da38 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -1,6 +1,6 @@ { "name": "@squaress/ui", - "version": "0.0.83", + "version": "0.0.84", "description": "", "main": "lib/index.js", "module": "lib/index.mjs", diff --git a/packages/ui/src/components/drawer/drawer.tsx b/packages/ui/src/components/drawer/drawer.tsx index 44bbff3..f6dcc9a 100644 --- a/packages/ui/src/components/drawer/drawer.tsx +++ b/packages/ui/src/components/drawer/drawer.tsx @@ -3,6 +3,12 @@ import { Drawer } from 'vaul' import { cn } from '@utils/cn' import type { ClassValue } from 'clsx' +const DrawerContext = React.createContext<{ + direction?: 'top' | 'right' | 'bottom' | 'left' +}>({ + direction: 'bottom', +}) + interface VaulDrawerTriggerProps { children: React.ReactNode } @@ -38,16 +44,18 @@ interface DrawerContentProps { } export const VaulDrawerContent = ({ children, className }: DrawerContentProps) => { + const { direction } = React.useContext(DrawerContext) return ( -
+
{children}
) @@ -72,10 +80,23 @@ export interface VaulDrawerProps { onClose?: () => void } -export const VaulDrawer = ({ children, open, onOpenChange, ...props }: VaulDrawerProps) => { +export const VaulDrawer = ({ + children, + open, + onOpenChange, + direction = 'bottom', + ...props +}: VaulDrawerProps) => { + const DrawerContextProvider = DrawerContext.Provider return ( - - {children} - + + + {children} + + ) }