@comicrelief/component-library 8.13.6 → 8.13.7
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/.github/workflows/main.yml +1 -1
- package/dist/components/Molecules/SingleMessage/SingleMessage.js +26 -22
- package/dist/components/Molecules/SingleMessage/SingleMessage.md +19 -7
- package/dist/components/Molecules/SingleMessage/_ExampleYoutubeIds.js +8 -0
- package/package.json +1 -1
- package/src/components/Molecules/SingleMessage/SingleMessage.js +29 -27
- package/src/components/Molecules/SingleMessage/SingleMessage.md +19 -7
- package/src/components/Molecules/SingleMessage/_ExampleYoutubeIds.js +10 -0
|
@@ -34,7 +34,7 @@ const SingleMessage = _ref => {
|
|
|
34
34
|
} = _ref;
|
|
35
35
|
const hasImage = imageSet || false;
|
|
36
36
|
const doubleImage = (imageSet || image) && (imageSet2 || image2);
|
|
37
|
-
const hasVideo =
|
|
37
|
+
const hasVideo = Boolean(videoID !== null && videoID !== '');
|
|
38
38
|
|
|
39
39
|
// States to track video status
|
|
40
40
|
const [isInitialised, setIsInitialised] = (0, _react.useState)(false);
|
|
@@ -46,22 +46,33 @@ const SingleMessage = _ref => {
|
|
|
46
46
|
const thisRef = (0, _react.useRef)(null);
|
|
47
47
|
const isIOS = typeof navigator === 'object' ? /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream && !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform) : false;
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
setUniqueID(thisVideoID);
|
|
55
|
-
return /*#__PURE__*/_react.default.createElement(_SingleMessage.VideoWrapper, {
|
|
56
|
-
isPlaying: isPlaying,
|
|
57
|
-
isBuffering: isBuffering,
|
|
58
|
-
key: thisVideoID,
|
|
59
|
-
landscapeVideo: landscapeVideo
|
|
60
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
61
|
-
id: thisVideoID
|
|
62
|
-
}));
|
|
49
|
+
/* Dynamically retrieve ID that Gatsby has already baked into the page,
|
|
50
|
+
need to null check for initial render */
|
|
51
|
+
const getID = refWithID => {
|
|
52
|
+
const thisID = refWithID !== null ? refWithID.getAttribute('id') : null;
|
|
53
|
+
return thisID;
|
|
63
54
|
};
|
|
64
55
|
|
|
56
|
+
// Create the id string for the youtube video
|
|
57
|
+
(0, _react.useEffect)(() => {
|
|
58
|
+
if (thisRef.current) {
|
|
59
|
+
const thisID = getID(thisRef.current);
|
|
60
|
+
if (thisID) {
|
|
61
|
+
setUniqueID("".concat(thisID, "__video"));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}, [thisRef]);
|
|
65
|
+
|
|
66
|
+
// Break-out video markup into its own function
|
|
67
|
+
const renderVideoPlayers = () => /*#__PURE__*/_react.default.createElement(_SingleMessage.VideoWrapper, {
|
|
68
|
+
isPlaying: isPlaying,
|
|
69
|
+
isBuffering: isBuffering,
|
|
70
|
+
key: uniqueID,
|
|
71
|
+
landscapeVideo: landscapeVideo
|
|
72
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
73
|
+
id: uniqueID
|
|
74
|
+
}));
|
|
75
|
+
|
|
65
76
|
/* Waiting on a usable ref from render before setting our flag used in other functions */
|
|
66
77
|
(0, _react.useEffect)(() => {
|
|
67
78
|
setHasParentID(true);
|
|
@@ -100,13 +111,6 @@ const SingleMessage = _ref => {
|
|
|
100
111
|
}, 1000);
|
|
101
112
|
setIsBuffering(true);
|
|
102
113
|
};
|
|
103
|
-
|
|
104
|
-
/* Dynamically retrieve ID that Gatsby has already baked into the page,
|
|
105
|
-
need to null check for initial render */
|
|
106
|
-
const getID = refWithID => {
|
|
107
|
-
const thisID = refWithID !== null ? refWithID.getAttribute('id') : null;
|
|
108
|
-
return thisID;
|
|
109
|
-
};
|
|
110
114
|
return (
|
|
111
115
|
/*#__PURE__*/
|
|
112
116
|
// Creates namespaced UUIDs for each row
|
|
@@ -124,7 +124,7 @@ import Text from '../../Atoms/Text/Text';
|
|
|
124
124
|
</SingleMessage>;
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
-
Single Message with no Image - no top and bottom padding
|
|
127
|
+
Single Message with no Image - no top and bottom padding
|
|
128
128
|
|
|
129
129
|
```js
|
|
130
130
|
import Text from '../../Atoms/Text/Text';
|
|
@@ -184,13 +184,15 @@ Single Message with 16:9 video
|
|
|
184
184
|
```js
|
|
185
185
|
import Text from '../../Atoms/Text/Text';
|
|
186
186
|
const defaultData = require('../../../styleguide/data/data').defaultData;
|
|
187
|
+
import exampleYoutubeIds from './_ExampleYoutubeIds.js';
|
|
188
|
+
|
|
187
189
|
<SingleMessage
|
|
188
190
|
backgroundColor="purple"
|
|
189
191
|
imageSet={defaultData.images}
|
|
190
192
|
image={defaultData.image}
|
|
191
193
|
imageAltText=""
|
|
192
194
|
copyFirst={true}
|
|
193
|
-
videoID=
|
|
195
|
+
videoID={exampleYoutubeIds[0]}
|
|
194
196
|
landscapeVideo
|
|
195
197
|
>
|
|
196
198
|
<Text tag="p" color="black" size="xxl">
|
|
@@ -202,13 +204,15 @@ const defaultData = require('../../../styleguide/data/data').defaultData;
|
|
|
202
204
|
```js
|
|
203
205
|
import Text from '../../Atoms/Text/Text';
|
|
204
206
|
const defaultData = require('../../../styleguide/data/data').defaultData;
|
|
207
|
+
import exampleYoutubeIds from './_ExampleYoutubeIds.js';
|
|
208
|
+
|
|
205
209
|
<SingleMessage
|
|
206
210
|
backgroundColor="purple"
|
|
207
211
|
imageSet={defaultData.images}
|
|
208
212
|
image={defaultData.image}
|
|
209
213
|
imageAltText=""
|
|
210
214
|
copyFirst={false}
|
|
211
|
-
videoID=
|
|
215
|
+
videoID={exampleYoutubeIds[1]}
|
|
212
216
|
landscapeVideo
|
|
213
217
|
>
|
|
214
218
|
<Text tag="p" color="black" size="xxl">
|
|
@@ -222,13 +226,15 @@ Single Message with portrait video
|
|
|
222
226
|
```js
|
|
223
227
|
import Text from '../../Atoms/Text/Text';
|
|
224
228
|
const defaultData = require('../../../styleguide/data/data').defaultData;
|
|
229
|
+
import exampleYoutubeIds from './_ExampleYoutubeIds.js';
|
|
230
|
+
|
|
225
231
|
<SingleMessage
|
|
226
232
|
backgroundColor="purple"
|
|
227
233
|
imageSet={defaultData.images}
|
|
228
234
|
image={defaultData.image}
|
|
229
235
|
imageAltText=""
|
|
230
236
|
copyFirst={true}
|
|
231
|
-
videoID=
|
|
237
|
+
videoID={exampleYoutubeIds[2]}
|
|
232
238
|
>
|
|
233
239
|
<Text tag="p" color="black" size="xxl">
|
|
234
240
|
Single Message with portrait video
|
|
@@ -240,14 +246,16 @@ Single Message with portrait video, 100VH
|
|
|
240
246
|
|
|
241
247
|
```js
|
|
242
248
|
import Text from '../../Atoms/Text/Text';
|
|
249
|
+
import exampleYoutubeIds from './_ExampleYoutubeIds.js';
|
|
243
250
|
const defaultData = require('../../../styleguide/data/data').defaultData;
|
|
251
|
+
|
|
244
252
|
<SingleMessage
|
|
245
253
|
backgroundColor="purple"
|
|
246
254
|
imageSet={defaultData.images}
|
|
247
255
|
image={defaultData.image}
|
|
248
256
|
imageAltText=""
|
|
249
257
|
copyFirst={true}
|
|
250
|
-
videoID=
|
|
258
|
+
videoID={exampleYoutubeIds[3]}
|
|
251
259
|
vhFull
|
|
252
260
|
>
|
|
253
261
|
<Text tag="p" color="black" size="xxl">
|
|
@@ -261,13 +269,15 @@ Single Message with landscape video, 100VH, fullwidth image
|
|
|
261
269
|
```js
|
|
262
270
|
import Text from '../../Atoms/Text/Text';
|
|
263
271
|
const defaultData = require('../../../styleguide/data/data').defaultData;
|
|
272
|
+
import exampleYoutubeIds from './_ExampleYoutubeIds.js';
|
|
273
|
+
|
|
264
274
|
<SingleMessage
|
|
265
275
|
backgroundColor="purple"
|
|
266
276
|
imageSet={defaultData.images}
|
|
267
277
|
image={defaultData.image}
|
|
268
278
|
imageAltText=""
|
|
269
279
|
copyFirst={true}
|
|
270
|
-
videoID=
|
|
280
|
+
videoID={exampleYoutubeIds[4]}
|
|
271
281
|
vhFull
|
|
272
282
|
fullImage={true}
|
|
273
283
|
>
|
|
@@ -283,13 +293,15 @@ Single Message with landscape video, 50VH, fullwidth image
|
|
|
283
293
|
```js
|
|
284
294
|
import Text from '../../Atoms/Text/Text';
|
|
285
295
|
const defaultData = require('../../../styleguide/data/data').defaultData;
|
|
296
|
+
import exampleYoutubeIds from './_ExampleYoutubeIds.js';
|
|
297
|
+
|
|
286
298
|
<SingleMessage
|
|
287
299
|
backgroundColor="purple"
|
|
288
300
|
imageSet={defaultData.images}
|
|
289
301
|
image={defaultData.image}
|
|
290
302
|
imageAltText=""
|
|
291
303
|
copyFirst={true}
|
|
292
|
-
videoID=
|
|
304
|
+
videoID={exampleYoutubeIds[5]}
|
|
293
305
|
fullImage={true}
|
|
294
306
|
>
|
|
295
307
|
<Text tag="p" color="black" size="xxl">
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const exampleYoutubeIds = ['fwCQRMlKBnA', 'ZlGgFEDYKlY', 'yKADOGvq1Hs', 'Il9jhN2-PMA', 'So-GyrcQtK8', 'DjTmbU9nZNk'];
|
|
8
|
+
var _default = exports.default = exampleYoutubeIds;
|
package/package.json
CHANGED
|
@@ -35,7 +35,7 @@ const SingleMessage = ({
|
|
|
35
35
|
}) => {
|
|
36
36
|
const hasImage = imageSet || false;
|
|
37
37
|
const doubleImage = (imageSet || image) && (imageSet2 || image2);
|
|
38
|
-
const hasVideo =
|
|
38
|
+
const hasVideo = Boolean(videoID !== null && videoID !== '');
|
|
39
39
|
|
|
40
40
|
// States to track video status
|
|
41
41
|
const [isInitialised, setIsInitialised] = useState(false);
|
|
@@ -54,26 +54,36 @@ const SingleMessage = ({
|
|
|
54
54
|
&& /iPad|iPhone|iPod/.test(navigator.platform)
|
|
55
55
|
: false;
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
setUniqueID(thisVideoID);
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<VideoWrapper
|
|
67
|
-
isPlaying={isPlaying}
|
|
68
|
-
isBuffering={isBuffering}
|
|
69
|
-
key={thisVideoID}
|
|
70
|
-
landscapeVideo={landscapeVideo}
|
|
71
|
-
>
|
|
72
|
-
<div id={thisVideoID} />
|
|
73
|
-
</VideoWrapper>
|
|
74
|
-
);
|
|
57
|
+
/* Dynamically retrieve ID that Gatsby has already baked into the page,
|
|
58
|
+
need to null check for initial render */
|
|
59
|
+
const getID = refWithID => {
|
|
60
|
+
const thisID = refWithID !== null ? refWithID.getAttribute('id') : null;
|
|
61
|
+
|
|
62
|
+
return thisID;
|
|
75
63
|
};
|
|
76
64
|
|
|
65
|
+
// Create the id string for the youtube video
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (thisRef.current) {
|
|
68
|
+
const thisID = getID(thisRef.current);
|
|
69
|
+
if (thisID) {
|
|
70
|
+
setUniqueID(`${thisID}__video`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}, [thisRef]);
|
|
74
|
+
|
|
75
|
+
// Break-out video markup into its own function
|
|
76
|
+
const renderVideoPlayers = () => (
|
|
77
|
+
<VideoWrapper
|
|
78
|
+
isPlaying={isPlaying}
|
|
79
|
+
isBuffering={isBuffering}
|
|
80
|
+
key={uniqueID}
|
|
81
|
+
landscapeVideo={landscapeVideo}
|
|
82
|
+
>
|
|
83
|
+
<div id={uniqueID} />
|
|
84
|
+
</VideoWrapper>
|
|
85
|
+
);
|
|
86
|
+
|
|
77
87
|
/* Waiting on a usable ref from render before setting our flag used in other functions */
|
|
78
88
|
useEffect(() => {
|
|
79
89
|
setHasParentID(true);
|
|
@@ -115,14 +125,6 @@ const SingleMessage = ({
|
|
|
115
125
|
setIsBuffering(true);
|
|
116
126
|
};
|
|
117
127
|
|
|
118
|
-
/* Dynamically retrieve ID that Gatsby has already baked into the page,
|
|
119
|
-
need to null check for initial render */
|
|
120
|
-
const getID = refWithID => {
|
|
121
|
-
const thisID = refWithID !== null ? refWithID.getAttribute('id') : null;
|
|
122
|
-
|
|
123
|
-
return thisID;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
128
|
return (
|
|
127
129
|
// Creates namespaced UUIDs for each row
|
|
128
130
|
<UID name={id => `single-msg__${id}`}>
|
|
@@ -124,7 +124,7 @@ import Text from '../../Atoms/Text/Text';
|
|
|
124
124
|
</SingleMessage>;
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
-
Single Message with no Image - no top and bottom padding
|
|
127
|
+
Single Message with no Image - no top and bottom padding
|
|
128
128
|
|
|
129
129
|
```js
|
|
130
130
|
import Text from '../../Atoms/Text/Text';
|
|
@@ -184,13 +184,15 @@ Single Message with 16:9 video
|
|
|
184
184
|
```js
|
|
185
185
|
import Text from '../../Atoms/Text/Text';
|
|
186
186
|
const defaultData = require('../../../styleguide/data/data').defaultData;
|
|
187
|
+
import exampleYoutubeIds from './_ExampleYoutubeIds.js';
|
|
188
|
+
|
|
187
189
|
<SingleMessage
|
|
188
190
|
backgroundColor="purple"
|
|
189
191
|
imageSet={defaultData.images}
|
|
190
192
|
image={defaultData.image}
|
|
191
193
|
imageAltText=""
|
|
192
194
|
copyFirst={true}
|
|
193
|
-
videoID=
|
|
195
|
+
videoID={exampleYoutubeIds[0]}
|
|
194
196
|
landscapeVideo
|
|
195
197
|
>
|
|
196
198
|
<Text tag="p" color="black" size="xxl">
|
|
@@ -202,13 +204,15 @@ const defaultData = require('../../../styleguide/data/data').defaultData;
|
|
|
202
204
|
```js
|
|
203
205
|
import Text from '../../Atoms/Text/Text';
|
|
204
206
|
const defaultData = require('../../../styleguide/data/data').defaultData;
|
|
207
|
+
import exampleYoutubeIds from './_ExampleYoutubeIds.js';
|
|
208
|
+
|
|
205
209
|
<SingleMessage
|
|
206
210
|
backgroundColor="purple"
|
|
207
211
|
imageSet={defaultData.images}
|
|
208
212
|
image={defaultData.image}
|
|
209
213
|
imageAltText=""
|
|
210
214
|
copyFirst={false}
|
|
211
|
-
videoID=
|
|
215
|
+
videoID={exampleYoutubeIds[1]}
|
|
212
216
|
landscapeVideo
|
|
213
217
|
>
|
|
214
218
|
<Text tag="p" color="black" size="xxl">
|
|
@@ -222,13 +226,15 @@ Single Message with portrait video
|
|
|
222
226
|
```js
|
|
223
227
|
import Text from '../../Atoms/Text/Text';
|
|
224
228
|
const defaultData = require('../../../styleguide/data/data').defaultData;
|
|
229
|
+
import exampleYoutubeIds from './_ExampleYoutubeIds.js';
|
|
230
|
+
|
|
225
231
|
<SingleMessage
|
|
226
232
|
backgroundColor="purple"
|
|
227
233
|
imageSet={defaultData.images}
|
|
228
234
|
image={defaultData.image}
|
|
229
235
|
imageAltText=""
|
|
230
236
|
copyFirst={true}
|
|
231
|
-
videoID=
|
|
237
|
+
videoID={exampleYoutubeIds[2]}
|
|
232
238
|
>
|
|
233
239
|
<Text tag="p" color="black" size="xxl">
|
|
234
240
|
Single Message with portrait video
|
|
@@ -240,14 +246,16 @@ Single Message with portrait video, 100VH
|
|
|
240
246
|
|
|
241
247
|
```js
|
|
242
248
|
import Text from '../../Atoms/Text/Text';
|
|
249
|
+
import exampleYoutubeIds from './_ExampleYoutubeIds.js';
|
|
243
250
|
const defaultData = require('../../../styleguide/data/data').defaultData;
|
|
251
|
+
|
|
244
252
|
<SingleMessage
|
|
245
253
|
backgroundColor="purple"
|
|
246
254
|
imageSet={defaultData.images}
|
|
247
255
|
image={defaultData.image}
|
|
248
256
|
imageAltText=""
|
|
249
257
|
copyFirst={true}
|
|
250
|
-
videoID=
|
|
258
|
+
videoID={exampleYoutubeIds[3]}
|
|
251
259
|
vhFull
|
|
252
260
|
>
|
|
253
261
|
<Text tag="p" color="black" size="xxl">
|
|
@@ -261,13 +269,15 @@ Single Message with landscape video, 100VH, fullwidth image
|
|
|
261
269
|
```js
|
|
262
270
|
import Text from '../../Atoms/Text/Text';
|
|
263
271
|
const defaultData = require('../../../styleguide/data/data').defaultData;
|
|
272
|
+
import exampleYoutubeIds from './_ExampleYoutubeIds.js';
|
|
273
|
+
|
|
264
274
|
<SingleMessage
|
|
265
275
|
backgroundColor="purple"
|
|
266
276
|
imageSet={defaultData.images}
|
|
267
277
|
image={defaultData.image}
|
|
268
278
|
imageAltText=""
|
|
269
279
|
copyFirst={true}
|
|
270
|
-
videoID=
|
|
280
|
+
videoID={exampleYoutubeIds[4]}
|
|
271
281
|
vhFull
|
|
272
282
|
fullImage={true}
|
|
273
283
|
>
|
|
@@ -283,13 +293,15 @@ Single Message with landscape video, 50VH, fullwidth image
|
|
|
283
293
|
```js
|
|
284
294
|
import Text from '../../Atoms/Text/Text';
|
|
285
295
|
const defaultData = require('../../../styleguide/data/data').defaultData;
|
|
296
|
+
import exampleYoutubeIds from './_ExampleYoutubeIds.js';
|
|
297
|
+
|
|
286
298
|
<SingleMessage
|
|
287
299
|
backgroundColor="purple"
|
|
288
300
|
imageSet={defaultData.images}
|
|
289
301
|
image={defaultData.image}
|
|
290
302
|
imageAltText=""
|
|
291
303
|
copyFirst={true}
|
|
292
|
-
videoID=
|
|
304
|
+
videoID={exampleYoutubeIds[5]}
|
|
293
305
|
fullImage={true}
|
|
294
306
|
>
|
|
295
307
|
<Text tag="p" color="black" size="xxl">
|