mirror of
https://github.com/morten-olsen/parcel.git
synced 2026-02-08 01:36:24 +01:00
update
This commit is contained in:
@@ -1,46 +1,22 @@
|
||||
import React, { Fragment, useState } from 'react';
|
||||
import { Menu, Dropdown, Form } from 'antd';
|
||||
import { DownOutlined, FileOutlined, FileTextOutlined } from '@ant-design/icons';
|
||||
import React, { useState } from 'react';
|
||||
import { Radio, Divider } from 'antd';
|
||||
import { FileOutlined, FileTextOutlined } from '@ant-design/icons';
|
||||
import AddText from './AddText';
|
||||
import AddFile from './AddFile';
|
||||
|
||||
const layout = {
|
||||
labelCol: { span: 2 },
|
||||
};
|
||||
const DEFAULT_VALUE = 'text';
|
||||
|
||||
const Add: React.FC = () => {
|
||||
const [type, setType] = useState<'file' | 'text'>('text');
|
||||
|
||||
const menu = (
|
||||
<Menu>
|
||||
<Menu.Item
|
||||
onClick={() => setType('file')}
|
||||
active={type === 'file'}
|
||||
icon={<FileOutlined />}
|
||||
>
|
||||
File
|
||||
</Menu.Item>
|
||||
<Menu.Item
|
||||
onClick={() => setType('text')}
|
||||
active={type === 'text'}
|
||||
icon={<FileTextOutlined />}
|
||||
>
|
||||
Text
|
||||
</Menu.Item>
|
||||
</Menu>
|
||||
);
|
||||
const [type, setType] = useState<'file' | 'text'>(DEFAULT_VALUE);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form {...layout}>
|
||||
<Form.Item
|
||||
label="I want to encrypt a"
|
||||
>
|
||||
<Dropdown overlay={menu}>
|
||||
<a>{type} <DownOutlined /></a>
|
||||
</Dropdown>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
<Divider>
|
||||
<Radio.Group onChange={evt => setType(evt.target.value)} defaultValue={DEFAULT_VALUE}>
|
||||
<Radio.Button value="text"><FileTextOutlined /> Text</Radio.Button>
|
||||
<Radio.Button value="file"><FileOutlined /> File</Radio.Button>
|
||||
</Radio.Group>
|
||||
</Divider>
|
||||
{type === 'text' && <AddText />}
|
||||
{type === 'file' && <AddFile />}
|
||||
</>
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import React, { useContext, useCallback } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { Layout } from 'antd';
|
||||
import { UploadOutlined } from '@ant-design/icons';
|
||||
import { FileAddTwoTone } from '@ant-design/icons';
|
||||
import { useDropzone } from 'react-dropzone';
|
||||
import EncryptionContext from '../contexts/Encryption';
|
||||
|
||||
const Icon = styled(UploadOutlined)`
|
||||
const Icon = styled(FileAddTwoTone)`
|
||||
font-size: 100px;
|
||||
margin-bottom: 20px;
|
||||
`;
|
||||
|
||||
const DropWrapper = styled(Layout)`
|
||||
|
||||
@@ -3,14 +3,6 @@ import { Input, Form, Button } from 'antd';
|
||||
import { PlusOutlined } from '@ant-design/icons';
|
||||
import EncryptionContext from '../contexts/Encryption';
|
||||
|
||||
const layout = {
|
||||
labelCol: { span: 2 },
|
||||
};
|
||||
|
||||
const tailLayout = {
|
||||
wrapperCol: { offset: 2 },
|
||||
};
|
||||
|
||||
const AddText : React.FC = () => {
|
||||
const { addText } = useContext(EncryptionContext);
|
||||
const [name, setName] = useState('');
|
||||
@@ -23,25 +15,23 @@ const AddText : React.FC = () => {
|
||||
}, [text, addText]);
|
||||
|
||||
return (
|
||||
<Form {...layout}>
|
||||
<Form.Item
|
||||
label="Name"
|
||||
>
|
||||
<Form>
|
||||
<Form.Item>
|
||||
<Input
|
||||
placeholder="Title"
|
||||
value={name}
|
||||
onChange={evt => setName(evt.target.value)}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="Message"
|
||||
>
|
||||
<Form.Item>
|
||||
<Input.TextArea
|
||||
placeholder="Your message here..."
|
||||
value={text}
|
||||
rows={10}
|
||||
rows={6}
|
||||
onChange={evt => setText(evt.target.value)}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item {...tailLayout}>
|
||||
<Form.Item>
|
||||
<Button
|
||||
onClick={add}
|
||||
type="primary"
|
||||
|
||||
@@ -2,6 +2,8 @@ import React, {useMemo} from 'react';
|
||||
import {
|
||||
List,
|
||||
Button,
|
||||
Tooltip,
|
||||
Popconfirm,
|
||||
} from 'antd';
|
||||
import {
|
||||
DeleteOutlined,
|
||||
@@ -46,12 +48,12 @@ const share = async (file: FileType, fileData: File[]) => {
|
||||
}
|
||||
|
||||
const IconText = ({ icon, text, ...props }) => (
|
||||
<Button
|
||||
{...props}
|
||||
icon={React.createElement(icon)}
|
||||
>
|
||||
{text}
|
||||
</Button>
|
||||
<Tooltip title={text}>
|
||||
<Button
|
||||
{...props}
|
||||
icon={React.createElement(icon)}
|
||||
/>
|
||||
</Tooltip>
|
||||
);
|
||||
|
||||
const FileView: React.FC<Props> = ({
|
||||
@@ -67,12 +69,18 @@ const FileView: React.FC<Props> = ({
|
||||
|
||||
if (file.link) {
|
||||
actions.push(
|
||||
<IconText
|
||||
icon={DeleteOutlined}
|
||||
danger
|
||||
text="Delete"
|
||||
onClick={remove}
|
||||
/>
|
||||
<Popconfirm
|
||||
title="Are you sure delete this file?"
|
||||
onConfirm={remove}
|
||||
okText="Yes"
|
||||
cancelText="No"
|
||||
>
|
||||
<IconText
|
||||
icon={DeleteOutlined}
|
||||
danger
|
||||
text="Delete"
|
||||
/>
|
||||
</Popconfirm>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user