@comicrelief/component-library 7.21.0 → 7.22.0
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/dist/components/Molecules/Promo/Promo.js +87 -12
- package/dist/components/Molecules/Promo/Promo.md +266 -4
- package/dist/components/Molecules/Promo/Promo.style.js +24 -6
- package/dist/components/Molecules/Promo/Promo.test.js +2 -2
- package/dist/components/Molecules/Promo/_ProgressRing.js +57 -0
- package/dist/components/Molecules/Promo/_PromoVideo.js +116 -0
- package/dist/components/Molecules/Promo/_PromoVideoButton.js +31 -0
- package/dist/components/Molecules/Promo/_PromoVideoButton.style.js +110 -0
- package/dist/components/Molecules/Promo/assets/Pause--black.svg +3 -0
- package/dist/components/Molecules/Promo/assets/Pause--white.svg +3 -0
- package/dist/components/Molecules/Promo/assets/Play--black.svg +3 -0
- package/dist/components/Molecules/Promo/assets/Play--white.svg +3 -0
- package/dist/styleguide/assets/mobileVideoPosterImage.png +0 -0
- package/package.json +1 -1
- package/src/components/Molecules/Promo/Promo.js +89 -13
- package/src/components/Molecules/Promo/Promo.md +266 -4
- package/src/components/Molecules/Promo/Promo.style.js +23 -2
- package/src/components/Molecules/Promo/Promo.test.js +2 -2
- package/src/components/Molecules/Promo/_ProgressRing.js +43 -0
- package/src/components/Molecules/Promo/_PromoVideo.js +105 -0
- package/src/components/Molecules/Promo/_PromoVideoButton.js +26 -0
- package/src/components/Molecules/Promo/_PromoVideoButton.style.js +121 -0
- package/src/components/Molecules/Promo/assets/Pause--black.svg +3 -0
- package/src/components/Molecules/Promo/assets/Pause--white.svg +3 -0
- package/src/components/Molecules/Promo/assets/Play--black.svg +3 -0
- package/src/components/Molecules/Promo/assets/Play--white.svg +3 -0
- package/src/styleguide/assets/mobileVideoPosterImage.png +0 -0
|
@@ -7,28 +7,85 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
|
|
14
|
+
var _PromoVideo = _interopRequireDefault(require("./_PromoVideo"));
|
|
15
|
+
|
|
16
|
+
var _breakpoint = require("../../../theme/shared/breakpoint");
|
|
11
17
|
|
|
12
18
|
var _Picture = _interopRequireDefault(require("../../Atoms/Picture/Picture"));
|
|
13
19
|
|
|
14
20
|
var _Promo = require("./Promo.style");
|
|
15
21
|
|
|
22
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
|
+
|
|
24
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
+
|
|
16
26
|
var Promo = function Promo(_ref) {
|
|
17
|
-
var
|
|
27
|
+
var copyLeft = _ref.copyLeft,
|
|
18
28
|
backgroundColor = _ref.backgroundColor,
|
|
19
29
|
imageLow = _ref.imageLow,
|
|
20
30
|
imageSet = _ref.imageSet,
|
|
21
31
|
image = _ref.image,
|
|
22
32
|
imageAltText = _ref.imageAltText,
|
|
23
33
|
children = _ref.children,
|
|
24
|
-
position = _ref.position
|
|
25
|
-
|
|
34
|
+
position = _ref.position,
|
|
35
|
+
autoPlay = _ref.autoPlay,
|
|
36
|
+
loop = _ref.loop,
|
|
37
|
+
poster = _ref.poster,
|
|
38
|
+
mobilePoster = _ref.mobilePoster,
|
|
39
|
+
showPosterAfterPlaying = _ref.showPosterAfterPlaying,
|
|
40
|
+
videoSrc = _ref.videoSrc,
|
|
41
|
+
mobileVideoSrc = _ref.mobileVideoSrc,
|
|
42
|
+
lightColouredVideo = _ref.lightColouredVideo;
|
|
43
|
+
|
|
44
|
+
// Store the appropriate prop in state, dependent on the breakpoint
|
|
45
|
+
var _useState = (0, _react.useState)(null),
|
|
46
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
47
|
+
thisVideoSrc = _useState2[0],
|
|
48
|
+
setThisVideoSrc = _useState2[1];
|
|
49
|
+
|
|
50
|
+
var _useState3 = (0, _react.useState)(null),
|
|
51
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
52
|
+
thisPoster = _useState4[0],
|
|
53
|
+
setThisPoster = _useState4[1]; // Let either field define this, just in case
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
var hasVideo = Boolean(videoSrc || mobileVideoSrc); // A 'video-y' Promo will override and ignore any 'non-Video' images;
|
|
57
|
+
// none of these fields are required so we have to handle them accordingly:
|
|
58
|
+
|
|
59
|
+
var hasImage = Boolean(imageSet && !hasVideo); // Runs on initial load:
|
|
60
|
+
|
|
61
|
+
(0, _react.useEffect)(function () {
|
|
62
|
+
if (hasVideo) {
|
|
63
|
+
// Checks size on load ONLY; don't want to mess about with listeners:
|
|
64
|
+
var isDesktop = window.innerWidth >= _breakpoint.sizes.nav; // 1024+ px
|
|
65
|
+
|
|
66
|
+
var currentPoster;
|
|
67
|
+
var currentSrc; // If we've got both desktop AND mobile videos, let the
|
|
68
|
+
// *current* screen width define which video src to use:
|
|
69
|
+
|
|
70
|
+
if (videoSrc && mobileVideoSrc) {
|
|
71
|
+
currentSrc = isDesktop ? videoSrc : mobileVideoSrc;
|
|
72
|
+
currentPoster = isDesktop ? poster : mobilePoster;
|
|
73
|
+
} else {
|
|
74
|
+
// Else, pick whatever we DO actually have:
|
|
75
|
+
currentSrc = videoSrc || mobileVideoSrc;
|
|
76
|
+
currentPoster = poster || mobilePoster;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
setThisVideoSrc(currentSrc);
|
|
80
|
+
setThisPoster(currentPoster);
|
|
81
|
+
}
|
|
82
|
+
}, [hasVideo, videoSrc, mobileVideoSrc, mobilePoster, poster]);
|
|
26
83
|
return /*#__PURE__*/_react.default.createElement(_Promo.Container, {
|
|
27
84
|
backgroundColor: backgroundColor,
|
|
28
85
|
position: position
|
|
29
|
-
},
|
|
30
|
-
imageRight:
|
|
31
|
-
}, /*#__PURE__*/_react.default.createElement(_Picture.default, {
|
|
86
|
+
}, /*#__PURE__*/_react.default.createElement(_Promo.Media, {
|
|
87
|
+
imageRight: copyLeft
|
|
88
|
+
}, hasImage && !hasVideo && /*#__PURE__*/_react.default.createElement(_Picture.default, {
|
|
32
89
|
alt: imageAltText,
|
|
33
90
|
imageLow: imageLow,
|
|
34
91
|
images: imageSet,
|
|
@@ -36,22 +93,40 @@ var Promo = function Promo(_ref) {
|
|
|
36
93
|
objectFit: "cover",
|
|
37
94
|
width: "100%",
|
|
38
95
|
height: "100%"
|
|
39
|
-
})
|
|
40
|
-
|
|
96
|
+
}), hasVideo && thisVideoSrc && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_PromoVideo.default, {
|
|
97
|
+
copyLeft: copyLeft,
|
|
98
|
+
lightColouredVideo: lightColouredVideo,
|
|
99
|
+
thisVideoSrc: thisVideoSrc,
|
|
100
|
+
thisPoster: thisPoster,
|
|
101
|
+
showPosterAfterPlaying: showPosterAfterPlaying,
|
|
102
|
+
autoPlay: autoPlay,
|
|
103
|
+
loop: loop
|
|
104
|
+
}))), /*#__PURE__*/_react.default.createElement(_Promo.Wrapper, {
|
|
105
|
+
copyLeft: copyLeft
|
|
41
106
|
}, /*#__PURE__*/_react.default.createElement(_Promo.Copy, {
|
|
42
|
-
position: position
|
|
107
|
+
position: position,
|
|
108
|
+
hasVideo: hasVideo,
|
|
109
|
+
lightColouredVideo: lightColouredVideo
|
|
43
110
|
}, children)));
|
|
44
111
|
};
|
|
45
112
|
|
|
46
113
|
Promo.defaultProps = {
|
|
47
114
|
backgroundColor: 'white',
|
|
48
|
-
|
|
115
|
+
copyLeft: false,
|
|
49
116
|
imageSet: null,
|
|
50
117
|
imageLow: null,
|
|
51
118
|
image: null,
|
|
52
119
|
imageAltText: '',
|
|
53
120
|
children: null,
|
|
54
|
-
position: 'none'
|
|
121
|
+
position: 'none',
|
|
122
|
+
autoPlay: true,
|
|
123
|
+
loop: true,
|
|
124
|
+
poster: null,
|
|
125
|
+
mobilePoster: null,
|
|
126
|
+
videoSrc: null,
|
|
127
|
+
mobileVideoSrc: null,
|
|
128
|
+
showPosterAfterPlaying: true,
|
|
129
|
+
lightColouredVideo: false
|
|
55
130
|
};
|
|
56
131
|
var _default = Promo;
|
|
57
132
|
exports.default = _default;
|
|
@@ -14,7 +14,7 @@ import Link from '../../Atoms/Link/Link';
|
|
|
14
14
|
image={defaultData.promoImage}
|
|
15
15
|
imageLow={defaultData.promoImage}
|
|
16
16
|
imageAltText=""
|
|
17
|
-
|
|
17
|
+
copyLeft={true}
|
|
18
18
|
hasOverlay={true}
|
|
19
19
|
position="upper"
|
|
20
20
|
>
|
|
@@ -50,7 +50,7 @@ import Link from '../../Atoms/Link/Link';
|
|
|
50
50
|
image={defaultData.promoImage}
|
|
51
51
|
imageLow={defaultData.promoImage}
|
|
52
52
|
imageAltText=""
|
|
53
|
-
|
|
53
|
+
copyLeft={true}
|
|
54
54
|
hasOverlay={true}
|
|
55
55
|
position="end"
|
|
56
56
|
>
|
|
@@ -86,7 +86,7 @@ import Link from '../../Atoms/Link/Link';
|
|
|
86
86
|
image={defaultData.promoImage}
|
|
87
87
|
imageLow={defaultData.promoImage}
|
|
88
88
|
imageAltText=""
|
|
89
|
-
|
|
89
|
+
copyLeft={true}
|
|
90
90
|
hasOverlay={true}
|
|
91
91
|
position="lower"
|
|
92
92
|
>
|
|
@@ -122,7 +122,7 @@ import Link from '../../Atoms/Link/Link';
|
|
|
122
122
|
image={defaultData.promoImage}
|
|
123
123
|
imageLow={defaultData.promoImage}
|
|
124
124
|
imageAltText=""
|
|
125
|
-
|
|
125
|
+
copyLeft={true}
|
|
126
126
|
hasOverlay={true}
|
|
127
127
|
>
|
|
128
128
|
<Text
|
|
@@ -149,3 +149,265 @@ import Link from '../../Atoms/Link/Link';
|
|
|
149
149
|
</Promo>
|
|
150
150
|
</div>
|
|
151
151
|
```
|
|
152
|
+
|
|
153
|
+
Promo w/Video
|
|
154
|
+
|
|
155
|
+
```js
|
|
156
|
+
const defaultData = require('../../../styleguide/data/data').defaultData;import Text from '../../Atoms/Text/Text';
|
|
157
|
+
import Link from '../../Atoms/Link/Link';
|
|
158
|
+
import poster from '../../../styleguide/assets/VideoBannerPosterImage.png';
|
|
159
|
+
import mobilePoster from '../../../styleguide/assets/mobileVideoPosterImage.png';
|
|
160
|
+
const videoSrc =
|
|
161
|
+
'https://www.comicrelief.com/sites/default/files/downloads/Creativists_Logo_Web_small_V2_0.mp4';
|
|
162
|
+
|
|
163
|
+
let mobileVideoSrc = 'https://samplelib.com/lib/preview/mp4/sample-10s.mp4';
|
|
164
|
+
|
|
165
|
+
<div>
|
|
166
|
+
<Text tag="h2" size="xl" color="black">
|
|
167
|
+
Promo Upper w/Video (autoplay and loop)
|
|
168
|
+
</Text>
|
|
169
|
+
<Promo
|
|
170
|
+
backgroundColor="blue_dark"
|
|
171
|
+
imageSet={defaultData.promoImage}
|
|
172
|
+
image={defaultData.promoImage}
|
|
173
|
+
imageLow={defaultData.promoImage}
|
|
174
|
+
imageAltText=""
|
|
175
|
+
copyLeft={true}
|
|
176
|
+
hasOverlay={true}
|
|
177
|
+
position="upper"
|
|
178
|
+
videoSrc={videoSrc}
|
|
179
|
+
poster={poster}
|
|
180
|
+
loop={true}
|
|
181
|
+
autoplay={true}
|
|
182
|
+
>
|
|
183
|
+
<Text
|
|
184
|
+
tag="h1"
|
|
185
|
+
color="white"
|
|
186
|
+
size="super"
|
|
187
|
+
family="Anton"
|
|
188
|
+
uppercase
|
|
189
|
+
weight="normal"
|
|
190
|
+
>
|
|
191
|
+
Curabitur pretium tincidunt lacus
|
|
192
|
+
</Text>
|
|
193
|
+
<Text tag="p" color="white">
|
|
194
|
+
Curabitur pretium tincidunt lacus. Nulla gravida orci a odio. Nullam varius,
|
|
195
|
+
turpis et commodo, est eros bibendum elit, nec luctus magna sollicitudin.
|
|
196
|
+
</Text>
|
|
197
|
+
<span>
|
|
198
|
+
<Link href="/" type="button" color="white">
|
|
199
|
+
<Text>
|
|
200
|
+
Show me this
|
|
201
|
+
</Text>
|
|
202
|
+
</Link>
|
|
203
|
+
</span>
|
|
204
|
+
</Promo>
|
|
205
|
+
|
|
206
|
+
<br />
|
|
207
|
+
|
|
208
|
+
<Text tag="h2" size="xl" color="black">
|
|
209
|
+
Promo End w/Video (loop only)
|
|
210
|
+
</Text>
|
|
211
|
+
<Promo
|
|
212
|
+
backgroundColor="blue_dark"
|
|
213
|
+
imageSet={defaultData.promoImage}
|
|
214
|
+
image={defaultData.promoImage}
|
|
215
|
+
imageLow={defaultData.promoImage}
|
|
216
|
+
imageAltText=""
|
|
217
|
+
copyLeft={true}
|
|
218
|
+
hasOverlay={true}
|
|
219
|
+
position="end"
|
|
220
|
+
videoSrc={videoSrc}
|
|
221
|
+
poster={poster}
|
|
222
|
+
loop={true}
|
|
223
|
+
autoPlay={false}
|
|
224
|
+
>
|
|
225
|
+
<Text
|
|
226
|
+
tag="h1"
|
|
227
|
+
color="white"
|
|
228
|
+
size="super"
|
|
229
|
+
family="Anton"
|
|
230
|
+
uppercase
|
|
231
|
+
weight="normal"
|
|
232
|
+
>
|
|
233
|
+
Curabitur pretium tincidunt lacus
|
|
234
|
+
</Text>
|
|
235
|
+
<Text tag="p" color="white">
|
|
236
|
+
Curabitur pretium tincidunt lacus. Nulla gravida orci a odio. Nullam varius,
|
|
237
|
+
turpis et commodo, est eros bibendum elit, nec luctus magna sollicitudin.
|
|
238
|
+
</Text>
|
|
239
|
+
<span>
|
|
240
|
+
<Link href="/" type="button" color="white">
|
|
241
|
+
<Text>
|
|
242
|
+
Show me this
|
|
243
|
+
</Text>
|
|
244
|
+
</Link>
|
|
245
|
+
</span>
|
|
246
|
+
</Promo>
|
|
247
|
+
|
|
248
|
+
<br />
|
|
249
|
+
|
|
250
|
+
<Text tag="h2" size="xl" color="black">
|
|
251
|
+
Promo Lower w/Video (autoplay only)
|
|
252
|
+
</Text>
|
|
253
|
+
<Promo
|
|
254
|
+
backgroundColor="blue_dark"
|
|
255
|
+
imageSet={defaultData.promoImage}
|
|
256
|
+
image={defaultData.promoImage}
|
|
257
|
+
imageLow={defaultData.promoImage}
|
|
258
|
+
imageAltText=""
|
|
259
|
+
copyLeft={true}
|
|
260
|
+
hasOverlay={true}
|
|
261
|
+
position="lower"
|
|
262
|
+
videoSrc={videoSrc}
|
|
263
|
+
poster={poster}
|
|
264
|
+
loop={false}
|
|
265
|
+
autoPlay={true}
|
|
266
|
+
>
|
|
267
|
+
<Text
|
|
268
|
+
tag="h1"
|
|
269
|
+
color="white"
|
|
270
|
+
size="super"
|
|
271
|
+
family="Anton"
|
|
272
|
+
uppercase
|
|
273
|
+
weight="normal"
|
|
274
|
+
>
|
|
275
|
+
Curabitur pretium tincidunt lacus
|
|
276
|
+
</Text>
|
|
277
|
+
<Text tag="p" color="white">
|
|
278
|
+
Curabitur pretium tincidunt lacus. Nulla gravida orci a odio. Nullam varius,
|
|
279
|
+
turpis et commodo, est eros bibendum elit, nec luctus magna sollicitudin.
|
|
280
|
+
</Text>
|
|
281
|
+
<span>
|
|
282
|
+
<Link href="/" type="button" color="white">
|
|
283
|
+
<Text>
|
|
284
|
+
Show me this
|
|
285
|
+
</Text>
|
|
286
|
+
</Link>
|
|
287
|
+
</span>
|
|
288
|
+
</Promo>
|
|
289
|
+
|
|
290
|
+
<br />
|
|
291
|
+
<Text tag="h2" size="xl" color="black">
|
|
292
|
+
Promo None w/Video (no loop or autoplay)
|
|
293
|
+
</Text>
|
|
294
|
+
<Promo
|
|
295
|
+
backgroundColor="blue_dark"
|
|
296
|
+
imageSet={defaultData.promoImage}
|
|
297
|
+
image={defaultData.promoImage}
|
|
298
|
+
imageLow={defaultData.promoImage}
|
|
299
|
+
imageAltText=""
|
|
300
|
+
copyLeft={false}
|
|
301
|
+
hasOverlay={true}
|
|
302
|
+
videoSrc={videoSrc}
|
|
303
|
+
poster={poster}
|
|
304
|
+
loop={false}
|
|
305
|
+
autoPlay={false}
|
|
306
|
+
>
|
|
307
|
+
<Text
|
|
308
|
+
tag="h1"
|
|
309
|
+
color="white"
|
|
310
|
+
size="super"
|
|
311
|
+
family="Anton"
|
|
312
|
+
uppercase
|
|
313
|
+
weight="normal"
|
|
314
|
+
>
|
|
315
|
+
Curabitur pretium tincidunt lacus
|
|
316
|
+
</Text>
|
|
317
|
+
<Text tag="p" color="white">
|
|
318
|
+
Curabitur pretium tincidunt lacus. Nulla gravida orci a odio. Nullam varius,
|
|
319
|
+
turpis et commodo, est eros bibendum elit, nec luctus magna sollicitudin.
|
|
320
|
+
</Text>
|
|
321
|
+
<span>
|
|
322
|
+
<Link href="/" type="button" color="white">
|
|
323
|
+
<Text>
|
|
324
|
+
Show me this
|
|
325
|
+
</Text>
|
|
326
|
+
</Link>
|
|
327
|
+
</span>
|
|
328
|
+
</Promo>
|
|
329
|
+
|
|
330
|
+
<Text tag="h2" size="xl" color="black">
|
|
331
|
+
Promo None w/Video (no loop or autoplay, 'light-coloured video' setting, different videos and posters for mobile and desktop)
|
|
332
|
+
</Text>
|
|
333
|
+
<Promo
|
|
334
|
+
backgroundColor="blue_light"
|
|
335
|
+
imageSet={defaultData.promoImage}
|
|
336
|
+
image={defaultData.promoImage}
|
|
337
|
+
imageLow={defaultData.promoImage}
|
|
338
|
+
imageAltText=""
|
|
339
|
+
copyLeft={true}
|
|
340
|
+
hasOverlay={true}
|
|
341
|
+
videoSrc={videoSrc}
|
|
342
|
+
mobileVideoSrc={mobileVideoSrc}
|
|
343
|
+
poster={poster}
|
|
344
|
+
mobilePoster={mobilePoster}
|
|
345
|
+
loop={false}
|
|
346
|
+
autoPlay={false}
|
|
347
|
+
lightColouredVideo={true}
|
|
348
|
+
>
|
|
349
|
+
<Text
|
|
350
|
+
tag="h1"
|
|
351
|
+
color="black"
|
|
352
|
+
size="super"
|
|
353
|
+
family="Anton"
|
|
354
|
+
uppercase
|
|
355
|
+
weight="normal"
|
|
356
|
+
>
|
|
357
|
+
Curabitur pretium tincidunt lacus
|
|
358
|
+
</Text>
|
|
359
|
+
<Text tag="p" color="black">
|
|
360
|
+
Curabitur pretium tincidunt lacus. Nulla gravida orci a odio. Nullam varius,
|
|
361
|
+
turpis et commodo, est eros bibendum elit, nec luctus magna sollicitudin.
|
|
362
|
+
</Text>
|
|
363
|
+
<span>
|
|
364
|
+
<Link href="/" type="button" color="black">
|
|
365
|
+
<Text>
|
|
366
|
+
Show me this
|
|
367
|
+
</Text>
|
|
368
|
+
</Link>
|
|
369
|
+
</span>
|
|
370
|
+
</Promo>
|
|
371
|
+
|
|
372
|
+
<Text tag="h2" size="xl" color="black">
|
|
373
|
+
Promo None w/Video (no loop or autoplay, 'light-coloured video' setting, mobile-only video and poster)
|
|
374
|
+
</Text>
|
|
375
|
+
<Promo
|
|
376
|
+
backgroundColor="blue_light"
|
|
377
|
+
imageSet={defaultData.promoImage}
|
|
378
|
+
image={defaultData.promoImage}
|
|
379
|
+
imageLow={defaultData.promoImage}
|
|
380
|
+
imageAltText=""
|
|
381
|
+
copyLeft={true}
|
|
382
|
+
hasOverlay={true}
|
|
383
|
+
mobileVideoSrc={mobileVideoSrc}
|
|
384
|
+
mobilePoster={mobilePoster}
|
|
385
|
+
loop={false}
|
|
386
|
+
autoPlay={false}
|
|
387
|
+
lightColouredVideo={true}
|
|
388
|
+
>
|
|
389
|
+
<Text
|
|
390
|
+
tag="h1"
|
|
391
|
+
color="black"
|
|
392
|
+
size="super"
|
|
393
|
+
family="Anton"
|
|
394
|
+
uppercase
|
|
395
|
+
weight="normal"
|
|
396
|
+
>
|
|
397
|
+
Curabitur pretium tincidunt lacus
|
|
398
|
+
</Text>
|
|
399
|
+
<Text tag="p" color="black">
|
|
400
|
+
Curabitur pretium tincidunt lacus. Nulla gravida orci a odio. Nullam varius,
|
|
401
|
+
turpis et commodo, est eros bibendum elit, nec luctus magna sollicitudin.
|
|
402
|
+
</Text>
|
|
403
|
+
<span>
|
|
404
|
+
<Link href="/" type="button" color="black">
|
|
405
|
+
<Text>
|
|
406
|
+
Show me this
|
|
407
|
+
</Text>
|
|
408
|
+
</Link>
|
|
409
|
+
</span>
|
|
410
|
+
</Promo>
|
|
411
|
+
|
|
412
|
+
</div>
|
|
413
|
+
```
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.Media = exports.Copy = exports.Wrapper = exports.Container = void 0;
|
|
8
|
+
exports.Video = exports.Media = exports.Copy = exports.Wrapper = exports.Container = void 0;
|
|
9
9
|
|
|
10
10
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
11
11
|
|
|
@@ -43,8 +43,8 @@ var Wrapper = _styledComponents.default.div.withConfig({
|
|
|
43
43
|
displayName: "Promostyle__Wrapper",
|
|
44
44
|
componentId: "sc-kk4nna-1"
|
|
45
45
|
})(["width:100%;max-width:", ";height:100%;left:0;right:0;margin:0 auto;display:flex;align-items:center;", ";", "{min-height:calc(100vh - 90px);}"], _size.container.medium, function (_ref5) {
|
|
46
|
-
var
|
|
47
|
-
return !
|
|
46
|
+
var copyLeft = _ref5.copyLeft;
|
|
47
|
+
return !copyLeft && 'justify-content: flex-end';
|
|
48
48
|
}, (0, _size.media)('medium'));
|
|
49
49
|
|
|
50
50
|
exports.Wrapper = Wrapper;
|
|
@@ -52,8 +52,15 @@ exports.Wrapper = Wrapper;
|
|
|
52
52
|
var Copy = _styledComponents.default.div.withConfig({
|
|
53
53
|
displayName: "Promostyle__Copy",
|
|
54
54
|
componentId: "sc-kk4nna-2"
|
|
55
|
-
})(["width:100%;padding:", " ", " ", ";", ";", "{width:70%;padding:", " ", ";}", "{width:50%;padding:", " ", ";}", ""], (0, _spacing.default)('m'), (0, _spacing.default)('m'), (0, _spacing.default)('xl'), (0, _zIndex.default)('low'), (0, _size.media)('medium'), (0, _spacing.default)('xl'), (0, _spacing.default)('m'), (0, _size.media)('medium'), (0, _spacing.default)('xxl'), (0, _spacing.default)('m'), function (_ref6) {
|
|
56
|
-
var
|
|
55
|
+
})(["width:100%;padding:", " ", " ", ";", ";", "{width:70%;padding:", " ", ";}", "{width:50%;padding:", " ", ";", " ", "}", ""], (0, _spacing.default)('m'), (0, _spacing.default)('m'), (0, _spacing.default)('xl'), (0, _zIndex.default)('low'), (0, _size.media)('medium'), (0, _spacing.default)('xl'), (0, _spacing.default)('m'), (0, _size.media)('medium'), (0, _spacing.default)('xxl'), (0, _spacing.default)('m'), function (_ref6) {
|
|
56
|
+
var hasVideo = _ref6.hasVideo;
|
|
57
|
+
return hasVideo !== false && (0, _styledComponents.css)(["background-color:rgba(0,0,0,0.75);overflow:hidden;box-shadow:0px 0px 75px 100px rgba(0,0,0,0.75);"]);
|
|
58
|
+
}, function (_ref7) {
|
|
59
|
+
var hasVideo = _ref7.hasVideo,
|
|
60
|
+
lightColouredVideo = _ref7.lightColouredVideo;
|
|
61
|
+
return hasVideo !== false && lightColouredVideo && (0, _styledComponents.css)(["background-color:rgba(255,255,255,0.75);box-shadow:0px 0px 75px 100px rgba(255,255,255,0.75);"]);
|
|
62
|
+
}, function (_ref8) {
|
|
63
|
+
var position = _ref8.position;
|
|
57
64
|
return position === 'lower' && (0, _styledComponents.css)(["padding:", " ", ";", "{padding:6rem ", ";margin-top:6rem;}"], (0, _spacing.default)('xl'), (0, _spacing.default)('m'), (0, _size.media)('medium'), (0, _spacing.default)('m'));
|
|
58
65
|
});
|
|
59
66
|
|
|
@@ -64,4 +71,15 @@ var Media = _styledComponents.default.div.withConfig({
|
|
|
64
71
|
componentId: "sc-kk4nna-3"
|
|
65
72
|
})(["width:100%;height:auto;img{object-position:center;}", "{height:100%;position:absolute;}"], (0, _size.media)('medium'));
|
|
66
73
|
|
|
67
|
-
exports.Media = Media;
|
|
74
|
+
exports.Media = Media;
|
|
75
|
+
|
|
76
|
+
var Video = _styledComponents.default.video.attrs(function () {
|
|
77
|
+
return {
|
|
78
|
+
playsInline: true
|
|
79
|
+
};
|
|
80
|
+
}).withConfig({
|
|
81
|
+
displayName: "Promostyle__Video",
|
|
82
|
+
componentId: "sc-kk4nna-4"
|
|
83
|
+
})(["width:100%;height:100%;object-fit:cover;"]);
|
|
84
|
+
|
|
85
|
+
exports.Video = Video;
|
|
@@ -22,7 +22,7 @@ it('renders Promo correctly', function () {
|
|
|
22
22
|
imageSet: defaultData.promoImage,
|
|
23
23
|
image: defaultData.promoImage,
|
|
24
24
|
imageAltText: "",
|
|
25
|
-
|
|
25
|
+
copyLeft: false
|
|
26
26
|
}, /*#__PURE__*/_react.default.createElement(_Text.default, {
|
|
27
27
|
tag: "h1",
|
|
28
28
|
color: "white",
|
|
@@ -46,7 +46,7 @@ it('renders Promo correctly end position', function () {
|
|
|
46
46
|
imageSet: defaultData.promoImage,
|
|
47
47
|
image: defaultData.promoImage,
|
|
48
48
|
imageAltText: "",
|
|
49
|
-
|
|
49
|
+
copyLeft: false,
|
|
50
50
|
position: "end"
|
|
51
51
|
}, /*#__PURE__*/_react.default.createElement(_Text.default, {
|
|
52
52
|
tag: "h1",
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
11
|
+
|
|
12
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _PromoVideoButton = require("./_PromoVideoButton.style");
|
|
17
|
+
|
|
18
|
+
var _excluded = ["videoProgress"];
|
|
19
|
+
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
+
|
|
22
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
+
|
|
24
|
+
var ProgressRing = function ProgressRing(_ref) {
|
|
25
|
+
var videoProgress = _ref.videoProgress,
|
|
26
|
+
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
27
|
+
var thisStroke = 4;
|
|
28
|
+
var thisRadius = 28;
|
|
29
|
+
var initNormRadius = thisRadius - thisStroke * 2;
|
|
30
|
+
var thisCircumference = initNormRadius * 2 * Math.PI;
|
|
31
|
+
|
|
32
|
+
var _useState = (0, _react.useState)(initNormRadius * 2 * Math.PI),
|
|
33
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
34
|
+
thisDashOffset = _useState2[0],
|
|
35
|
+
setThisDashOffset = _useState2[1];
|
|
36
|
+
|
|
37
|
+
(0, _react.useEffect)(function () {
|
|
38
|
+
var offset = thisCircumference - videoProgress / 100 * thisCircumference;
|
|
39
|
+
setThisDashOffset(offset);
|
|
40
|
+
}, [videoProgress, thisCircumference]);
|
|
41
|
+
return /*#__PURE__*/_react.default.createElement(_PromoVideoButton.ProgressRingWrapper, {
|
|
42
|
+
videoProgress: videoProgress
|
|
43
|
+
}, /*#__PURE__*/_react.default.createElement(_PromoVideoButton.ProgressRingSVG, {
|
|
44
|
+
height: thisRadius * 2,
|
|
45
|
+
width: thisRadius * 2
|
|
46
|
+
}, /*#__PURE__*/_react.default.createElement(_PromoVideoButton.ProgressRingCircle, Object.assign({
|
|
47
|
+
strokeDasharray: "".concat(thisCircumference, " ").concat(thisCircumference),
|
|
48
|
+
strokeDashOffsetStyle: thisDashOffset,
|
|
49
|
+
strokeWidth: "".concat(thisStroke),
|
|
50
|
+
r: "".concat(initNormRadius),
|
|
51
|
+
cx: "".concat(thisRadius),
|
|
52
|
+
cy: "".concat(thisRadius)
|
|
53
|
+
}, rest))));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
var _default = ProgressRing;
|
|
57
|
+
exports.default = _default;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
|
|
14
|
+
var _Promo = require("./Promo.style");
|
|
15
|
+
|
|
16
|
+
var _PromoVideoButton = _interopRequireDefault(require("./_PromoVideoButton"));
|
|
17
|
+
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
22
|
+
var PromoVideo = function PromoVideo(_ref) {
|
|
23
|
+
var lightColouredVideo = _ref.lightColouredVideo,
|
|
24
|
+
copyLeft = _ref.copyLeft,
|
|
25
|
+
thisVideoSrc = _ref.thisVideoSrc,
|
|
26
|
+
thisPoster = _ref.thisPoster,
|
|
27
|
+
autoPlay = _ref.autoPlay,
|
|
28
|
+
loop = _ref.loop,
|
|
29
|
+
showPosterAfterPlaying = _ref.showPosterAfterPlaying;
|
|
30
|
+
|
|
31
|
+
var _useState = (0, _react.useState)(false),
|
|
32
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
33
|
+
isPlaying = _useState2[0],
|
|
34
|
+
setIsPlaying = _useState2[1];
|
|
35
|
+
|
|
36
|
+
var _useState3 = (0, _react.useState)(false),
|
|
37
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
38
|
+
isRestarting = _useState4[0],
|
|
39
|
+
setIsRestarting = _useState4[1];
|
|
40
|
+
|
|
41
|
+
var _useState5 = (0, _react.useState)(0),
|
|
42
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
43
|
+
videoProgress = _useState6[0],
|
|
44
|
+
setVideoProgress = _useState6[1];
|
|
45
|
+
|
|
46
|
+
var videoEl = (0, _react.useRef)(null);
|
|
47
|
+
|
|
48
|
+
var togglePlay = function togglePlay() {
|
|
49
|
+
if (isPlaying) videoEl.current.pause();else videoEl.current.play();
|
|
50
|
+
setIsPlaying(!isPlaying);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var updateTime = function updateTime() {
|
|
54
|
+
if (videoEl.current.duration) {
|
|
55
|
+
// Calculate the percentage of the video played:
|
|
56
|
+
var percentage = Math.round(videoEl.current.currentTime / videoEl.current.duration * 100); // Because a completely smooth animation is impossible with the 250ms-ish frequency of
|
|
57
|
+
// the 'timeupdate' event, we're electing to just update the ring every 25%.
|
|
58
|
+
|
|
59
|
+
var nearest = 25;
|
|
60
|
+
var roundedPercentage = percentage + nearest / 2 - (percentage + nearest / 2) % nearest;
|
|
61
|
+
setVideoProgress(roundedPercentage);
|
|
62
|
+
}
|
|
63
|
+
}; // Only loads once the initial screensize check is complete
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
(0, _react.useEffect)(function () {
|
|
67
|
+
// Use truthy comparison so either a null OR undefined value won't work
|
|
68
|
+
if (thisVideoSrc != null) {
|
|
69
|
+
videoEl.current.addEventListener('timeupdate', updateTime); // Trigger on-load autoplay if apppropriate
|
|
70
|
+
|
|
71
|
+
if (autoPlay && !isPlaying) {
|
|
72
|
+
togglePlay();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
videoEl.current.addEventListener('ended', function () {
|
|
76
|
+
// Used purely to halt the CSS animation:
|
|
77
|
+
setIsRestarting(true); // If this is a non-looping video, add a listener to update our local state
|
|
78
|
+
// once the video's ended, to let the user retrigger it manually:
|
|
79
|
+
|
|
80
|
+
if (!loop) {
|
|
81
|
+
setIsPlaying(false);
|
|
82
|
+
setVideoProgress(0); // Reload the video to show the poster image:
|
|
83
|
+
|
|
84
|
+
if (showPosterAfterPlaying) videoEl.current.load();
|
|
85
|
+
} else {
|
|
86
|
+
// Rather than using the Video 'loop' property, we retrigger
|
|
87
|
+
// it in *code* as there's no 'restarted' to hook into:
|
|
88
|
+
togglePlay();
|
|
89
|
+
} // Grace period to allow the animation to reset
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
setTimeout(function () {
|
|
93
|
+
setIsRestarting(false);
|
|
94
|
+
}, 100);
|
|
95
|
+
});
|
|
96
|
+
} // CERTAINLY don't want this re-running for EACH of these variable updates, sorry Lint...
|
|
97
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
98
|
+
|
|
99
|
+
}, [thisVideoSrc]);
|
|
100
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Promo.Video, {
|
|
101
|
+
ref: videoEl,
|
|
102
|
+
src: thisVideoSrc,
|
|
103
|
+
poster: thisPoster,
|
|
104
|
+
muted: true
|
|
105
|
+
}, "Your browser does not support this video filetype."), /*#__PURE__*/_react.default.createElement(_PromoVideoButton.default, {
|
|
106
|
+
copyLeft: copyLeft,
|
|
107
|
+
videoProgress: videoProgress,
|
|
108
|
+
togglePlay: togglePlay,
|
|
109
|
+
isPlaying: isPlaying,
|
|
110
|
+
lightColouredVideo: lightColouredVideo,
|
|
111
|
+
isRestarting: isRestarting
|
|
112
|
+
}));
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
var _default = PromoVideo;
|
|
116
|
+
exports.default = _default;
|