@ndla/video-search 4.1.44 → 4.1.46
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/es/PreviewVideo.js +12 -16
- package/es/VideoLoadMoreButton.js +15 -16
- package/es/VideoSearch.js +201 -230
- package/es/VideoSearchForm.js +46 -73
- package/es/VideoSearchList.js +32 -37
- package/es/VideoSearchResultBrightcove.js +39 -40
- package/es/VideoSearchResultYouTube.js +32 -37
- package/es/VideoTabs.js +8 -15
- package/es/index.js +8 -0
- package/es/shapes.js +3 -3
- package/es/videoHelpers.js +14 -15
- package/lib/PreviewVideo.js +20 -22
- package/lib/VideoLoadMoreButton.js +24 -24
- package/lib/VideoSearch.js +210 -238
- package/lib/VideoSearchForm.js +55 -81
- package/lib/VideoSearchList.js +41 -45
- package/lib/VideoSearchResultBrightcove.js +47 -46
- package/lib/VideoSearchResultYouTube.js +40 -43
- package/lib/VideoTabs.js +17 -23
- package/lib/index.js +8 -2
- package/lib/shapes.js +4 -7
- package/lib/videoHelpers.js +14 -15
- package/package.json +8 -8
package/lib/VideoSearchForm.js
CHANGED
|
@@ -1,99 +1,74 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.default = void 0;
|
|
8
|
-
var _react = require("react");
|
|
9
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
-
var
|
|
8
|
+
var _react = require("react");
|
|
11
9
|
var _reactBemHelper = _interopRequireDefault(require("react-bem-helper"));
|
|
10
|
+
var _button = require("@ndla/button");
|
|
12
11
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
13
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
24
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
25
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
26
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
27
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
28
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /**
|
|
29
|
-
* Copyright (c) 2016-present, NDLA.
|
|
30
|
-
*
|
|
31
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
32
|
-
* LICENSE file in the root directory of this source tree.
|
|
33
|
-
*
|
|
34
|
-
*/
|
|
35
|
-
var classes = new _reactBemHelper.default({
|
|
13
|
+
/**
|
|
14
|
+
* Copyright (c) 2016-present, NDLA.
|
|
15
|
+
*
|
|
16
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
17
|
+
* LICENSE file in the root directory of this source tree.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const classes = new _reactBemHelper.default({
|
|
36
22
|
name: 'video-search',
|
|
37
23
|
prefix: 'c-'
|
|
38
24
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var _this;
|
|
44
|
-
_classCallCheck(this, SearchForm);
|
|
45
|
-
_this = _super.call(this, props);
|
|
46
|
-
_this.state = {
|
|
25
|
+
class SearchForm extends _react.Component {
|
|
26
|
+
constructor(props) {
|
|
27
|
+
super(props);
|
|
28
|
+
this.state = {
|
|
47
29
|
query: props.query
|
|
48
30
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return _this;
|
|
31
|
+
this.handleQueryChange = this.handleQueryChange.bind(this);
|
|
32
|
+
this.handleSubmit = this.handleSubmit.bind(this);
|
|
33
|
+
this.onKeyPress = this.onKeyPress.bind(this);
|
|
53
34
|
}
|
|
54
|
-
|
|
55
|
-
key
|
|
56
|
-
|
|
57
|
-
if (evt.key === 'Enter') {
|
|
58
|
-
this.handleSubmit(evt);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}, {
|
|
62
|
-
key: "handleQueryChange",
|
|
63
|
-
value: function handleQueryChange(evt) {
|
|
64
|
-
this.setState({
|
|
65
|
-
query: evt.target.value
|
|
66
|
-
});
|
|
35
|
+
onKeyPress(evt) {
|
|
36
|
+
if (evt.key === 'Enter') {
|
|
37
|
+
this.handleSubmit(evt);
|
|
67
38
|
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
evt.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}))
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
39
|
+
}
|
|
40
|
+
handleQueryChange(evt) {
|
|
41
|
+
this.setState({
|
|
42
|
+
query: evt.target.value
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
handleSubmit(evt) {
|
|
46
|
+
evt.preventDefault();
|
|
47
|
+
this.props.onSearchQuerySubmit(this.state.query);
|
|
48
|
+
}
|
|
49
|
+
render() {
|
|
50
|
+
const {
|
|
51
|
+
searching,
|
|
52
|
+
translations
|
|
53
|
+
} = this.props;
|
|
54
|
+
return (0, _jsxRuntime.jsxs)("div", {
|
|
55
|
+
...classes('form'),
|
|
56
|
+
children: [(0, _jsxRuntime.jsx)("input", {
|
|
57
|
+
...classes('form-query'),
|
|
58
|
+
type: "text",
|
|
59
|
+
onChange: this.handleQueryChange,
|
|
60
|
+
onKeyPress: this.onKeyPress,
|
|
61
|
+
value: this.state.query,
|
|
62
|
+
placeholder: translations.searchPlaceholder
|
|
63
|
+
}), (0, _jsxRuntime.jsx)(_button.ButtonV2, {
|
|
64
|
+
...classes('form-button'),
|
|
65
|
+
onClick: this.handleSubmit,
|
|
66
|
+
disabled: searching,
|
|
67
|
+
children: translations.searchButtonTitle
|
|
68
|
+
})]
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
97
72
|
SearchForm.propTypes = {
|
|
98
73
|
query: _propTypes.default.string,
|
|
99
74
|
searching: _propTypes.default.bool.isRequired,
|
|
@@ -106,5 +81,4 @@ SearchForm.propTypes = {
|
|
|
106
81
|
SearchForm.defaultProps = {
|
|
107
82
|
query: ''
|
|
108
83
|
};
|
|
109
|
-
var _default = SearchForm;
|
|
110
|
-
exports.default = _default;
|
|
84
|
+
var _default = exports.default = SearchForm;
|
package/lib/VideoSearchList.js
CHANGED
|
@@ -11,66 +11,63 @@ var _VideoSearchResultBrightcove = _interopRequireDefault(require("./VideoSearch
|
|
|
11
11
|
var _VideoSearchResultYouTube = _interopRequireDefault(require("./VideoSearchResultYouTube"));
|
|
12
12
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
* LICENSE file in the root directory of this source tree.
|
|
24
|
-
*
|
|
25
|
-
*/
|
|
26
|
-
var classes = new _reactBemHelper.default({
|
|
14
|
+
/**
|
|
15
|
+
* Copyright (c) 2017-present, NDLA.
|
|
16
|
+
*
|
|
17
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
18
|
+
* LICENSE file in the root directory of this source tree.
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const classes = new _reactBemHelper.default({
|
|
27
23
|
name: 'video-search',
|
|
28
24
|
prefix: 'c-'
|
|
29
25
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
const VideoSearchList = props => {
|
|
27
|
+
const {
|
|
28
|
+
videos,
|
|
29
|
+
locale,
|
|
30
|
+
translations,
|
|
31
|
+
selectedType,
|
|
32
|
+
selectedVideo,
|
|
33
|
+
onSelectVideo,
|
|
34
|
+
onVideoPreview,
|
|
35
|
+
searching
|
|
36
|
+
} = props;
|
|
39
37
|
if ((!videos || videos.length === 0) && !searching) {
|
|
40
38
|
return (0, _jsxRuntime.jsx)("p", {
|
|
41
39
|
children: translations.noResults
|
|
42
40
|
});
|
|
43
41
|
}
|
|
44
42
|
if (searching && !(videos.length > 0)) {
|
|
45
|
-
return (0, _jsxRuntime.jsx)("div",
|
|
43
|
+
return (0, _jsxRuntime.jsx)("div", {
|
|
44
|
+
...classes('result-spinner')
|
|
45
|
+
});
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
const videoresults = () => {
|
|
48
48
|
if (selectedType === 'youtube') {
|
|
49
|
-
return videos.map(
|
|
50
|
-
return (0, _jsxRuntime.jsx)(_VideoSearchResultYouTube.default, {
|
|
51
|
-
video: video,
|
|
52
|
-
onVideoPreview: onVideoPreview,
|
|
53
|
-
selectedVideo: selectedVideo,
|
|
54
|
-
onSelectVideo: onSelectVideo,
|
|
55
|
-
translations: translations,
|
|
56
|
-
locale: locale
|
|
57
|
-
}, video.cacheId);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return videos.map(function (video) {
|
|
61
|
-
return (0, _jsxRuntime.jsx)(_VideoSearchResultBrightcove.default, {
|
|
49
|
+
return videos.map(video => (0, _jsxRuntime.jsx)(_VideoSearchResultYouTube.default, {
|
|
62
50
|
video: video,
|
|
63
51
|
onVideoPreview: onVideoPreview,
|
|
64
52
|
selectedVideo: selectedVideo,
|
|
65
53
|
onSelectVideo: onSelectVideo,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}, video.
|
|
69
|
-
}
|
|
54
|
+
translations: translations,
|
|
55
|
+
locale: locale
|
|
56
|
+
}, video.cacheId));
|
|
57
|
+
}
|
|
58
|
+
return videos.map(video => (0, _jsxRuntime.jsx)(_VideoSearchResultBrightcove.default, {
|
|
59
|
+
video: video,
|
|
60
|
+
onVideoPreview: onVideoPreview,
|
|
61
|
+
selectedVideo: selectedVideo,
|
|
62
|
+
onSelectVideo: onSelectVideo,
|
|
63
|
+
locale: locale,
|
|
64
|
+
translations: translations
|
|
65
|
+
}, video.id));
|
|
70
66
|
};
|
|
71
|
-
return (0, _jsxRuntime.jsx)("div",
|
|
67
|
+
return (0, _jsxRuntime.jsx)("div", {
|
|
68
|
+
...classes('list-inner'),
|
|
72
69
|
children: videoresults()
|
|
73
|
-
})
|
|
70
|
+
});
|
|
74
71
|
};
|
|
75
72
|
VideoSearchList.propTypes = {
|
|
76
73
|
onSelectVideo: _propTypes.default.func.isRequired,
|
|
@@ -86,5 +83,4 @@ VideoSearchList.propTypes = {
|
|
|
86
83
|
}),
|
|
87
84
|
locale: _propTypes.default.string.isRequired
|
|
88
85
|
};
|
|
89
|
-
var _default = VideoSearchList;
|
|
90
|
-
exports.default = _default;
|
|
86
|
+
var _default = exports.default = VideoSearchList;
|
|
@@ -5,86 +5,87 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = VideoSearchResultBrightcove;
|
|
7
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _reactBemHelper = _interopRequireDefault(require("react-bem-helper"));
|
|
8
9
|
var _button = require("@ndla/button");
|
|
10
|
+
var _common = require("@ndla/icons/common");
|
|
9
11
|
var _licenses = require("@ndla/licenses");
|
|
10
12
|
var _notion = require("@ndla/notion");
|
|
11
|
-
var _common = require("@ndla/icons/common");
|
|
12
|
-
var _reactBemHelper = _interopRequireDefault(require("react-bem-helper"));
|
|
13
13
|
var _PreviewVideo = _interopRequireDefault(require("./PreviewVideo"));
|
|
14
14
|
var _shapes = require("./shapes");
|
|
15
15
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* LICENSE file in the root directory of this source tree.
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
var classes = new _reactBemHelper.default({
|
|
17
|
+
/**
|
|
18
|
+
* Copyright (c) 2017-present, NDLA.
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
21
|
+
* LICENSE file in the root directory of this source tree.
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const classes = new _reactBemHelper.default({
|
|
30
26
|
name: 'video-search',
|
|
31
27
|
prefix: 'c-'
|
|
32
28
|
});
|
|
33
29
|
function VideoSearchResultBrightcove(_ref) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
30
|
+
let {
|
|
31
|
+
video,
|
|
32
|
+
onVideoPreview,
|
|
33
|
+
selectedVideo,
|
|
34
|
+
onSelectVideo,
|
|
35
|
+
locale,
|
|
36
|
+
translations
|
|
37
|
+
} = _ref;
|
|
38
|
+
const active = selectedVideo && selectedVideo.id === video.id ? 'active' : '';
|
|
39
|
+
const license = video.custom_fields && video.custom_fields.license ? (0, _licenses.getLicenseByNBTitle)(video.custom_fields.license, locale) : '';
|
|
40
|
+
const thumbnailSource = video.images && video.images.thumbnail ? video.images.thumbnail.src : '';
|
|
41
|
+
const is360video = video.projection === 'equirectangular';
|
|
42
|
+
return (0, _jsxRuntime.jsxs)("div", {
|
|
43
|
+
...classes('list-item', active),
|
|
44
|
+
children: [(0, _jsxRuntime.jsxs)("div", {
|
|
45
|
+
...classes('list-item-inner'),
|
|
46
46
|
children: [(0, _jsxRuntime.jsx)("img", {
|
|
47
47
|
role: "presentation",
|
|
48
48
|
alt: "presentation",
|
|
49
49
|
src: thumbnailSource
|
|
50
|
-
}), (0, _jsxRuntime.jsxs)("div",
|
|
51
|
-
|
|
50
|
+
}), (0, _jsxRuntime.jsxs)("div", {
|
|
51
|
+
...classes('information'),
|
|
52
|
+
children: [(0, _jsxRuntime.jsxs)("h2", {
|
|
53
|
+
...classes('header'),
|
|
52
54
|
children: [video.name || '', is360video && (0, _jsxRuntime.jsx)(_common.PanoramaPhotosphere, {})]
|
|
53
|
-
})
|
|
55
|
+
}), (0, _jsxRuntime.jsx)("div", {
|
|
56
|
+
...classes('copyright-author'),
|
|
54
57
|
children: video.custom_fields && video.custom_fields.licenseinfo ? video.custom_fields.licenseinfo : ''
|
|
55
|
-
})
|
|
58
|
+
}), (0, _jsxRuntime.jsx)("div", {
|
|
59
|
+
...classes('license'),
|
|
56
60
|
children: license.rights ? (0, _jsxRuntime.jsx)(_notion.LicenseByline, {
|
|
57
61
|
licenseRights: license.rights,
|
|
58
62
|
locale: locale
|
|
59
63
|
}) : license
|
|
60
|
-
})
|
|
64
|
+
}), (0, _jsxRuntime.jsx)(_button.ButtonV2, {
|
|
65
|
+
...classes('button'),
|
|
61
66
|
variant: "outline",
|
|
62
|
-
onClick:
|
|
63
|
-
return onVideoPreview(video);
|
|
64
|
-
},
|
|
67
|
+
onClick: () => onVideoPreview(video),
|
|
65
68
|
children: translations.previewVideo
|
|
66
|
-
})
|
|
67
|
-
"data-testid": "use-video"
|
|
68
|
-
|
|
69
|
-
onClick:
|
|
70
|
-
return onSelectVideo(video);
|
|
71
|
-
},
|
|
69
|
+
}), (0, _jsxRuntime.jsx)(_button.ButtonV2, {
|
|
70
|
+
"data-testid": "use-video",
|
|
71
|
+
...classes('button'),
|
|
72
|
+
onClick: () => onSelectVideo(video),
|
|
72
73
|
children: translations.addVideo
|
|
73
|
-
})
|
|
74
|
-
})
|
|
75
|
-
})
|
|
74
|
+
})]
|
|
75
|
+
})]
|
|
76
|
+
}), selectedVideo && selectedVideo.id === video.id ? (0, _jsxRuntime.jsx)(_PreviewVideo.default, {
|
|
76
77
|
onVideoPreview: onVideoPreview,
|
|
77
78
|
selectedType: "brightcove",
|
|
78
79
|
children: (0, _jsxRuntime.jsx)("iframe", {
|
|
79
80
|
className: "c-video-preview__video",
|
|
80
81
|
title: selectedVideo.name,
|
|
81
|
-
src:
|
|
82
|
+
src: `//players.brightcove.net/${selectedVideo.account_id}/BkLm8fT_default/index.html?videoId=${selectedVideo.id}`
|
|
82
83
|
// eslint-disable-next-line react/no-unknown-property
|
|
83
84
|
,
|
|
84
85
|
allowFullScreen: true
|
|
85
86
|
})
|
|
86
87
|
}) : '']
|
|
87
|
-
}
|
|
88
|
+
}, video.id);
|
|
88
89
|
}
|
|
89
90
|
VideoSearchResultBrightcove.propTypes = {
|
|
90
91
|
license: _shapes.LicenseShape,
|
|
@@ -5,73 +5,70 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = VideoSearchResultYouTube;
|
|
7
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
-
var _button = require("@ndla/button");
|
|
9
8
|
var _reactBemHelper = _interopRequireDefault(require("react-bem-helper"));
|
|
9
|
+
var _button = require("@ndla/button");
|
|
10
10
|
var _PreviewVideo = _interopRequireDefault(require("./PreviewVideo"));
|
|
11
11
|
var _shapes = require("./shapes");
|
|
12
12
|
var _videoHelpers = require("./videoHelpers");
|
|
13
13
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*
|
|
26
|
-
*/
|
|
27
|
-
var classes = new _reactBemHelper.default({
|
|
15
|
+
/**
|
|
16
|
+
* Copyright (c) 2017-present, NDLA.
|
|
17
|
+
*
|
|
18
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
19
|
+
* LICENSE file in the root directory of this source tree.
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const classes = new _reactBemHelper.default({
|
|
28
24
|
name: 'video-search',
|
|
29
25
|
prefix: 'c-'
|
|
30
26
|
});
|
|
31
27
|
function VideoSearchResultYouTube(_ref) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
onVideoPreview
|
|
35
|
-
selectedVideo
|
|
36
|
-
onSelectVideo
|
|
37
|
-
translations
|
|
38
|
-
locale
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
let {
|
|
29
|
+
video,
|
|
30
|
+
onVideoPreview,
|
|
31
|
+
selectedVideo,
|
|
32
|
+
onSelectVideo,
|
|
33
|
+
translations,
|
|
34
|
+
locale
|
|
35
|
+
} = _ref;
|
|
36
|
+
const videoData = video?.pagemap?.videoobject?.[0];
|
|
37
|
+
const activeVideo = selectedVideo?.pagemap?.videoobject?.[0]?.videoid === videoData?.videoid;
|
|
41
38
|
if (videoData) {
|
|
42
|
-
return (0, _jsxRuntime.jsxs)("div",
|
|
43
|
-
|
|
39
|
+
return (0, _jsxRuntime.jsxs)("div", {
|
|
40
|
+
...classes('list-item', activeVideo ? 'active' : ''),
|
|
41
|
+
children: [(0, _jsxRuntime.jsxs)("div", {
|
|
42
|
+
...classes('list-item-inner'),
|
|
44
43
|
children: [(0, _jsxRuntime.jsx)("img", {
|
|
45
44
|
role: "presentation",
|
|
46
45
|
alt: "presentation",
|
|
47
46
|
src: videoData.thumbnailurl
|
|
48
|
-
}), (0, _jsxRuntime.jsxs)("div",
|
|
47
|
+
}), (0, _jsxRuntime.jsxs)("div", {
|
|
48
|
+
...classes('information'),
|
|
49
49
|
children: [(0, _jsxRuntime.jsx)("h2", {
|
|
50
50
|
children: videoData.name
|
|
51
51
|
}), (0, _jsxRuntime.jsx)("div", {
|
|
52
|
-
children:
|
|
52
|
+
children: `${translations.publishedDate}: ${(0, _videoHelpers.setLocaleDate)(videoData.datepublished, locale)}`
|
|
53
53
|
}), (0, _jsxRuntime.jsx)("div", {
|
|
54
|
-
children:
|
|
54
|
+
children: `${translations.duration}: ${(0, _videoHelpers.setYouTubeDuration)(videoData.duration)}`
|
|
55
55
|
}), (0, _jsxRuntime.jsx)("div", {
|
|
56
|
-
children:
|
|
56
|
+
children: `${translations.interactioncount}: ${videoData.interactioncount}`
|
|
57
57
|
}), (0, _jsxRuntime.jsx)("div", {
|
|
58
58
|
children: videoData.description
|
|
59
|
-
}), (0, _jsxRuntime.jsx)(_button.ButtonV2,
|
|
59
|
+
}), (0, _jsxRuntime.jsx)(_button.ButtonV2, {
|
|
60
|
+
...classes('button'),
|
|
60
61
|
variant: "outline",
|
|
61
|
-
onClick:
|
|
62
|
-
return onVideoPreview(video);
|
|
63
|
-
},
|
|
62
|
+
onClick: () => onVideoPreview(video),
|
|
64
63
|
children: translations.previewVideo
|
|
65
|
-
})
|
|
66
|
-
"data-testid": "use-video"
|
|
67
|
-
|
|
68
|
-
onClick:
|
|
69
|
-
return onSelectVideo(video);
|
|
70
|
-
},
|
|
64
|
+
}), (0, _jsxRuntime.jsx)(_button.ButtonV2, {
|
|
65
|
+
"data-testid": "use-video",
|
|
66
|
+
...classes('button'),
|
|
67
|
+
onClick: () => onSelectVideo(video),
|
|
71
68
|
children: translations.addVideo
|
|
72
|
-
})
|
|
73
|
-
})
|
|
74
|
-
})
|
|
69
|
+
})]
|
|
70
|
+
})]
|
|
71
|
+
}), activeVideo ? (0, _jsxRuntime.jsx)(_PreviewVideo.default, {
|
|
75
72
|
onVideoPreview: onVideoPreview,
|
|
76
73
|
selectedType: "youtube",
|
|
77
74
|
children: (0, _jsxRuntime.jsx)("iframe", {
|
|
@@ -83,7 +80,7 @@ function VideoSearchResultYouTube(_ref) {
|
|
|
83
80
|
allowFullScreen: true
|
|
84
81
|
})
|
|
85
82
|
}) : '']
|
|
86
|
-
})
|
|
83
|
+
});
|
|
87
84
|
} else {
|
|
88
85
|
return (0, _jsxRuntime.jsx)("div", {});
|
|
89
86
|
}
|
package/lib/VideoTabs.js
CHANGED
|
@@ -4,31 +4,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _react = require("react");
|
|
9
9
|
var _tabs = _interopRequireDefault(require("@ndla/tabs"));
|
|
10
10
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var _useState = (0, _react.useState)(undefined),
|
|
28
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
29
|
-
selectedTab = _useState2[0],
|
|
30
|
-
setSelectedTab = _useState2[1];
|
|
31
|
-
var handleOnSelect = function handleOnSelect(value) {
|
|
12
|
+
/**
|
|
13
|
+
* Copyright (c) 2016-present, NDLA.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const VideoTabs = _ref => {
|
|
21
|
+
let {
|
|
22
|
+
onSearchTypeChange,
|
|
23
|
+
tabs
|
|
24
|
+
} = _ref;
|
|
25
|
+
const [selectedTab, setSelectedTab] = (0, _react.useState)(undefined);
|
|
26
|
+
const handleOnSelect = value => {
|
|
32
27
|
setSelectedTab(value);
|
|
33
28
|
onSearchTypeChange(value);
|
|
34
29
|
};
|
|
@@ -46,5 +41,4 @@ VideoTabs.propTypes = {
|
|
|
46
41
|
content: _propTypes.default.node
|
|
47
42
|
})).isRequired
|
|
48
43
|
};
|
|
49
|
-
var _default = VideoTabs;
|
|
50
|
-
exports.default = _default;
|
|
44
|
+
var _default = exports.default = VideoTabs;
|