Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Upload component drag-in, drag-out and disable styles. #171

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions app/src/components/Upload/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ import { useUploadContext } from './UploadContext'
const UploadBody = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
({ children, className, ...props }, ref: Ref<HTMLDivElement>) => {
const { options, horizontal } = useUploadContext()
const { getRootProps, getInputProps } = useDropzone(options)
const { getRootProps, getInputProps, isDragActive, isDragReject } = useDropzone(options)
return (
<div
{...props}
ref={ref}
{...getRootProps()}
className={cn(
horizontal
? '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'
: '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',
'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',
horizontal ? 'gap-4 px-3' : 'flex-col border-metal-50 p-3 text-center',
isDragActive && 'border-blue-500 bg-sky-100 dark:bg-blue-900',
isDragReject && 'border-red-500 bg-red-100 dark:bg-red-900',
options?.disabled && 'cursor-not-allowed hover:bg-transparent',
className,
)}>
<input {...getInputProps()} />
Expand Down
5 changes: 1 addition & 4 deletions app/src/components/Upload/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ const UploadIcon = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
return (
<div
{...props}
className={cn(
'flex h-16 w-16 items-center justify-center rounded-full bg-metal-50 dark:bg-metal-800',
className,
)}
className={cn('flex size-16 items-center justify-center rounded-full bg-metal-50 dark:bg-metal-800', className)}
ref={ref}>
{children}
</div>
Expand Down
Loading