({
isUploading,
onUpload,
onRemove,
file,
removeLabel,
title,
description,
extensions,
})
| 17 | } |
| 18 | |
| 19 | export const FileUpload: FC<FileUploadProps> = ({ |
| 20 | isUploading, |
| 21 | onUpload, |
| 22 | onRemove, |
| 23 | file, |
| 24 | removeLabel, |
| 25 | title, |
| 26 | description, |
| 27 | extensions, |
| 28 | }) => { |
| 29 | const fileDrop = useFileDrop(onUpload, extensions); |
| 30 | const inputRef = useRef<HTMLInputElement>(null); |
| 31 | const clickable = useClickable<HTMLDivElement>(() => |
| 32 | inputRef.current?.click(), |
| 33 | ); |
| 34 | |
| 35 | if (!isUploading && file) { |
| 36 | return ( |
| 37 | <div className="flex flex-row items-center justify-between gap-4 rounded-lg border border-border bg-surface-primary p-4"> |
| 38 | <div className="flex flex-row items-center gap-4"> |
| 39 | <FolderIcon className="size-icon-sm" /> |
| 40 | <span>{file.name}</span> |
| 41 | </div> |
| 42 | |
| 43 | <Button |
| 44 | variant="subtle" |
| 45 | size="icon-lg" |
| 46 | onClick={onRemove} |
| 47 | title={removeLabel} |
| 48 | > |
| 49 | <TrashIcon className="size-icon-sm" /> |
| 50 | </Button> |
| 51 | </div> |
| 52 | ); |
| 53 | } |
| 54 | |
| 55 | return ( |
| 56 | <> |
| 57 | <div |
| 58 | data-testid="drop-zone" |
| 59 | className={cn( |
| 60 | "flex cursor-pointer items-center justify-center rounded-lg border-2", |
| 61 | "border-dashed border-border p-12 hover:bg-surface-primary", |
| 62 | isUploading && "pointer-events-none opacity-75", |
| 63 | )} |
| 64 | {...clickable} |
| 65 | {...fileDrop} |
| 66 | > |
| 67 | <div className="flex flex-col items-center gap-2"> |
| 68 | <div className="flex size-16 items-center justify-center"> |
| 69 | {isUploading ? ( |
| 70 | <CircularProgress size={32} /> |
| 71 | ) : ( |
| 72 | <CloudUploadIcon className="size-16" /> |
| 73 | )} |
| 74 | </div> |
| 75 | |
| 76 | <div className="flex flex-col items-center gap-1"> |
nothing calls this directly
no test coverage detected