Upload src\components\FormDrawer.tsx with huggingface_hub
Browse files
src//components//FormDrawer.tsx
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Dialog, DialogPanel, DialogTitle, Transition, TransitionChild } from "@headlessui/react";
|
| 2 |
+
import { Fragment, ReactNode } from "react";
|
| 3 |
+
import { X } from "lucide-react";
|
| 4 |
+
|
| 5 |
+
interface FormDrawerProps {
|
| 6 |
+
isOpen: boolean;
|
| 7 |
+
onClose: () => void;
|
| 8 |
+
title: string;
|
| 9 |
+
subtitle?: string;
|
| 10 |
+
children: ReactNode;
|
| 11 |
+
maxWidth?: string;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
export default function FormDrawer({
|
| 15 |
+
isOpen,
|
| 16 |
+
onClose,
|
| 17 |
+
title,
|
| 18 |
+
subtitle,
|
| 19 |
+
children,
|
| 20 |
+
maxWidth = "max-w-xl",
|
| 21 |
+
}: FormDrawerProps) {
|
| 22 |
+
return (
|
| 23 |
+
<Transition show={isOpen} as={Fragment}>
|
| 24 |
+
<Dialog as="div" className="relative z-50" onClose={onClose}>
|
| 25 |
+
<TransitionChild
|
| 26 |
+
as={Fragment}
|
| 27 |
+
enter="ease-in-out duration-300"
|
| 28 |
+
enterFrom="opacity-0"
|
| 29 |
+
enterTo="opacity-100"
|
| 30 |
+
leave="ease-in-out duration-300"
|
| 31 |
+
leaveFrom="opacity-100"
|
| 32 |
+
leaveTo="opacity-0"
|
| 33 |
+
>
|
| 34 |
+
<div className="fixed inset-0 bg-black/70 backdrop-blur-xs transition-opacity" />
|
| 35 |
+
</TransitionChild>
|
| 36 |
+
|
| 37 |
+
<div className="fixed inset-0 overflow-hidden">
|
| 38 |
+
<div className="absolute inset-0 overflow-hidden">
|
| 39 |
+
<div className="pointer-events-none fixed inset-y-0 right-0 flex max-w-full pl-10">
|
| 40 |
+
<TransitionChild
|
| 41 |
+
as={Fragment}
|
| 42 |
+
enter="transform transition ease-in-out duration-300 sm:duration-400"
|
| 43 |
+
enterFrom="translate-x-full"
|
| 44 |
+
enterTo="translate-x-0"
|
| 45 |
+
leave="transform transition ease-in-out duration-300 sm:duration-400"
|
| 46 |
+
leaveFrom="translate-x-0"
|
| 47 |
+
leaveTo="translate-x-full"
|
| 48 |
+
>
|
| 49 |
+
<DialogPanel className={`pointer-events-auto w-screen ${maxWidth}`}>
|
| 50 |
+
<div className="flex h-full flex-col overflow-y-auto bg-zinc-950 border-l border-zinc-800 shadow-2xl">
|
| 51 |
+
<div className="px-6 py-5 border-b border-zinc-800 bg-zinc-900/50 flex items-center justify-between sticky top-0 z-10">
|
| 52 |
+
<div>
|
| 53 |
+
<DialogTitle className="text-lg font-semibold text-zinc-100">
|
| 54 |
+
{title}
|
| 55 |
+
</DialogTitle>
|
| 56 |
+
{subtitle && (
|
| 57 |
+
<p className="text-xs text-zinc-400 mt-0.5">{subtitle}</p>
|
| 58 |
+
)}
|
| 59 |
+
</div>
|
| 60 |
+
<button
|
| 61 |
+
onClick={onClose}
|
| 62 |
+
className="rounded-lg p-2 text-zinc-400 hover:text-zinc-100 hover:bg-zinc-800 transition-colors"
|
| 63 |
+
>
|
| 64 |
+
<X className="w-5 h-5" />
|
| 65 |
+
</button>
|
| 66 |
+
</div>
|
| 67 |
+
|
| 68 |
+
<div className="flex-1 px-6 py-6 space-y-6">{children}</div>
|
| 69 |
+
</div>
|
| 70 |
+
</DialogPanel>
|
| 71 |
+
</TransitionChild>
|
| 72 |
+
</div>
|
| 73 |
+
</div>
|
| 74 |
+
</div>
|
| 75 |
+
</Dialog>
|
| 76 |
+
</Transition>
|
| 77 |
+
);
|
| 78 |
+
}
|