import { useCallback } from 'react' import { useDropzone } from 'react-dropzone' import { motion, AnimatePresence } from 'framer-motion' import { Upload, X, Image as ImageIcon, User } from 'lucide-react' function ImageUpload({ label, image, onImageSelect, onClear }) { const onDrop = useCallback((acceptedFiles) => { const file = acceptedFiles[0] if (file) { const preview = URL.createObjectURL(file) onImageSelect({ file, preview }) } }, [onImageSelect]) const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop, accept: { 'image/*': ['.jpeg', '.jpg', '.png', '.webp'] }, maxFiles: 1, maxSize: 10 * 1024 * 1024 // 10MB }) return (
{!image ? ( {/* Animated upload icon */}
{isDragActive && ( )}

{isDragActive ? 'Drop image here' : 'Drag & drop an image'}

or browse files

Supports: JPG, PNG, WebP (max 10MB)

) : ( {/* Image preview */} Preview {/* Overlay on hover */}
{/* Clear button */} { e.stopPropagation() onClear() }} className="absolute top-3 right-3 w-10 h-10 rounded-full bg-black/50 backdrop-blur-sm flex items-center justify-center text-white hover:bg-red-500/80 transition-colors" > {/* File info */}
{image.file.name}
{/* Success indicator */}
)}
) } export default ImageUpload