@performant-software/semantic-components 1.0.3 → 1.0.4-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/main.css +25 -0
- package/package.json +2 -2
- package/src/components/FileUploadModal.js +294 -319
- package/src/components/FileUploadProgress.css +24 -0
- package/src/components/FileUploadProgress.js +75 -0
- package/src/components/FileUploadStatus.css +3 -0
- package/src/components/FileUploadStatus.js +65 -0
- package/src/i18n/en.json +2 -1
- package/types/components/FileUploadModal.js.flow +294 -319
- package/types/components/FileUploadProgress.js.flow +75 -0
- package/types/components/FileUploadStatus.js.flow +65 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
.file-upload-progress {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.file-upload-progress > .progress-container {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
margin-left: 20px;
|
|
10
|
+
width: 100%;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.file-upload-progress > .progress-container > .ui.header {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: flex-end;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.file-upload-progress > .progress-container > .ui.header > .content {
|
|
19
|
+
margin-right: 40px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.file-upload-progress > .progress-container > .progress {
|
|
23
|
+
margin-bottom: 0;
|
|
24
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
import React, { useMemo, type ComponentType } from 'react';
|
|
4
|
+
import { Header, Icon, Progress } from 'semantic-ui-react';
|
|
5
|
+
import './FileUploadProgress.css';
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
completed: number,
|
|
9
|
+
total: number,
|
|
10
|
+
uploading?: boolean
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const FileUploadProgress: ComponentType<any> = (props: Props) => {
|
|
14
|
+
/**
|
|
15
|
+
* Sets the "complete" variable to "true" if the number of completed items is equal to the total and
|
|
16
|
+
* greater than zero.
|
|
17
|
+
*
|
|
18
|
+
* @type {unknown}
|
|
19
|
+
*/
|
|
20
|
+
const complete = useMemo(() => (
|
|
21
|
+
props.completed > 0 && props.completed === props.total
|
|
22
|
+
), [props.completed, props.total]);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Sets the percent of completed items.
|
|
26
|
+
*
|
|
27
|
+
* @type {number|number}
|
|
28
|
+
*/
|
|
29
|
+
const percent = useMemo(() => (
|
|
30
|
+
props.total > 0 ? (props.completed / props.total) : 0
|
|
31
|
+
), [props.completed, props.total]);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Sets the formatted percent view.
|
|
35
|
+
*/
|
|
36
|
+
const percentView = useMemo(() => (
|
|
37
|
+
Number(percent)
|
|
38
|
+
.toLocaleString(undefined, {
|
|
39
|
+
style: 'percent',
|
|
40
|
+
minimumFractionDigits: 0
|
|
41
|
+
})
|
|
42
|
+
), [percent]);
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<div
|
|
46
|
+
className='file-upload-progress'
|
|
47
|
+
>
|
|
48
|
+
<Icon
|
|
49
|
+
color='blue'
|
|
50
|
+
name='cloud upload'
|
|
51
|
+
size='big'
|
|
52
|
+
/>
|
|
53
|
+
<div
|
|
54
|
+
className='progress-container'
|
|
55
|
+
>
|
|
56
|
+
<Header>
|
|
57
|
+
<Header.Content
|
|
58
|
+
content={percentView}
|
|
59
|
+
/>
|
|
60
|
+
<Header.Subheader>
|
|
61
|
+
{ !(props.uploading || complete) && 'Getting Started' }
|
|
62
|
+
{ props.uploading && 'Uploading...' }
|
|
63
|
+
{ complete && 'Completed' }
|
|
64
|
+
</Header.Subheader>
|
|
65
|
+
</Header>
|
|
66
|
+
<Progress
|
|
67
|
+
color='blue'
|
|
68
|
+
percent={percent * 100}
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default FileUploadProgress;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
import React, { useMemo, type ComponentType } from 'react';
|
|
4
|
+
import { Icon, Label, Loader } from 'semantic-ui-react';
|
|
5
|
+
import './FileUploadStatus.css';
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
status: string
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const Status = {
|
|
12
|
+
pending: 'pending',
|
|
13
|
+
processing: 'processing',
|
|
14
|
+
complete: 'complete',
|
|
15
|
+
error: 'error'
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const ColorsByStatus = {
|
|
19
|
+
[Status.processing]: 'black',
|
|
20
|
+
[Status.complete]: 'green',
|
|
21
|
+
[Status.error]: 'red'
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const IconsByStatus = {
|
|
25
|
+
[Status.pending]: 'clock outline',
|
|
26
|
+
[Status.complete]: 'checkmark',
|
|
27
|
+
[Status.error]: 'warning circle'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const TextByStatus = {
|
|
31
|
+
[Status.pending]: 'Pending',
|
|
32
|
+
[Status.processing]: 'Processing',
|
|
33
|
+
[Status.complete]: 'Complete',
|
|
34
|
+
[Status.error]: 'Error'
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const FileUploadStatus: ComponentType<any> = ({ status = Status.pending }: Props) => {
|
|
38
|
+
const color = useMemo(() => ColorsByStatus[status], [status]);
|
|
39
|
+
const icon = useMemo(() => IconsByStatus[status], [status]);
|
|
40
|
+
const text = useMemo(() => TextByStatus[status], [status]);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Label
|
|
44
|
+
className='file-upload-status'
|
|
45
|
+
color={color}
|
|
46
|
+
>
|
|
47
|
+
{ status === Status.processing && (
|
|
48
|
+
<Loader
|
|
49
|
+
active
|
|
50
|
+
inline
|
|
51
|
+
inverted
|
|
52
|
+
size='mini'
|
|
53
|
+
/>
|
|
54
|
+
)}
|
|
55
|
+
{ icon && (
|
|
56
|
+
<Icon
|
|
57
|
+
name={icon}
|
|
58
|
+
/>
|
|
59
|
+
)}
|
|
60
|
+
{ text }
|
|
61
|
+
</Label>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default FileUploadStatus;
|
package/src/i18n/en.json
CHANGED
|
@@ -128,7 +128,8 @@
|
|
|
128
128
|
},
|
|
129
129
|
"FileUploadModal": {
|
|
130
130
|
"errors": {
|
|
131
|
-
"
|
|
131
|
+
"header": "There was an error processing your files",
|
|
132
|
+
"required": "File {{filename}} - The following fields are required: {{fields}}"
|
|
132
133
|
},
|
|
133
134
|
"loader": "Uploading files...",
|
|
134
135
|
"title": "Upload Files"
|