"use client"; import { ReactNode, useState } from "react"; import { DropzoneOptions, FileWithPath, useDropzone } from "react-dropzone"; import { Icon } from "@iconify/react"; interface Props { onDrop: (acceptedFiles: FileWithPath[]) => void; options?: DropzoneOptions; children?: ReactNode; } export default function Dropzone({ onDrop, options, children }: Props) { const [isDraggingOver, setIsDraggingOver] = useState(false); const handleDrop = (acceptedFiles: FileWithPath[]) => { setIsDraggingOver(false); onDrop(acceptedFiles); }; const { getRootProps, getInputProps } = useDropzone({ onDrop: handleDrop, maxFiles: 3, accept: { "image/*": [".png", ".jpg", ".jpeg", ".bmp", ".webp", ".heic"], }, ...options, }); return (
setIsDraggingOver(true)} onDragLeave={() => setIsDraggingOver(false)} className={`relative bg-orange-200 flex flex-col justify-center items-center gap-2 p-4 rounded-xl border-2 border-dashed border-amber-500 select-none size-full transition-all duration-200 ${ isDraggingOver && "scale-105 brightness-90 shadow-xl" }`} > {/* Used to transition from border-dashed to border-solid */}
1 : false })} /> {children}
); }