@performant-software/semantic-components 0.5.16-beta.0 → 0.5.16-beta.3
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 +8 -0
- package/package.json +4 -6
- package/src/components/AudioPlayer.js +40 -22
- package/src/components/DownloadButton.js +63 -12
- package/src/components/IIIFModal.js +26 -0
- package/src/components/LazyAudio.js +31 -4
- package/src/components/LazyDocument.js +20 -6
- package/src/components/LazyIIIF.js +44 -0
- package/src/components/LazyImage.js +32 -5
- package/src/components/LazyLoader.css +7 -0
- package/src/components/LazyLoader.js +28 -0
- package/src/components/LazyMedia.js +243 -0
- package/src/components/LazyVideo.js +40 -5
- package/src/components/PhotoViewer.js +38 -25
- package/src/components/VideoPlayer.js +23 -2
- package/src/i18n/en.json +33 -6
- package/src/index.js +3 -0
- package/types/components/AudioPlayer.js.flow +40 -22
- package/types/components/DownloadButton.js.flow +63 -12
- package/types/components/IIIFModal.js.flow +26 -0
- package/types/components/LazyAudio.js.flow +31 -4
- package/types/components/LazyDocument.js.flow +20 -6
- package/types/components/LazyIIIF.js.flow +44 -0
- package/types/components/LazyImage.js.flow +32 -5
- package/types/components/LazyLoader.js.flow +28 -0
- package/types/components/LazyMedia.js.flow +243 -0
- package/types/components/LazyVideo.js.flow +40 -5
- package/types/components/PhotoViewer.js.flow +38 -25
- package/types/components/VideoPlayer.js.flow +23 -2
- package/types/index.js.flow +3 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
import React, {
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
useState,
|
|
8
|
+
type ComponentType,
|
|
9
|
+
type Node
|
|
10
|
+
} from 'react';
|
|
11
|
+
import { Icon } from 'semantic-ui-react';
|
|
12
|
+
import { Trans } from 'react-i18next';
|
|
13
|
+
import _ from 'underscore';
|
|
14
|
+
import FileInputButton from './FileInputButton';
|
|
15
|
+
import i18n from '../i18n/i18n';
|
|
16
|
+
import LazyAudio from './LazyAudio';
|
|
17
|
+
import LazyDocument from './LazyDocument';
|
|
18
|
+
import LazyImage from './LazyImage';
|
|
19
|
+
import LazyVideo from './LazyVideo';
|
|
20
|
+
|
|
21
|
+
type Props = {
|
|
22
|
+
children?: Node,
|
|
23
|
+
contentType: string,
|
|
24
|
+
dimmable?: boolean,
|
|
25
|
+
downloadUrl?: string,
|
|
26
|
+
name?: string,
|
|
27
|
+
onUpload: (file: File) => void,
|
|
28
|
+
preview?: string,
|
|
29
|
+
size?: string,
|
|
30
|
+
src?: string
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const ContentTypes = {
|
|
34
|
+
audio: 'audio',
|
|
35
|
+
image: 'image',
|
|
36
|
+
pdf: 'application/pdf',
|
|
37
|
+
video: 'video'
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const WebContentTypes = [
|
|
41
|
+
'image/png',
|
|
42
|
+
'image/jpeg',
|
|
43
|
+
'image/gif',
|
|
44
|
+
'image/webp',
|
|
45
|
+
'image/bmp',
|
|
46
|
+
'video/m4v',
|
|
47
|
+
'video/mp4'
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
const LazyMedia: ComponentType<any> = (props: Props) => {
|
|
51
|
+
const [contentType, setContentType] = useState(props.contentType || '');
|
|
52
|
+
const [name, setName] = useState(props.name);
|
|
53
|
+
const [preview, setPreview] = useState(props.preview);
|
|
54
|
+
const [source, setSource] = useState(props.src);
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Sets the file extension based on the name.
|
|
58
|
+
*
|
|
59
|
+
* @type {*}
|
|
60
|
+
*/
|
|
61
|
+
const fileExtension = useMemo(() => {
|
|
62
|
+
let value;
|
|
63
|
+
|
|
64
|
+
if (name) {
|
|
65
|
+
value = name.split('.').pop();
|
|
66
|
+
value = value && value.toUpperCase();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return value;
|
|
70
|
+
}, [name]);
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Sets the content type, name, preview, and source attributes. Also calls the onUpload prop.
|
|
74
|
+
*
|
|
75
|
+
* @type {(function(*): void)|*}
|
|
76
|
+
*/
|
|
77
|
+
const onUpload = useCallback((files) => {
|
|
78
|
+
const file = _.first(files);
|
|
79
|
+
|
|
80
|
+
setContentType(file.type);
|
|
81
|
+
setName(file.name);
|
|
82
|
+
setPreview(null);
|
|
83
|
+
|
|
84
|
+
if (_.contains(WebContentTypes, file.type)
|
|
85
|
+
|| file.type.startsWith(ContentTypes.audio)
|
|
86
|
+
|| file.type === ContentTypes.pdf) {
|
|
87
|
+
setSource(URL.createObjectURL(file));
|
|
88
|
+
} else {
|
|
89
|
+
setSource(null);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
props.onUpload(file);
|
|
93
|
+
}, [props.onUpload]);
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Renders the child buttons.
|
|
97
|
+
*
|
|
98
|
+
* @type {unknown}
|
|
99
|
+
*/
|
|
100
|
+
const renderChildren = useCallback(() => (
|
|
101
|
+
<>
|
|
102
|
+
{ props.onUpload && (
|
|
103
|
+
<FileInputButton
|
|
104
|
+
color='orange'
|
|
105
|
+
content={i18n.t('Common.buttons.upload')}
|
|
106
|
+
icon='cloud upload'
|
|
107
|
+
onSelection={onUpload}
|
|
108
|
+
/>
|
|
109
|
+
)}
|
|
110
|
+
{ props.children }
|
|
111
|
+
</>
|
|
112
|
+
));
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Renders the media component.
|
|
116
|
+
*
|
|
117
|
+
* @type {(function(): *)|*}
|
|
118
|
+
*/
|
|
119
|
+
const renderMedia = useCallback(() => {
|
|
120
|
+
if (contentType.startsWith(ContentTypes.image)) {
|
|
121
|
+
return (
|
|
122
|
+
<LazyImage
|
|
123
|
+
dimmable={props.dimmable}
|
|
124
|
+
download={props.downloadUrl}
|
|
125
|
+
preview={preview}
|
|
126
|
+
src={source}
|
|
127
|
+
size={props.size}
|
|
128
|
+
>
|
|
129
|
+
{ renderChildren() }
|
|
130
|
+
</LazyImage>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (contentType.startsWith(ContentTypes.video)) {
|
|
135
|
+
return (
|
|
136
|
+
<LazyVideo
|
|
137
|
+
dimmable={props.dimmable}
|
|
138
|
+
download={props.downloadUrl}
|
|
139
|
+
preview={preview}
|
|
140
|
+
src={source}
|
|
141
|
+
size={props.size}
|
|
142
|
+
>
|
|
143
|
+
{ renderChildren() }
|
|
144
|
+
</LazyVideo>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (contentType.startsWith(ContentTypes.audio)) {
|
|
149
|
+
return (
|
|
150
|
+
<LazyAudio
|
|
151
|
+
dimmable={props.dimmable}
|
|
152
|
+
download={props.downloadUrl}
|
|
153
|
+
preview={preview}
|
|
154
|
+
src={source}
|
|
155
|
+
size={props.size}
|
|
156
|
+
>
|
|
157
|
+
{ renderChildren() }
|
|
158
|
+
</LazyAudio>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<LazyDocument
|
|
164
|
+
dimmable={props.dimmable}
|
|
165
|
+
pdf={contentType === ContentTypes.pdf}
|
|
166
|
+
preview={preview}
|
|
167
|
+
src={source}
|
|
168
|
+
size={props.size}
|
|
169
|
+
>
|
|
170
|
+
{ renderChildren() }
|
|
171
|
+
</LazyDocument>
|
|
172
|
+
);
|
|
173
|
+
}, [contentType, preview, source, props.dimmable, props.downloadUrl, props.size]);
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Renders the upload message.
|
|
177
|
+
*
|
|
178
|
+
* @type {(function(): (null|*))|*}
|
|
179
|
+
*/
|
|
180
|
+
const renderMessage = useCallback(() => {
|
|
181
|
+
if (!fileExtension) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<div>
|
|
187
|
+
<Icon
|
|
188
|
+
name='info circle'
|
|
189
|
+
/>
|
|
190
|
+
<span>
|
|
191
|
+
<Trans
|
|
192
|
+
components={{ bold: <strong /> }}
|
|
193
|
+
default='Your <bold>{{type}}</bold> has been received'
|
|
194
|
+
i18n={i18n}
|
|
195
|
+
i18nKey='LazyMedia.messages.uploaded'
|
|
196
|
+
values={{
|
|
197
|
+
type: fileExtension
|
|
198
|
+
}}
|
|
199
|
+
/>
|
|
200
|
+
</span>
|
|
201
|
+
</div>
|
|
202
|
+
);
|
|
203
|
+
}, [fileExtension]);
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Sets the content type, name, preview, and source.
|
|
207
|
+
*/
|
|
208
|
+
useEffect(() => {
|
|
209
|
+
if (props.contentType) {
|
|
210
|
+
setContentType(props.contentType);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (props.name) {
|
|
214
|
+
setName(props.name);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (props.preview) {
|
|
218
|
+
setPreview(props.preview);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (props.src) {
|
|
222
|
+
setSource(props.src);
|
|
223
|
+
} else {
|
|
224
|
+
setSource(null);
|
|
225
|
+
}
|
|
226
|
+
}, [props.contentType, props.name, props.preview, props.src]);
|
|
227
|
+
|
|
228
|
+
return (
|
|
229
|
+
<div
|
|
230
|
+
className='lazy-media'
|
|
231
|
+
>
|
|
232
|
+
{ renderMedia() }
|
|
233
|
+
{ renderMessage() }
|
|
234
|
+
</div>
|
|
235
|
+
);
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
LazyMedia.defaultProps = {
|
|
239
|
+
dimmable: true,
|
|
240
|
+
size: 'medium'
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
export default LazyMedia;
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
Visibility
|
|
13
13
|
} from 'semantic-ui-react';
|
|
14
14
|
import i18n from '../i18n/i18n';
|
|
15
|
+
import DownloadButton from './DownloadButton';
|
|
16
|
+
import LazyLoader from './LazyLoader';
|
|
15
17
|
import VideoPlayer from './VideoPlayer';
|
|
16
18
|
import './LazyVideo.css';
|
|
17
19
|
|
|
@@ -19,19 +21,23 @@ type Props = {
|
|
|
19
21
|
autoPlay?: boolean,
|
|
20
22
|
children?: Node,
|
|
21
23
|
dimmable: boolean,
|
|
24
|
+
download?: string,
|
|
22
25
|
duration?: number,
|
|
23
26
|
embedded?: boolean,
|
|
24
27
|
icon?: string | Element<any>,
|
|
25
28
|
image?: any,
|
|
29
|
+
name?: string,
|
|
26
30
|
preview?: ?string,
|
|
27
31
|
size?: string,
|
|
28
32
|
src?: string
|
|
29
33
|
};
|
|
30
34
|
|
|
31
35
|
const LazyVideo = (props: Props) => {
|
|
32
|
-
const [visible, setVisible] = useState(false);
|
|
33
|
-
const [modal, setModal] = useState(false);
|
|
34
36
|
const [dimmer, setDimmer] = useState(false);
|
|
37
|
+
const [error, setError] = useState(false);
|
|
38
|
+
const [loaded, setLoaded] = useState(!(props.preview || props.src));
|
|
39
|
+
const [modal, setModal] = useState(false);
|
|
40
|
+
const [visible, setVisible] = useState(false);
|
|
35
41
|
|
|
36
42
|
if (!visible) {
|
|
37
43
|
return (
|
|
@@ -63,24 +69,46 @@ const LazyVideo = (props: Props) => {
|
|
|
63
69
|
onMouseEnter={() => setDimmer(true)}
|
|
64
70
|
onMouseLeave={() => setDimmer(false)}
|
|
65
71
|
>
|
|
66
|
-
{
|
|
72
|
+
{ !loaded && (
|
|
73
|
+
<LazyLoader
|
|
74
|
+
active
|
|
75
|
+
size={props.size}
|
|
76
|
+
/>
|
|
77
|
+
)}
|
|
78
|
+
{ !error && props.preview && (
|
|
67
79
|
<Image
|
|
68
80
|
{...props.image}
|
|
81
|
+
onError={() => {
|
|
82
|
+
setError(true);
|
|
83
|
+
setLoaded(true);
|
|
84
|
+
}}
|
|
85
|
+
onLoad={() => {
|
|
86
|
+
setError(false);
|
|
87
|
+
setLoaded(true);
|
|
88
|
+
}}
|
|
69
89
|
src={props.preview}
|
|
70
90
|
size={props.size}
|
|
71
91
|
/>
|
|
72
92
|
)}
|
|
73
|
-
{ !props.preview && props.src && (
|
|
93
|
+
{ !error && !props.preview && props.src && (
|
|
74
94
|
<Image
|
|
75
95
|
{...props.image}
|
|
76
96
|
size={props.size}
|
|
77
97
|
>
|
|
78
98
|
<video
|
|
99
|
+
onError={() => {
|
|
100
|
+
setError(true);
|
|
101
|
+
setLoaded(true);
|
|
102
|
+
}}
|
|
103
|
+
onLoadedData={() => {
|
|
104
|
+
setError(false);
|
|
105
|
+
setLoaded(true);
|
|
106
|
+
}}
|
|
79
107
|
src={props.src}
|
|
80
108
|
/>
|
|
81
109
|
</Image>
|
|
82
110
|
)}
|
|
83
|
-
{ !props.preview && !props.src && (
|
|
111
|
+
{ (error || (!props.preview && !props.src)) && (
|
|
84
112
|
<Image
|
|
85
113
|
{...props.image}
|
|
86
114
|
className='placeholder-image'
|
|
@@ -107,6 +135,13 @@ const LazyVideo = (props: Props) => {
|
|
|
107
135
|
primary
|
|
108
136
|
/>
|
|
109
137
|
)}
|
|
138
|
+
{ props.download && (
|
|
139
|
+
<DownloadButton
|
|
140
|
+
color='green'
|
|
141
|
+
filename={props.name}
|
|
142
|
+
url={props.download}
|
|
143
|
+
/>
|
|
144
|
+
)}
|
|
110
145
|
{ props.children }
|
|
111
146
|
</div>
|
|
112
147
|
</Dimmer>
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { Image, Modal } from 'semantic-ui-react';
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
|
+
import { Image, Message, Modal } from 'semantic-ui-react';
|
|
5
5
|
import ModalContext from '../context/ModalContext';
|
|
6
6
|
import './PhotoViewer.css';
|
|
7
|
+
import i18n from '../i18n/i18n';
|
|
7
8
|
|
|
8
9
|
type Props = {
|
|
9
10
|
alt?: string,
|
|
@@ -13,29 +14,41 @@ type Props = {
|
|
|
13
14
|
size?: string
|
|
14
15
|
};
|
|
15
16
|
|
|
16
|
-
const PhotoViewer = (props: Props) =>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
)
|
|
17
|
+
const PhotoViewer = (props: Props) => {
|
|
18
|
+
const [error, setError] = useState(false);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<ModalContext.Consumer>
|
|
22
|
+
{(mountNode) => (
|
|
23
|
+
<Modal
|
|
24
|
+
centered={false}
|
|
25
|
+
className='photo-viewer'
|
|
26
|
+
closeIcon
|
|
27
|
+
mountNode={mountNode}
|
|
28
|
+
onClose={props.onClose.bind(this)}
|
|
29
|
+
open={props.open}
|
|
30
|
+
size={props.size}
|
|
31
|
+
>
|
|
32
|
+
<Modal.Content>
|
|
33
|
+
{ error && (
|
|
34
|
+
<Message
|
|
35
|
+
content={i18n.t('PhotoViewer.errors.path.content', { path: props.image })}
|
|
36
|
+
header={i18n.t('PhotoViewer.errors.path.header')}
|
|
37
|
+
icon='exclamation circle'
|
|
38
|
+
/>
|
|
39
|
+
)}
|
|
40
|
+
<Image
|
|
41
|
+
alt={props.alt}
|
|
42
|
+
fluid
|
|
43
|
+
onError={() => setError(true)}
|
|
44
|
+
src={props.image}
|
|
45
|
+
/>
|
|
46
|
+
</Modal.Content>
|
|
47
|
+
</Modal>
|
|
48
|
+
)}
|
|
49
|
+
</ModalContext.Consumer>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
39
52
|
|
|
40
53
|
PhotoViewer.defaultProps = {
|
|
41
54
|
size: 'small'
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
|
|
3
|
-
import React, {
|
|
4
|
-
|
|
3
|
+
import React, {
|
|
4
|
+
useEffect,
|
|
5
|
+
useRef,
|
|
6
|
+
useState,
|
|
7
|
+
type Element
|
|
8
|
+
} from 'react';
|
|
9
|
+
import {
|
|
10
|
+
Embed,
|
|
11
|
+
Message,
|
|
12
|
+
Modal,
|
|
13
|
+
Ref
|
|
14
|
+
} from 'semantic-ui-react';
|
|
5
15
|
import ModalContext from '../context/ModalContext';
|
|
6
16
|
import './VideoPlayer.css';
|
|
17
|
+
import i18n from '../i18n/i18n';
|
|
7
18
|
|
|
8
19
|
type Props = {
|
|
9
20
|
autoPlay?: boolean,
|
|
@@ -18,6 +29,8 @@ type Props = {
|
|
|
18
29
|
};
|
|
19
30
|
|
|
20
31
|
const VideoPlayer = (props: Props) => {
|
|
32
|
+
const [error, setError] = useState(false);
|
|
33
|
+
|
|
21
34
|
const embedRef = useRef();
|
|
22
35
|
|
|
23
36
|
/**
|
|
@@ -46,6 +59,13 @@ const VideoPlayer = (props: Props) => {
|
|
|
46
59
|
size={props.size}
|
|
47
60
|
>
|
|
48
61
|
<Modal.Content>
|
|
62
|
+
{ error && (
|
|
63
|
+
<Message
|
|
64
|
+
content={i18n.t('VideoPlayer.errors.path.content', { path: props.video })}
|
|
65
|
+
header={i18n.t('VideoPlayer.errors.path.header')}
|
|
66
|
+
icon='exclamation circle'
|
|
67
|
+
/>
|
|
68
|
+
)}
|
|
49
69
|
{ props.embedded && (
|
|
50
70
|
<Ref
|
|
51
71
|
innerRef={embedRef}
|
|
@@ -63,6 +83,7 @@ const VideoPlayer = (props: Props) => {
|
|
|
63
83
|
<video
|
|
64
84
|
autoPlay={props.autoPlay}
|
|
65
85
|
controls
|
|
86
|
+
onError={() => setError(true)}
|
|
66
87
|
src={props.video}
|
|
67
88
|
/>
|
|
68
89
|
)}
|
package/src/i18n/en.json
CHANGED
|
@@ -8,15 +8,26 @@
|
|
|
8
8
|
"AccordionSelector": {
|
|
9
9
|
"title": "Select Items"
|
|
10
10
|
},
|
|
11
|
+
"AudioPlayer": {
|
|
12
|
+
"errors": {
|
|
13
|
+
"path": {
|
|
14
|
+
"content": "Please check the audio path: {{path}}",
|
|
15
|
+
"header": "There was a problem loading the audio"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
11
19
|
"Common": {
|
|
12
20
|
"buttons": {
|
|
13
21
|
"add": "Add",
|
|
14
22
|
"cancel": "Cancel",
|
|
15
23
|
"clear": "Clear",
|
|
16
24
|
"close": "Close",
|
|
25
|
+
"download": "Download",
|
|
17
26
|
"edit": "Edit",
|
|
18
27
|
"ok": "OK",
|
|
19
|
-
"
|
|
28
|
+
"open": "Open",
|
|
29
|
+
"save": "Save",
|
|
30
|
+
"upload": "Upload"
|
|
20
31
|
},
|
|
21
32
|
"errors": {
|
|
22
33
|
"title": "Oops!"
|
|
@@ -140,16 +151,16 @@
|
|
|
140
151
|
"play": "Play"
|
|
141
152
|
}
|
|
142
153
|
},
|
|
143
|
-
"LazyDocument": {
|
|
144
|
-
"buttons": {
|
|
145
|
-
"download": "Download"
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
154
|
"LazyImage": {
|
|
149
155
|
"buttons": {
|
|
150
156
|
"view": "View image"
|
|
151
157
|
}
|
|
152
158
|
},
|
|
159
|
+
"LazyMedia": {
|
|
160
|
+
"messages": {
|
|
161
|
+
"uploaded": "Your <bold>{{type}}</bold> has been received"
|
|
162
|
+
}
|
|
163
|
+
},
|
|
153
164
|
"LazyVideo": {
|
|
154
165
|
"buttons": {
|
|
155
166
|
"play": "Play video"
|
|
@@ -198,6 +209,14 @@
|
|
|
198
209
|
"loginErrorHeader": "Invalid Credentials",
|
|
199
210
|
"password": "Password"
|
|
200
211
|
},
|
|
212
|
+
"PhotoViewer": {
|
|
213
|
+
"errors": {
|
|
214
|
+
"path": {
|
|
215
|
+
"content": "Please check the image path: {{path}}",
|
|
216
|
+
"header": "There was a problem loading the image"
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
},
|
|
201
220
|
"ReferenceCodeFormLabel": {
|
|
202
221
|
"content": "The values in this list can be edited via the {{name}} reference table."
|
|
203
222
|
},
|
|
@@ -245,6 +264,14 @@
|
|
|
245
264
|
},
|
|
246
265
|
"title": "Select Frame"
|
|
247
266
|
},
|
|
267
|
+
"VideoPlayer": {
|
|
268
|
+
"errors": {
|
|
269
|
+
"path": {
|
|
270
|
+
"content": "Please check the video path: {{path}}",
|
|
271
|
+
"header": "There was a problem loading the video"
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
},
|
|
248
275
|
"ViewXML": {
|
|
249
276
|
"buttons": {
|
|
250
277
|
"view": "View XML"
|
package/src/index.js
CHANGED
|
@@ -35,6 +35,7 @@ export { default as FuzzyDate } from './components/FuzzyDate';
|
|
|
35
35
|
export { default as GoogleMap } from './components/GoogleMap';
|
|
36
36
|
export { default as GooglePlacesSearch } from './components/GooglePlacesSearch';
|
|
37
37
|
export { default as HorizontalCards } from './components/HorizontalCards';
|
|
38
|
+
export { default as IIIFModal } from './components/IIIFModal';
|
|
38
39
|
export { default as ItemCollection } from './components/ItemCollection';
|
|
39
40
|
export { default as ItemList } from './components/ItemList';
|
|
40
41
|
export { default as Items } from './components/Items';
|
|
@@ -42,7 +43,9 @@ export { default as KeyboardField } from './components/KeyboardField';
|
|
|
42
43
|
export { default as KeyValuePairs } from './components/KeyValuePairs';
|
|
43
44
|
export { default as LazyAudio } from './components/LazyAudio';
|
|
44
45
|
export { default as LazyDocument } from './components/LazyDocument';
|
|
46
|
+
export { default as LazyIIIF } from './components/LazyIIIF';
|
|
45
47
|
export { default as LazyImage } from './components/LazyImage';
|
|
48
|
+
export { default as LazyMedia } from './components/LazyMedia';
|
|
46
49
|
export { default as LazyVideo } from './components/LazyVideo';
|
|
47
50
|
export { default as LinkButton } from './components/LinkButton';
|
|
48
51
|
export { default as ListFilters } from './components/ListFilters';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { Button, Modal } from 'semantic-ui-react';
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
|
+
import { Button, Message, Modal } from 'semantic-ui-react';
|
|
5
5
|
import i18n from '../i18n/i18n';
|
|
6
|
+
import ModalContext from '../context/ModalContext';
|
|
6
7
|
import './AudioPlayer.css';
|
|
7
8
|
|
|
8
9
|
type Props = {
|
|
@@ -12,25 +13,42 @@ type Props = {
|
|
|
12
13
|
src: string
|
|
13
14
|
};
|
|
14
15
|
|
|
15
|
-
const AudioPlayer = (props: Props) =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
)
|
|
16
|
+
const AudioPlayer = (props: Props) => {
|
|
17
|
+
const [error, setError] = useState(false);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<ModalContext.Consumer>
|
|
21
|
+
{(mountNode) => (
|
|
22
|
+
<Modal
|
|
23
|
+
centered={props.centered}
|
|
24
|
+
className='audio-player'
|
|
25
|
+
mountNode={mountNode}
|
|
26
|
+
open={props.open}
|
|
27
|
+
>
|
|
28
|
+
<Modal.Content>
|
|
29
|
+
{ error && (
|
|
30
|
+
<Message
|
|
31
|
+
content={i18n.t('AudioPlayer.errors.path.content', { path: props.src })}
|
|
32
|
+
header={i18n.t('AudioPlayer.errors.path.header')}
|
|
33
|
+
icon='exclamation circle'
|
|
34
|
+
/>
|
|
35
|
+
)}
|
|
36
|
+
<audio
|
|
37
|
+
controls
|
|
38
|
+
onError={() => setError(true)}
|
|
39
|
+
src={props.src}
|
|
40
|
+
/>
|
|
41
|
+
</Modal.Content>
|
|
42
|
+
<Modal.Actions>
|
|
43
|
+
<Button
|
|
44
|
+
content={i18n.t('Common.buttons.close')}
|
|
45
|
+
onClick={props.onClose}
|
|
46
|
+
/>
|
|
47
|
+
</Modal.Actions>
|
|
48
|
+
</Modal>
|
|
49
|
+
)}
|
|
50
|
+
</ModalContext.Consumer>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
35
53
|
|
|
36
54
|
export default AudioPlayer;
|