Skip to content

Commit 1c5be3b

Browse files
committed
Added: Drag and Reject effect on upload component
1 parent e8e9c78 commit 1c5be3b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

app/src/components/Upload/Body.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ import { useUploadContext } from './UploadContext'
77
const UploadBody = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
88
({ children, className, ...props }, ref: Ref<HTMLDivElement>) => {
99
const { options, horizontal } = useUploadContext()
10-
const { getRootProps, getInputProps } = useDropzone(options)
10+
const { getRootProps, getInputProps, isDragActive, isDragReject } = useDropzone(options)
1111
return (
1212
<div
1313
{...props}
1414
ref={ref}
1515
{...getRootProps()}
1616
className={cn(
17-
horizontal
18-
? 'flex cursor-pointer items-center gap-4 rounded-xl border border-dashed bg-white px-3 transition-all duration-300 hover:bg-metal-25 dark:border-metal-800 dark:bg-metal-900 dark:hover:bg-metal-900'
19-
: 'flex cursor-pointer flex-col items-center rounded-xl border border-dashed border-metal-50 bg-white p-3 text-center transition-all duration-300 hover:bg-metal-25 dark:border-metal-800 dark:bg-metal-900 dark:hover:bg-metal-900',
17+
'flex cursor-pointer items-center rounded-xl border border-dashed bg-white transition-all duration-300 hover:bg-metal-25 dark:border-metal-800 dark:bg-metal-900 dark:hover:bg-metal-900',
18+
horizontal ? 'gap-4 px-3' : 'flex-col border-metal-50 p-3 text-center',
19+
isDragActive && 'border-primary-500 dark:border-primary-400',
20+
isDragReject && 'border-error-500 dark:border-error-500',
2021
className,
2122
)}>
2223
<input {...getInputProps()} />

0 commit comments

Comments
 (0)