Skip to content

Commit 9f0dab0

Browse files
Fix drawer
1 parent fbb2701 commit 9f0dab0

File tree

5 files changed

+36
-9
lines changed

5 files changed

+36
-9
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@undp/design-system-react",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"main": "./dist/index.cjs",
55
"module": "./dist/index.js",
66
"browser": "./dist/index.umd.js",

src/components/ui/drawer.tsx

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ function DrawerContent({
4444
return (
4545
<DrawerPortal data-slot='drawer-portal'>
4646
<DrawerOverlay />
47-
4847
<DrawerPrimitive.Content
4948
data-slot='drawer-content'
5049
className={cn(
@@ -70,7 +69,9 @@ function DrawerContent({
7069
<X size={32} strokeWidth={1} />
7170
</button>
7271
</DrawerClose>
73-
{children}
72+
<div className='pt-[4.375rem] px-[0.75rem] md:pt-0 md:pr-[1.5rem] md:pl-[2rem] h-[100vh] undp-scrollbar'>
73+
{children}
74+
</div>
7475
</DrawerPrimitive.Content>
7576
</DrawerPortal>
7677
);
@@ -81,30 +82,52 @@ function DrawerHeader({ className, ...props }: React.ComponentProps<'div'>) {
8182
<div
8283
data-slot='drawer-header'
8384
className={cn(
84-
'flex flex-col gap-0.5 p-4 group-data-[vaul-drawer-direction=left]:mt-24 group-data-[vaul-drawer-direction=right]:mt-24 group-data-[vaul-drawer-direction=right]:mr-24 group-data-[vaul-drawer-direction=top]:mt-24 group-data-[vaul-drawer-direction=bottom]:mt-24 group-data-[vaul-drawer-direction=top]:ml-24 group-data-[vaul-drawer-direction=bottom]:ml-24 group-data-[vaul-drawer-direction=left]:mt-24 group-data-[vaul-drawer-direction=bottom]/drawer-content:text-center group-data-[vaul-drawer-direction=top]/drawer-content:text-center md:gap-1.5 md:text-left h-[100vh] undp-scrollbar',
85+
'mt-0 mr-0 ml-[1.875rem] md:mt-[6rem] md:ml-[6rem] group-data-[vaul-drawer-direction=left]:mt-24 group-data-[vaul-drawer-direction=right]:mt-24 group-data-[vaul-drawer-direction=right]:mr-24 group-data-[vaul-drawer-direction=top]:mt-24 group-data-[vaul-drawer-direction=bottom]:mt-24 group-data-[vaul-drawer-direction=top]:ml-24 group-data-[vaul-drawer-direction=bottom]:ml-24 group-data-[vaul-drawer-direction=left]:mt-24 group-data-[vaul-drawer-direction=bottom]/drawer-content:text-center group-data-[vaul-drawer-direction=top]/drawer-content:text-center md:gap-1.5 md:text-left',
8586
className,
8687
)}
8788
{...props}
8889
/>
8990
);
9091
}
9192

93+
function DrawerBody({ className, ...props }: React.ComponentProps<'div'>) {
94+
return <div data-slot='drawer-header' className={cn('mt-20', className)} {...props} />;
95+
}
96+
9297
function DrawerFooter({ className, ...props }: React.ComponentProps<'div'>) {
9398
return (
9499
<div
95100
data-slot='drawer-footer'
96-
className={cn('mt-auto flex flex-col gap-2 p-4', className)}
101+
className={cn('mt-auto flex flex-col gap-2 p-4 absolute bottom-0', className)}
97102
{...props}
98103
/>
99104
);
100105
}
101106

102107
function DrawerTitle({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Title>) {
103-
return <DrawerPrimitive.Title data-slot='drawer-title' {...props} />;
108+
return (
109+
<DrawerPrimitive.Title
110+
data-slot='drawer-title'
111+
{...props}
112+
className={cn(
113+
'font-heading mb-4 text-[1.563rem] leading-[1.1] uppercase font-bold md:text-[3.438rem]',
114+
props.className,
115+
)}
116+
/>
117+
);
104118
}
105119

106120
function DrawerDescription({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Description>) {
107-
return <DrawerPrimitive.Description data-slot='drawer-description' {...props} />;
121+
return (
122+
<DrawerPrimitive.Description
123+
data-slot='drawer-description'
124+
{...props}
125+
className={cn(
126+
'text-[1.25rem] mb-4 leading-[1.15] font-semibold md:text-[2.188rem]',
127+
props.className,
128+
)}
129+
/>
130+
);
108131
}
109132

110133
export {
@@ -118,4 +141,5 @@ export {
118141
DrawerFooter,
119142
DrawerTitle,
120143
DrawerDescription,
144+
DrawerBody,
121145
};

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export {
127127
DrawerHeader,
128128
DrawerTitle,
129129
DrawerTrigger,
130+
DrawerBody,
130131
} from '@/components/ui/drawer';
131132

132133
export { SDGCardButton } from '@/components/ui/sdgCardButton';

src/stories/Drawer/Drawer.stories.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Meta, StoryObj } from '@storybook/react';
33

44
import {
55
Drawer,
6+
DrawerBody,
67
DrawerContent,
78
DrawerDescription,
89
DrawerFooter,
@@ -42,6 +43,7 @@ const meta: Meta<PagePropsAndCustomArgs> = {
4243
<DrawerTitle>Are you absolutely sure?</DrawerTitle>
4344
<DrawerDescription>This action cannot be undone.</DrawerDescription>
4445
</DrawerHeader>
46+
<DrawerBody>Hello world</DrawerBody>
4547
<DrawerFooter>This is the footer</DrawerFooter>
4648
</DrawerContent>
4749
</Drawer>

0 commit comments

Comments
 (0)