forked from kimmelsg/cj-upload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
87 lines (79 loc) · 2.39 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import React from 'react';
import Welcome from './Welcome';
import Uploader from '../src/uploader';
import UploadField from '../src/upload-field';
import { WithNotes } from '@kadira/storybook-addon-notes';
import { storiesOf, action, linkTo } from '@kadira/storybook';
import { withKnobs, text, boolean } from '@kadira/storybook-addon-knobs';
storiesOf('NavJobs Upload', module).add('Welcome', () => (
<Welcome showApp={linkTo('Button')} />
));
const field = storiesOf('Field', module);
field.addDecorator(withKnobs);
field.add('Renders', () => (
<WithNotes
notes="Make any child element a clickable file upload by wrapping it inside of UploadField"
>
<UploadField onFiles={action('files')}>
<div>
{text('children', 'Click here and select a file to see files logged.')}
</div>
</UploadField>
</WithNotes>
));
field.add('Triggers hover on children', () => {
const hoverColor = text('hover color', 'grey');
return (
<UploadField onFiles={action('files')}>
{hover => (
<div
style={{
backgroundColor: hover ? hoverColor : 'white',
}}
>
{text(
'children',
'Click here and select a file to see files logged.'
)}
</div>
)}
</UploadField>
);
});
const uploader = storiesOf('Uploader', module);
uploader.addDecorator(withKnobs);
uploader.add('Renders', () => {
const uploadOnSelection = boolean('uploadOnSelection', false);
return (
<Uploader
request={{
url: text('url', 'https://google.com'),
method: text('Method', 'POST'),
fields: {
full_name: 'Testing extra fields',
},
headers: {
Authorization: text('Authorization Header', 'Bearer: Blah'),
},
}}
uploadOnSelection={uploadOnSelection}
>
{({ onFiles, startUpload, progress, complete, canceled, failed }) => (
<div>
<UploadField onFiles={onFiles}>
<div>
{text('children', 'Click here and select a file!')}
</div>
</UploadField>
{progress ? `Progress: ${progress}` : null}
{complete ? 'Complete!' : null}
{canceled ? 'Canceled!' : null}
{failed ? 'Failed!' : null}
{uploadOnSelection
? null
: <div onClick={startUpload}>Upload Files</div>}
</div>
)}
</Uploader>
);
});