From be2da74395ea4db3b6f8b4fcaf13a25ac1383a14 Mon Sep 17 00:00:00 2001 From: jyswee Date: Thu, 23 Jul 2026 22:13:21 +0000 Subject: [PATCH] Seed: photography template (19 files) --- src/components/ui/sheet.tsx | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/components/ui/sheet.tsx diff --git a/src/components/ui/sheet.tsx b/src/components/ui/sheet.tsx new file mode 100644 index 0000000..875ea22 --- /dev/null +++ b/src/components/ui/sheet.tsx @@ -0,0 +1,50 @@ +import * as React from "react"; +import { cn } from "@/lib/utils"; + +const SheetContext = React.createContext<{ open: boolean; setOpen: (o: boolean) => void }>({ open: false, setOpen: () => {} }); + +export function Sheet({ open: controlled, onOpenChange, children }: { open?: boolean; onOpenChange?: (o: boolean) => void; children?: React.ReactNode }) { + const [internal, setInternal] = React.useState(false); + const open = controlled ?? internal; + const setOpen = (o: boolean) => { setInternal(o); onOpenChange?.(o); }; + return {children}; +} + +export function SheetTrigger({ asChild, children, ...props }: React.ButtonHTMLAttributes & { asChild?: boolean }) { + const ctx = React.useContext(SheetContext); + if (asChild && React.isValidElement(children)) { + return React.cloneElement(children as React.ReactElement, { onClick: () => ctx.setOpen(true) }); + } + return ; +} + +export function SheetContent({ side = "right", className, children, ...props }: React.HTMLAttributes & { side?: "left" | "right" | "top" | "bottom" }) { + const ctx = React.useContext(SheetContext); + if (!ctx.open) return null; + const pos = side === "left" ? "left-0 top-0 h-full w-72" : side === "right" ? "right-0 top-0 h-full w-72" : side === "top" ? "top-0 left-0 w-full" : "bottom-0 left-0 w-full"; + return ( +
+
ctx.setOpen(false)} /> +
+ + {children} +
+
+ ); +} + +export function SheetHeader({ className, ...props }: React.HTMLAttributes) { + return
; +} +export function SheetTitle({ className, ...props }: React.HTMLAttributes) { + return

; +} +export function SheetDescription({ className, ...props }: React.HTMLAttributes) { + return

; +} +export function SheetClose({ children, ...props }: React.ButtonHTMLAttributes) { + const ctx = React.useContext(SheetContext); + return ; +} + +export default Sheet;