diff --git a/src/components/image-picker.tsx b/src/components/image-picker.tsx new file mode 100644 index 0000000..899477e --- /dev/null +++ b/src/components/image-picker.tsx @@ -0,0 +1,68 @@ +"use client"; + +import type React from "react"; +import { useRef } from "react"; +import { Button } from "@/components/ui/button"; +import { ImageIcon } from "lucide-react"; + +interface ImagePickerProps { + onFileSelect?: (file: File) => void; + className?: string; + children?: React.ReactNode; + variant?: + | "default" + | "destructive" + | "outline" + | "secondary" + | "ghost" + | "link"; + size?: "default" | "sm" | "lg" | "icon"; + disabled?: boolean; +} + +export function ImagePicker({ + onFileSelect, + className, + children, + variant = "ghost", + size = "icon", + disabled = false, +}: ImagePickerProps) { + const fileInputRef = useRef(null); + + const handleButtonClick = () => { + fileInputRef.current?.click(); + }; + + const handleFileChange = (event: React.ChangeEvent) => { + const file = event.target.files?.[0]; + if (file && onFileSelect) { + onFileSelect(file); + } + if (fileInputRef.current) { + fileInputRef.current.value = ""; + } + }; + + return ( + <> + + + + ); +}