Sha256: 5e8b586edb4df3d4f83293e994b3d994b43e72fd09d9f236444ccd722d18a3aa
Contents?: true
Size: 1.16 KB
Versions: 8
Compression:
Stored size: 1.16 KB
Contents
/* @flow */ import React, { useCallback } from 'react' import { useDropzone } from 'react-dropzone' import { buildCss, noop, } from '../utilities/props' import type { Callback } from '../types.js' import { Body, Card, } from '..' type FileUploadProps = { accept?: Array<String>, className?: String, onFilesAccepted: Callback, } const FileUpload = ({ accept = ['image/png', 'image/jpg', 'image/jpeg', 'image/svg+xml'], className, onFilesAccepted = noop, }: FileUploadProps) => { const onDrop = useCallback((files) => { onFilesAccepted(files) }) const { getRootProps, getInputProps, isDragActive, } = useDropzone({ accept, onDrop, }) return ( <div className={buildCss('pb_file_upload_kit', className)} {...getRootProps()} > <Card> <input {...getInputProps()} /> <Body color="light" > <If condition={isDragActive}> <p>{'Drop the files here ...'}</p> <Else /> <p>{'Drag & drop some files here, or click to select files'}</p> </If> </Body> </Card> </div> ) } export default FileUpload
Version data entries
8 entries across 8 versions & 1 rubygems