-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#865 Write projects overview in react/javascript
* clean up * install react-dropzone * create component FileUploadButton
- Loading branch information
Showing
6 changed files
with
111 additions
and
160 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { useDropzone } from 'react-dropzone' | ||
|
||
const FileUploadButton = ({ acceptedTypes, buttonText, onFileDrop }) => { | ||
const { getRootProps, getInputProps } = useDropzone({ | ||
accept: acceptedTypes, | ||
onDrop: (acceptedFiles) => { | ||
if (onFileDrop) { | ||
onFileDrop(acceptedFiles) | ||
} | ||
}, | ||
}) | ||
|
||
return ( | ||
<div {...getRootProps()}> | ||
<input {...getInputProps()} /> | ||
<button className="btn btn-link"> | ||
<i className="fa fa-download" aria-hidden="true"></i> {buttonText} | ||
</button> | ||
</div> | ||
) | ||
} | ||
|
||
FileUploadButton.propTypes = { | ||
acceptedTypes: PropTypes.string.isRequired, | ||
buttonText: PropTypes.string.isRequired, | ||
onFileDrop: PropTypes.func, | ||
} | ||
|
||
export default FileUploadButton |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters