@xk2800/nextjs-template 0.7.2-beta.5 → 0.7.2-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/ui/drawer.tsx +88 -0
- package/package.json +1 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Drawer as DrawerPrimitive } from "vaul"
|
|
5
|
+
|
|
6
|
+
import { cn } from "../../lib/utils"
|
|
7
|
+
|
|
8
|
+
function Drawer({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>) {
|
|
9
|
+
return <DrawerPrimitive.Root data-slot="drawer" {...props} />
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function DrawerTrigger({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Trigger>) {
|
|
13
|
+
return <DrawerPrimitive.Trigger data-slot="drawer-trigger" {...props} />
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function DrawerPortal({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Portal>) {
|
|
17
|
+
return <DrawerPrimitive.Portal data-slot="drawer-portal" {...props} />
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function DrawerClose({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Close>) {
|
|
21
|
+
return <DrawerPrimitive.Close data-slot="drawer-close" {...props} />
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function DrawerOverlay({ className, ...props }: React.ComponentProps<typeof DrawerPrimitive.Overlay>) {
|
|
25
|
+
return (
|
|
26
|
+
<DrawerPrimitive.Overlay
|
|
27
|
+
data-slot="drawer-overlay"
|
|
28
|
+
className={cn("fixed inset-0 z-50 bg-black/50", className)}
|
|
29
|
+
{...props}
|
|
30
|
+
/>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Bottom sheet by default; pass direction="top|left|right" on <Drawer> for other edges.
|
|
35
|
+
function DrawerContent({ className, children, ...props }: React.ComponentProps<typeof DrawerPrimitive.Content>) {
|
|
36
|
+
return (
|
|
37
|
+
<DrawerPortal>
|
|
38
|
+
<DrawerOverlay />
|
|
39
|
+
<DrawerPrimitive.Content
|
|
40
|
+
data-slot="drawer-content"
|
|
41
|
+
className={cn(
|
|
42
|
+
"group/drawer-content bg-background fixed z-50 flex h-auto flex-col border-(length:--surface-border-width) border-(--surface-border-color)",
|
|
43
|
+
"data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[90dvh] data-[vaul-drawer-direction=bottom]:rounded-t-xl data-[vaul-drawer-direction=bottom]:pb-[env(safe-area-inset-bottom)]",
|
|
44
|
+
"data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[90dvh] data-[vaul-drawer-direction=top]:rounded-b-xl",
|
|
45
|
+
"data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:sm:max-w-sm",
|
|
46
|
+
"data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:sm:max-w-sm",
|
|
47
|
+
className
|
|
48
|
+
)}
|
|
49
|
+
{...props}
|
|
50
|
+
>
|
|
51
|
+
<div
|
|
52
|
+
aria-hidden
|
|
53
|
+
className="bg-muted-foreground/30 mx-auto mt-4 hidden h-1.5 w-12 shrink-0 rounded-full group-data-[vaul-drawer-direction=bottom]/drawer-content:block"
|
|
54
|
+
/>
|
|
55
|
+
{children}
|
|
56
|
+
</DrawerPrimitive.Content>
|
|
57
|
+
</DrawerPortal>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function DrawerHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
62
|
+
return <div data-slot="drawer-header" className={cn("flex flex-col gap-1.5 p-4", className)} {...props} />
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function DrawerFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
66
|
+
return <div data-slot="drawer-footer" className={cn("mt-auto flex flex-col gap-2 p-4", className)} {...props} />
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function DrawerTitle({ className, ...props }: React.ComponentProps<typeof DrawerPrimitive.Title>) {
|
|
70
|
+
return <DrawerPrimitive.Title data-slot="drawer-title" className={cn("text-foreground font-semibold", className)} {...props} />
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function DrawerDescription({ className, ...props }: React.ComponentProps<typeof DrawerPrimitive.Description>) {
|
|
74
|
+
return <DrawerPrimitive.Description data-slot="drawer-description" className={cn("text-muted-foreground text-sm", className)} {...props} />
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export {
|
|
78
|
+
Drawer,
|
|
79
|
+
DrawerClose,
|
|
80
|
+
DrawerContent,
|
|
81
|
+
DrawerDescription,
|
|
82
|
+
DrawerFooter,
|
|
83
|
+
DrawerHeader,
|
|
84
|
+
DrawerOverlay,
|
|
85
|
+
DrawerPortal,
|
|
86
|
+
DrawerTitle,
|
|
87
|
+
DrawerTrigger,
|
|
88
|
+
}
|