mirror of
https://github.com/morten-olsen/parcel.git
synced 2026-02-08 01:36:24 +01:00
37 lines
986 B
TypeScript
37 lines
986 B
TypeScript
import React, { useContext, useCallback } from 'react';
|
|
import styled from 'styled-components';
|
|
import { Layout } from 'antd';
|
|
import { FileAddTwoTone } from '@ant-design/icons';
|
|
import { useDropzone } from 'react-dropzone';
|
|
import EncryptionContext from '../../contexts/Encryption';
|
|
|
|
const Icon = styled(FileAddTwoTone)`
|
|
font-size: 100px;
|
|
margin-bottom: 20px;
|
|
`;
|
|
|
|
const DropWrapper = styled(Layout)`
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
flex-direction: column;
|
|
padding: 50px;
|
|
`;
|
|
|
|
const AddFile: React.FC = () => {
|
|
const { addFile } = useContext(EncryptionContext);
|
|
const onDrop = useCallback(acceptedFiles => {
|
|
acceptedFiles.forEach(addFile);
|
|
}, [])
|
|
const {getRootProps, getInputProps} = useDropzone({ onDrop });
|
|
return (
|
|
<DropWrapper {...getRootProps()}>
|
|
<input {...getInputProps()} />
|
|
<Icon />
|
|
<p>Drag 'n' drop some files here, or click to select files</p>
|
|
</DropWrapper>
|
|
);
|
|
};
|
|
|
|
export default AddFile;
|