@comicrelief/component-library 7.18.4 → 7.19.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/.github/workflows/main.yml +4 -4
- package/.nvmrc +1 -0
- package/cypress/integration/components/Molecules/VideoBanner.spec.js +1 -1
- package/dist/components/Atoms/Select/Select.md +3 -4
- package/dist/components/Molecules/VideoBanner/VideoBanner.js +44 -9
- package/dist/components/Molecules/VideoBanner/VideoBanner.md +20 -1
- package/dist/components/Molecules/VideoBanner/VideoBanner.test.js +5 -5
- package/dist/styleguide/assets/VideoBannerPosterImage.png +0 -0
- package/package.json +1 -1
- package/src/components/Atoms/Select/Select.md +3 -4
- package/src/components/Molecules/VideoBanner/VideoBanner.js +47 -11
- package/src/components/Molecules/VideoBanner/VideoBanner.md +20 -1
- package/src/components/Molecules/VideoBanner/VideoBanner.test.js +9 -8
- package/src/styleguide/assets/VideoBannerPosterImage.png +0 -0
- package/dist/styleguide/assets/poster.png +0 -0
- package/src/styleguide/assets/poster.png +0 -0
|
@@ -13,7 +13,7 @@ jobs:
|
|
|
13
13
|
- name: Set up Node
|
|
14
14
|
uses: actions/setup-node@v3
|
|
15
15
|
with:
|
|
16
|
-
node-version:
|
|
16
|
+
node-version-file: '.nvmrc'
|
|
17
17
|
|
|
18
18
|
- name: Restore packages cache
|
|
19
19
|
uses: actions/cache@v3
|
|
@@ -37,7 +37,7 @@ jobs:
|
|
|
37
37
|
- name: Set up Node
|
|
38
38
|
uses: actions/setup-node@v3
|
|
39
39
|
with:
|
|
40
|
-
node-version:
|
|
40
|
+
node-version-file: '.nvmrc'
|
|
41
41
|
|
|
42
42
|
- name: Restore packages cache
|
|
43
43
|
uses: actions/cache@v3
|
|
@@ -69,7 +69,7 @@ jobs:
|
|
|
69
69
|
- name: Set up Node
|
|
70
70
|
uses: actions/setup-node@v3
|
|
71
71
|
with:
|
|
72
|
-
node-version:
|
|
72
|
+
node-version-file: '.nvmrc'
|
|
73
73
|
|
|
74
74
|
# see https://github.com/marketplace/actions/cypress-io
|
|
75
75
|
- name: Run Cypress tests
|
|
@@ -110,7 +110,7 @@ jobs:
|
|
|
110
110
|
- name: Set up Node
|
|
111
111
|
uses: actions/setup-node@v3
|
|
112
112
|
with:
|
|
113
|
-
node-version:
|
|
113
|
+
node-version-file: '.nvmrc'
|
|
114
114
|
|
|
115
115
|
- name: Restore packages cache
|
|
116
116
|
uses: actions/cache@v3
|
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
v16.20.0
|
|
@@ -35,7 +35,7 @@ describe('Video Banner component', () => {
|
|
|
35
35
|
|
|
36
36
|
describe('Video Banner section', () => {
|
|
37
37
|
beforeEach(() => {
|
|
38
|
-
cy.get('[data-testid="VideoBanner-example-
|
|
38
|
+
cy.get('[data-testid="VideoBanner-example-1"]')
|
|
39
39
|
.as('container')
|
|
40
40
|
.find('[data-preview="VideoBanner"]')
|
|
41
41
|
.as('preview');
|
|
@@ -5,13 +5,12 @@
|
|
|
5
5
|
<Select
|
|
6
6
|
label="Label"
|
|
7
7
|
description="Please choose an option"
|
|
8
|
+
// note: defaultValue is just using the built-in React defaultValue prop. It adds the HTML prop "selected" to one of the options elements. This is why defaultValue must be set to one of the existing options values:
|
|
9
|
+
defaultValue="Option four"
|
|
8
10
|
errorMsg=""
|
|
9
11
|
options={[
|
|
10
12
|
{ value: 'Option one', displayValue: 'The first option' },
|
|
11
|
-
{
|
|
12
|
-
value: 'Option two',
|
|
13
|
-
displayValue: 'The second option'
|
|
14
|
-
},
|
|
13
|
+
{ value: 'Option two', displayValue: 'The second option' },
|
|
15
14
|
{ value: 'Option three', displayValue: 'The third option' },
|
|
16
15
|
{ value: 'Option four', displayValue: 'The fourth option' }
|
|
17
16
|
]}
|
|
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
11
|
+
|
|
10
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
13
|
|
|
12
14
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
@@ -17,10 +19,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
17
19
|
|
|
18
20
|
var Video = _styledComponents.default.video.attrs(function () {
|
|
19
21
|
return {
|
|
20
|
-
|
|
21
|
-
playsInline: true,
|
|
22
|
-
muted: true,
|
|
23
|
-
loop: false
|
|
22
|
+
playsInline: true
|
|
24
23
|
};
|
|
25
24
|
}).withConfig({
|
|
26
25
|
displayName: "VideoBanner__Video",
|
|
@@ -29,22 +28,58 @@ var Video = _styledComponents.default.video.attrs(function () {
|
|
|
29
28
|
|
|
30
29
|
var VideoBanner = function VideoBanner(_ref) {
|
|
31
30
|
var video = _ref.video,
|
|
32
|
-
poster = _ref.poster
|
|
31
|
+
poster = _ref.poster,
|
|
32
|
+
controls = _ref.controls,
|
|
33
|
+
autoPlay = _ref.autoPlay,
|
|
34
|
+
loop = _ref.loop,
|
|
35
|
+
muted = _ref.muted,
|
|
36
|
+
showPosterAfterPlaying = _ref.showPosterAfterPlaying;
|
|
37
|
+
|
|
38
|
+
// Use the prop as our default
|
|
39
|
+
var _useState = (0, _react.useState)(muted),
|
|
40
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
41
|
+
isMuted = _useState2[0],
|
|
42
|
+
setIsMuted = _useState2[1];
|
|
43
|
+
|
|
33
44
|
var videoEl = (0, _react.useRef)(null);
|
|
34
45
|
|
|
35
|
-
var
|
|
46
|
+
var triggerPlay = function triggerPlay() {
|
|
36
47
|
videoEl.current.play();
|
|
37
48
|
};
|
|
38
49
|
|
|
39
50
|
(0, _react.useEffect)(function () {
|
|
40
|
-
|
|
41
|
-
|
|
51
|
+
// Trigger onload autoplay based on prop:
|
|
52
|
+
if (autoPlay) {
|
|
53
|
+
// As it's a Chrome requirement to mute any autoplay videos,
|
|
54
|
+
// update accordingly; see https://developer.chrome.com/blog/autoplay/
|
|
55
|
+
setIsMuted(true);
|
|
56
|
+
triggerPlay();
|
|
57
|
+
} // And attach event listener based on prop:
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
if (!loop && showPosterAfterPlaying) {
|
|
61
|
+
videoEl.current.addEventListener('ended', function () {
|
|
62
|
+
// Reloads video, which re-shows poster
|
|
63
|
+
videoEl.current.load();
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}, [autoPlay, loop, showPosterAfterPlaying]);
|
|
42
67
|
return /*#__PURE__*/_react.default.createElement(Video, {
|
|
43
68
|
poster: poster,
|
|
44
69
|
src: video,
|
|
45
|
-
ref: videoEl
|
|
70
|
+
ref: videoEl,
|
|
71
|
+
controls: controls,
|
|
72
|
+
loop: loop,
|
|
73
|
+
muted: isMuted
|
|
46
74
|
}, "Your browser does not support video.");
|
|
47
75
|
};
|
|
48
76
|
|
|
77
|
+
VideoBanner.defaultProps = {
|
|
78
|
+
showPosterAfterPlaying: true,
|
|
79
|
+
controls: false,
|
|
80
|
+
autoPlay: true,
|
|
81
|
+
loop: false,
|
|
82
|
+
muted: true
|
|
83
|
+
};
|
|
49
84
|
var _default = VideoBanner;
|
|
50
85
|
exports.default = _default;
|
|
@@ -1,7 +1,26 @@
|
|
|
1
|
+
Default Video Banner (autoplay, no loop, no poster re-show)
|
|
1
2
|
```js
|
|
2
|
-
import poster from '../../../styleguide/assets/
|
|
3
|
+
import poster from '../../../styleguide/assets/VideoBannerPosterImage.png';
|
|
3
4
|
const src =
|
|
4
5
|
'https://www.comicrelief.com/sites/default/files/downloads/Creativists_Logo_Web_small_V2_0.mp4';
|
|
5
6
|
|
|
6
7
|
<VideoBanner poster={poster} video={src} />;
|
|
7
8
|
```
|
|
9
|
+
Looping Video Banner With Controls (autoplay, loop)
|
|
10
|
+
```js
|
|
11
|
+
import poster from '../../../styleguide/assets/VideoBannerPosterImage.png';
|
|
12
|
+
const src =
|
|
13
|
+
'https://www.comicrelief.com/sites/default/files/downloads/Creativists_Logo_Web_small_V2_0.mp4';
|
|
14
|
+
|
|
15
|
+
<VideoBanner poster={poster} video={src} loop={true} controls={true} autoPlay={true} muted={false}
|
|
16
|
+
/>;
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Non-autoplay Video Banner (reshows poster image after playing)
|
|
20
|
+
```js
|
|
21
|
+
import poster from '../../../styleguide/assets/VideoBannerPosterImage.png';
|
|
22
|
+
const src =
|
|
23
|
+
'https://www.comicrelief.com/sites/default/files/downloads/Creativists_Logo_Web_small_V2_0.mp4';
|
|
24
|
+
|
|
25
|
+
<VideoBanner poster={poster} video={src} showPosterAfterPlaying={true} />;
|
|
26
|
+
```
|
|
@@ -10,13 +10,13 @@ var _shallowWithTheme = _interopRequireDefault(require("../../../hoc/shallowWith
|
|
|
10
10
|
|
|
11
11
|
var _VideoBanner = _interopRequireDefault(require("./VideoBanner"));
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _VideoBannerPosterImage = _interopRequireDefault(require("../../../styleguide/assets/VideoBannerPosterImage.png"));
|
|
14
14
|
|
|
15
|
-
it(
|
|
16
|
-
var src =
|
|
15
|
+
it("renders correctly", function () {
|
|
16
|
+
var src = "https://www.comicrelief.com/sites/default/files/downloads/Creativists_Logo_Web_small_V2_0.mp4";
|
|
17
17
|
var tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_VideoBanner.default, {
|
|
18
|
-
poster:
|
|
18
|
+
poster: _VideoBannerPosterImage.default,
|
|
19
19
|
video: src
|
|
20
20
|
})).toJSON();
|
|
21
|
-
expect(tree).toMatchInlineSnapshot("\n .c0 {\n width: 100%;\n height: 100%;\n }\n\n <video\n
|
|
21
|
+
expect(tree).toMatchInlineSnapshot("\n .c0 {\n width: 100%;\n height: 100%;\n }\n\n <video\n className=\"c0\"\n controls={false}\n loop={false}\n muted={true}\n playsInline={true}\n poster=\"mock.asset\"\n src=\"https://www.comicrelief.com/sites/default/files/downloads/Creativists_Logo_Web_small_V2_0.mp4\"\n >\n Your browser does not support video.\n </video>\n ");
|
|
22
22
|
});
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -5,13 +5,12 @@
|
|
|
5
5
|
<Select
|
|
6
6
|
label="Label"
|
|
7
7
|
description="Please choose an option"
|
|
8
|
+
// note: defaultValue is just using the built-in React defaultValue prop. It adds the HTML prop "selected" to one of the options elements. This is why defaultValue must be set to one of the existing options values:
|
|
9
|
+
defaultValue="Option four"
|
|
8
10
|
errorMsg=""
|
|
9
11
|
options={[
|
|
10
12
|
{ value: 'Option one', displayValue: 'The first option' },
|
|
11
|
-
{
|
|
12
|
-
value: 'Option two',
|
|
13
|
-
displayValue: 'The second option'
|
|
14
|
-
},
|
|
13
|
+
{ value: 'Option two', displayValue: 'The second option' },
|
|
15
14
|
{ value: 'Option three', displayValue: 'The third option' },
|
|
16
15
|
{ value: 'Option four', displayValue: 'The fourth option' }
|
|
17
16
|
]}
|
|
@@ -1,38 +1,74 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from 'react';
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
|
|
5
5
|
const Video = styled.video.attrs(() => ({
|
|
6
|
-
|
|
7
|
-
playsInline: true,
|
|
8
|
-
muted: true,
|
|
9
|
-
loop: false
|
|
6
|
+
playsInline: true
|
|
10
7
|
}))`
|
|
11
8
|
width: 100%;
|
|
12
9
|
height: 100%;
|
|
13
10
|
`;
|
|
14
11
|
|
|
15
|
-
const VideoBanner = ({
|
|
12
|
+
const VideoBanner = ({
|
|
13
|
+
video, poster, controls, autoPlay, loop, muted, showPosterAfterPlaying
|
|
14
|
+
}) => {
|
|
15
|
+
// Use the prop as our default
|
|
16
|
+
const [isMuted, setIsMuted] = useState(muted);
|
|
17
|
+
|
|
16
18
|
const videoEl = useRef(null);
|
|
17
19
|
|
|
18
|
-
const
|
|
20
|
+
const triggerPlay = () => {
|
|
19
21
|
videoEl.current.play();
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
useEffect(() => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
// Trigger onload autoplay based on prop:
|
|
26
|
+
if (autoPlay) {
|
|
27
|
+
// As it's a Chrome requirement to mute any autoplay videos,
|
|
28
|
+
// update accordingly; see https://developer.chrome.com/blog/autoplay/
|
|
29
|
+
setIsMuted(true);
|
|
30
|
+
triggerPlay();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// And attach event listener based on prop:
|
|
34
|
+
if (!loop && showPosterAfterPlaying) {
|
|
35
|
+
videoEl.current.addEventListener('ended', () => {
|
|
36
|
+
// Reloads video, which re-shows poster
|
|
37
|
+
videoEl.current.load();
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}, [autoPlay, loop, showPosterAfterPlaying]);
|
|
25
41
|
|
|
26
42
|
return (
|
|
27
|
-
<Video
|
|
43
|
+
<Video
|
|
44
|
+
poster={poster}
|
|
45
|
+
src={video}
|
|
46
|
+
ref={videoEl}
|
|
47
|
+
controls={controls}
|
|
48
|
+
loop={loop}
|
|
49
|
+
muted={isMuted}
|
|
50
|
+
>
|
|
28
51
|
Your browser does not support video.
|
|
29
52
|
</Video>
|
|
30
53
|
);
|
|
31
54
|
};
|
|
32
55
|
|
|
56
|
+
VideoBanner.defaultProps = {
|
|
57
|
+
showPosterAfterPlaying: true,
|
|
58
|
+
controls: false,
|
|
59
|
+
autoPlay: true,
|
|
60
|
+
loop: false,
|
|
61
|
+
muted: true
|
|
62
|
+
};
|
|
63
|
+
|
|
33
64
|
VideoBanner.propTypes = {
|
|
65
|
+
showPosterAfterPlaying: PropTypes.bool,
|
|
34
66
|
video: PropTypes.string.isRequired,
|
|
35
|
-
poster: PropTypes.string.isRequired
|
|
67
|
+
poster: PropTypes.string.isRequired,
|
|
68
|
+
controls: PropTypes.bool,
|
|
69
|
+
autoPlay: PropTypes.bool,
|
|
70
|
+
loop: PropTypes.bool,
|
|
71
|
+
muted: PropTypes.bool
|
|
36
72
|
};
|
|
37
73
|
|
|
38
74
|
export default VideoBanner;
|
|
@@ -1,7 +1,26 @@
|
|
|
1
|
+
Default Video Banner (autoplay, no loop, no poster re-show)
|
|
1
2
|
```js
|
|
2
|
-
import poster from '../../../styleguide/assets/
|
|
3
|
+
import poster from '../../../styleguide/assets/VideoBannerPosterImage.png';
|
|
3
4
|
const src =
|
|
4
5
|
'https://www.comicrelief.com/sites/default/files/downloads/Creativists_Logo_Web_small_V2_0.mp4';
|
|
5
6
|
|
|
6
7
|
<VideoBanner poster={poster} video={src} />;
|
|
7
8
|
```
|
|
9
|
+
Looping Video Banner With Controls (autoplay, loop)
|
|
10
|
+
```js
|
|
11
|
+
import poster from '../../../styleguide/assets/VideoBannerPosterImage.png';
|
|
12
|
+
const src =
|
|
13
|
+
'https://www.comicrelief.com/sites/default/files/downloads/Creativists_Logo_Web_small_V2_0.mp4';
|
|
14
|
+
|
|
15
|
+
<VideoBanner poster={poster} video={src} loop={true} controls={true} autoPlay={true} muted={false}
|
|
16
|
+
/>;
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Non-autoplay Video Banner (reshows poster image after playing)
|
|
20
|
+
```js
|
|
21
|
+
import poster from '../../../styleguide/assets/VideoBannerPosterImage.png';
|
|
22
|
+
const src =
|
|
23
|
+
'https://www.comicrelief.com/sites/default/files/downloads/Creativists_Logo_Web_small_V2_0.mp4';
|
|
24
|
+
|
|
25
|
+
<VideoBanner poster={poster} video={src} showPosterAfterPlaying={true} />;
|
|
26
|
+
```
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "jest-styled-components";
|
|
3
3
|
|
|
4
|
-
import renderWithTheme from
|
|
5
|
-
import VideoBanner from
|
|
6
|
-
import poster from
|
|
4
|
+
import renderWithTheme from "../../../hoc/shallowWithTheme";
|
|
5
|
+
import VideoBanner from "./VideoBanner";
|
|
6
|
+
import poster from "../../../styleguide/assets/VideoBannerPosterImage.png";
|
|
7
7
|
|
|
8
|
-
it(
|
|
9
|
-
const src =
|
|
8
|
+
it("renders correctly", () => {
|
|
9
|
+
const src =
|
|
10
|
+
"https://www.comicrelief.com/sites/default/files/downloads/Creativists_Logo_Web_small_V2_0.mp4";
|
|
10
11
|
|
|
11
12
|
const tree = renderWithTheme(
|
|
12
13
|
<VideoBanner poster={poster} video={src} />
|
|
@@ -19,8 +20,8 @@ it('renders correctly', () => {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
<video
|
|
22
|
-
autoPlay={true}
|
|
23
23
|
className="c0"
|
|
24
|
+
controls={false}
|
|
24
25
|
loop={false}
|
|
25
26
|
muted={true}
|
|
26
27
|
playsInline={true}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|