StillWorking commited on
Commit
a4138df
·
verified ·
1 Parent(s): a6e98d5

Upload frontend/src/components/ui/sheet.tsx with huggingface_hub

Browse files
Files changed (1) hide show
  1. frontend/src/components/ui/sheet.tsx +122 -0
frontend/src/components/ui/sheet.tsx ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import * as SheetPrimitive from "@radix-ui/react-dialog";
5
+ import { cva, type VariantProps } from "class-variance-authority";
6
+ import { X } from "lucide-react";
7
+
8
+ import { cn } from "@/lib/utils";
9
+
10
+ const Sheet = SheetPrimitive.Root;
11
+
12
+ const SheetTrigger = SheetPrimitive.Trigger;
13
+
14
+ const SheetClose = SheetPrimitive.Close;
15
+
16
+ const SheetPortal = SheetPrimitive.Portal;
17
+
18
+ const SheetOverlay = React.forwardRef<
19
+ React.ElementRef<typeof SheetPrimitive.Overlay>,
20
+ React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>
21
+ >(({ className, ...props }, ref) => (
22
+ <SheetPrimitive.Overlay
23
+ className={cn(
24
+ "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
25
+ className,
26
+ )}
27
+ {...props}
28
+ ref={ref}
29
+ />
30
+ ));
31
+ SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
32
+
33
+ const sheetVariants = cva(
34
+ "fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",
35
+ {
36
+ variants: {
37
+ side: {
38
+ top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
39
+ bottom:
40
+ "inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
41
+ left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
42
+ right:
43
+ "inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",
44
+ },
45
+ },
46
+ defaultVariants: {
47
+ side: "right",
48
+ },
49
+ },
50
+ );
51
+
52
+ interface SheetContentProps
53
+ extends
54
+ React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
55
+ VariantProps<typeof sheetVariants> {}
56
+
57
+ const SheetContent = React.forwardRef<
58
+ React.ElementRef<typeof SheetPrimitive.Content>,
59
+ SheetContentProps
60
+ >(({ side = "right", className, children, ...props }, ref) => (
61
+ <SheetPortal>
62
+ <SheetOverlay />
63
+ <SheetPrimitive.Content ref={ref} className={cn(sheetVariants({ side }), className)} {...props}>
64
+ <SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background cursor-pointer transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary">
65
+ <X className="h-4 w-4" />
66
+ <span className="sr-only">Close</span>
67
+ </SheetPrimitive.Close>
68
+ {children}
69
+ </SheetPrimitive.Content>
70
+ </SheetPortal>
71
+ ));
72
+ SheetContent.displayName = SheetPrimitive.Content.displayName;
73
+
74
+ const SheetHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
75
+ <div className={cn("flex flex-col space-y-2 text-center sm:text-left", className)} {...props} />
76
+ );
77
+ SheetHeader.displayName = "SheetHeader";
78
+
79
+ const SheetFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
80
+ <div
81
+ className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)}
82
+ {...props}
83
+ />
84
+ );
85
+ SheetFooter.displayName = "SheetFooter";
86
+
87
+ const SheetTitle = React.forwardRef<
88
+ React.ElementRef<typeof SheetPrimitive.Title>,
89
+ React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title>
90
+ >(({ className, ...props }, ref) => (
91
+ <SheetPrimitive.Title
92
+ ref={ref}
93
+ className={cn("text-lg font-semibold text-foreground", className)}
94
+ {...props}
95
+ />
96
+ ));
97
+ SheetTitle.displayName = SheetPrimitive.Title.displayName;
98
+
99
+ const SheetDescription = React.forwardRef<
100
+ React.ElementRef<typeof SheetPrimitive.Description>,
101
+ React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description>
102
+ >(({ className, ...props }, ref) => (
103
+ <SheetPrimitive.Description
104
+ ref={ref}
105
+ className={cn("text-sm text-muted-foreground", className)}
106
+ {...props}
107
+ />
108
+ ));
109
+ SheetDescription.displayName = SheetPrimitive.Description.displayName;
110
+
111
+ export {
112
+ Sheet,
113
+ SheetPortal,
114
+ SheetOverlay,
115
+ SheetTrigger,
116
+ SheetClose,
117
+ SheetContent,
118
+ SheetHeader,
119
+ SheetFooter,
120
+ SheetTitle,
121
+ SheetDescription,
122
+ };