Sha256: 783848b3929398d780436dfb92c45cc91825dc1b5a53b7d9a4bb4d5123c98664
Contents?: true
Size: 1.27 KB
Versions: 18
Compression:
Stored size: 1.27 KB
Contents
/* @flow */ import React, { useCallback } from 'react' import { useDropzone } from 'react-dropzone' import { buildCss, noop } from '../utilities/props' import classnames from 'classnames' import { globalProps } from '../utilities/globalProps.js' import type { Callback } from '../types.js' import { Body, Card } from '..' type FileUploadProps = { accept?: array<string>, className?: string, onFilesAccepted: Callback, } const FileUpload = (props: FileUploadProps) => { const { accept = ['image/png', 'image/jpg', 'image/jpeg', 'image/svg+xml'], className, onFilesAccepted = noop, } = props const onDrop = useCallback((files) => { onFilesAccepted(files) }) const { getRootProps, getInputProps, isDragActive } = useDropzone({ accept, onDrop, }) return ( <div className={classnames(buildCss('pb_file_upload_kit', className), globalProps(props))} {...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
18 entries across 18 versions & 1 rubygems