@ndla/video-search 4.1.47 → 5.0.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.
@@ -1,101 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = VideoSearchResultBrightcove;
7
- var _propTypes = _interopRequireDefault(require("prop-types"));
8
- var _reactBemHelper = _interopRequireDefault(require("react-bem-helper"));
9
- var _button = require("@ndla/button");
10
- var _common = require("@ndla/icons/common");
11
- var _licenses = require("@ndla/licenses");
12
- var _notion = require("@ndla/notion");
13
- var _PreviewVideo = _interopRequireDefault(require("./PreviewVideo"));
14
- var _shapes = require("./shapes");
15
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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({
26
- name: 'video-search',
27
- prefix: 'c-'
28
- });
29
- function VideoSearchResultBrightcove(_ref) {
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
- children: [(0, _jsxRuntime.jsx)("img", {
47
- role: "presentation",
48
- alt: "presentation",
49
- src: thumbnailSource
50
- }), (0, _jsxRuntime.jsxs)("div", {
51
- ...classes('information'),
52
- children: [(0, _jsxRuntime.jsxs)("h2", {
53
- ...classes('header'),
54
- children: [video.name || '', is360video && (0, _jsxRuntime.jsx)(_common.PanoramaPhotosphere, {})]
55
- }), (0, _jsxRuntime.jsx)("div", {
56
- ...classes('copyright-author'),
57
- children: video.custom_fields && video.custom_fields.licenseinfo ? video.custom_fields.licenseinfo : ''
58
- }), (0, _jsxRuntime.jsx)("div", {
59
- ...classes('license'),
60
- children: license.rights ? (0, _jsxRuntime.jsx)(_notion.LicenseByline, {
61
- licenseRights: license.rights,
62
- locale: locale
63
- }) : license
64
- }), (0, _jsxRuntime.jsx)(_button.ButtonV2, {
65
- ...classes('button'),
66
- variant: "outline",
67
- onClick: () => onVideoPreview(video),
68
- children: translations.previewVideo
69
- }), (0, _jsxRuntime.jsx)(_button.ButtonV2, {
70
- "data-testid": "use-video",
71
- ...classes('button'),
72
- onClick: () => onSelectVideo(video),
73
- children: translations.addVideo
74
- })]
75
- })]
76
- }), selectedVideo && selectedVideo.id === video.id ? (0, _jsxRuntime.jsx)(_PreviewVideo.default, {
77
- onVideoPreview: onVideoPreview,
78
- selectedType: "brightcove",
79
- children: (0, _jsxRuntime.jsx)("iframe", {
80
- className: "c-video-preview__video",
81
- title: selectedVideo.name,
82
- src: `//players.brightcove.net/${selectedVideo.account_id}/BkLm8fT_default/index.html?videoId=${selectedVideo.id}`
83
- // eslint-disable-next-line react/no-unknown-property
84
- ,
85
- allowFullScreen: true
86
- })
87
- }) : '']
88
- }, video.id);
89
- }
90
- VideoSearchResultBrightcove.propTypes = {
91
- license: _shapes.LicenseShape,
92
- video: _shapes.BrightcoveShape.isRequired,
93
- onVideoPreview: _propTypes.default.func.isRequired,
94
- selectedVideo: _shapes.BrightcoveShape,
95
- onSelectVideo: _propTypes.default.func.isRequired,
96
- locale: _propTypes.default.string.isRequired,
97
- translations: _propTypes.default.shape({
98
- addVideo: _propTypes.default.string.isRequired,
99
- previewVideo: _propTypes.default.string.isRequired
100
- })
101
- };
@@ -1,99 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = VideoSearchResultYouTube;
7
- var _propTypes = _interopRequireDefault(require("prop-types"));
8
- var _reactBemHelper = _interopRequireDefault(require("react-bem-helper"));
9
- var _button = require("@ndla/button");
10
- var _PreviewVideo = _interopRequireDefault(require("./PreviewVideo"));
11
- var _shapes = require("./shapes");
12
- var _videoHelpers = require("./videoHelpers");
13
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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({
24
- name: 'video-search',
25
- prefix: 'c-'
26
- });
27
- function VideoSearchResultYouTube(_ref) {
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;
38
- if (videoData) {
39
- return (0, _jsxRuntime.jsxs)("div", {
40
- ...classes('list-item', activeVideo ? 'active' : ''),
41
- children: [(0, _jsxRuntime.jsxs)("div", {
42
- ...classes('list-item-inner'),
43
- children: [(0, _jsxRuntime.jsx)("img", {
44
- role: "presentation",
45
- alt: "presentation",
46
- src: videoData.thumbnailurl
47
- }), (0, _jsxRuntime.jsxs)("div", {
48
- ...classes('information'),
49
- children: [(0, _jsxRuntime.jsx)("h2", {
50
- children: videoData.name
51
- }), (0, _jsxRuntime.jsx)("div", {
52
- children: `${translations.publishedDate}: ${(0, _videoHelpers.setLocaleDate)(videoData.datepublished, locale)}`
53
- }), (0, _jsxRuntime.jsx)("div", {
54
- children: `${translations.duration}: ${(0, _videoHelpers.setYouTubeDuration)(videoData.duration)}`
55
- }), (0, _jsxRuntime.jsx)("div", {
56
- children: `${translations.interactioncount}: ${videoData.interactioncount}`
57
- }), (0, _jsxRuntime.jsx)("div", {
58
- children: videoData.description
59
- }), (0, _jsxRuntime.jsx)(_button.ButtonV2, {
60
- ...classes('button'),
61
- variant: "outline",
62
- onClick: () => onVideoPreview(video),
63
- children: translations.previewVideo
64
- }), (0, _jsxRuntime.jsx)(_button.ButtonV2, {
65
- "data-testid": "use-video",
66
- ...classes('button'),
67
- onClick: () => onSelectVideo(video),
68
- children: translations.addVideo
69
- })]
70
- })]
71
- }), activeVideo ? (0, _jsxRuntime.jsx)(_PreviewVideo.default, {
72
- onVideoPreview: onVideoPreview,
73
- selectedType: "youtube",
74
- children: (0, _jsxRuntime.jsx)("iframe", {
75
- className: "c-video-preview__video",
76
- title: selectedVideo.title,
77
- src: selectedVideo.pagemap.videoobject[0].embedurl
78
- // eslint-disable-next-line react/no-unknown-property
79
- ,
80
- allowFullScreen: true
81
- })
82
- }) : '']
83
- });
84
- } else {
85
- return (0, _jsxRuntime.jsx)("div", {});
86
- }
87
- }
88
- VideoSearchResultYouTube.propTypes = {
89
- video: _shapes.YouTubeShape.isRequired,
90
- onVideoPreview: _propTypes.default.func.isRequired,
91
- selectedVideo: _shapes.YouTubeShape,
92
- onSelectVideo: _propTypes.default.func.isRequired,
93
- locale: _propTypes.default.string.isRequired,
94
- translations: _propTypes.default.shape({
95
- addVideo: _propTypes.default.string.isRequired,
96
- previewVideo: _propTypes.default.string.isRequired,
97
- publishedDate: _propTypes.default.string.isRequired
98
- })
99
- };
package/lib/VideoTabs.js DELETED
@@ -1,44 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _propTypes = _interopRequireDefault(require("prop-types"));
8
- var _react = require("react");
9
- var _tabs = _interopRequireDefault(require("@ndla/tabs"));
10
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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 => {
27
- setSelectedTab(value);
28
- onSearchTypeChange(value);
29
- };
30
- return (0, _jsxRuntime.jsx)(_tabs.default, {
31
- value: selectedTab,
32
- onValueChange: handleOnSelect,
33
- tabs: tabs
34
- });
35
- };
36
- VideoTabs.propTypes = {
37
- onSearchTypeChange: _propTypes.default.func.isRequired,
38
- tabs: _propTypes.default.arrayOf(_propTypes.default.shape({
39
- type: _propTypes.default.string,
40
- id: _propTypes.default.string,
41
- content: _propTypes.default.node
42
- })).isRequired
43
- };
44
- var _default = exports.default = VideoTabs;
package/lib/shapes.js DELETED
@@ -1,50 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.YouTubeShape = exports.LicenseShape = exports.BrightcoveShape = void 0;
7
- var _propTypes = _interopRequireDefault(require("prop-types"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- /**
10
- * Copyright (c) 2017-present, NDLA.
11
- *
12
- * This source code is licensed under the GPLv3 license found in the
13
- * LICENSE file in the root directory of this source tree.
14
- *
15
- */
16
-
17
- const LicenseShape = exports.LicenseShape = _propTypes.default.shape({
18
- short: _propTypes.default.string.isRequired,
19
- title: _propTypes.default.string.isRequired,
20
- userFriendlyTitle: _propTypes.default.string.isRequired,
21
- description: _propTypes.default.string.isRequired,
22
- rights: _propTypes.default.arrayOf(_propTypes.default.string).isRequired
23
- });
24
- const BrightcoveShape = exports.BrightcoveShape = _propTypes.default.shape({
25
- id: _propTypes.default.string.isRequired,
26
- name: _propTypes.default.string.isRequired,
27
- custom_fields: _propTypes.default.shape({
28
- licenseinfo: _propTypes.default.string.isRequired,
29
- license: _propTypes.default.string.isRequired
30
- }),
31
- images: _propTypes.default.shape({
32
- thumbnail: _propTypes.default.shape({
33
- src: _propTypes.default.string.isRequired
34
- })
35
- })
36
- });
37
- const YouTubeShape = exports.YouTubeShape = _propTypes.default.shape({
38
- pagemap: _propTypes.default.shape({
39
- videoobject: _propTypes.default.arrayOf(_propTypes.default.shape({
40
- name: _propTypes.default.string.isRequired,
41
- description: _propTypes.default.string.isRequired,
42
- videoid: _propTypes.default.string.isRequired,
43
- duration: _propTypes.default.string.isRequired,
44
- thumbnailurl: _propTypes.default.string.isRequired,
45
- embedurl: _propTypes.default.string.isRequired,
46
- interactioncount: _propTypes.default.string.isRequired,
47
- datepublished: _propTypes.default.string.isRequired
48
- }))
49
- })
50
- });
@@ -1,53 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.youTubeDurationToSeconds = exports.setYouTubeDuration = exports.setLocaleDate = exports.getLastPage = void 0;
7
- /**
8
- * Copyright (c) 2017-present, NDLA.
9
- *
10
- * This source code is licensed under the GPLv3 license found in the
11
- * LICENSE file in the root directory of this source tree.
12
- *
13
- */
14
-
15
- const getLastPage = (search, type) => {
16
- if (type === 'youtube') {
17
- if (search?.queries?.request?.length > 0) {
18
- const request = search.queries.request[0];
19
- if (request.totalResults && request.count) {
20
- return Math.ceil(request.totalResults / request.count);
21
- }
22
- return 0;
23
- }
24
- }
25
- return 0;
26
- };
27
- exports.getLastPage = getLastPage;
28
- const youTubeDurationToSeconds = duration => {
29
- const match = duration.match(/PT(\d+H)?(\d+M)?(\d+S)?/);
30
- const hours = parseInt(match[1], 10) || 0;
31
- const minutes = parseInt(match[2], 10) || 0;
32
- const seconds = parseInt(match[3], 10) || 0;
33
- return hours * 3600 + minutes * 60 + seconds;
34
- };
35
- exports.youTubeDurationToSeconds = youTubeDurationToSeconds;
36
- const setLocaleDate = (date, locale) => {
37
- const newDate = new Date(Date.parse(date));
38
- const options = {
39
- year: 'numeric',
40
- month: '2-digit',
41
- day: '2-digit'
42
- };
43
- return newDate.toLocaleDateString(locale, options);
44
- };
45
- exports.setLocaleDate = setLocaleDate;
46
- const setYouTubeDuration = duration => {
47
- const seconds = youTubeDurationToSeconds(duration);
48
- if (seconds > 86400) {
49
- return `24h+ ${new Date(seconds * 1000).toISOString().substr(11, 8)}`;
50
- }
51
- return new Date(seconds * 1000).toISOString().substr(11, 8);
52
- };
53
- exports.setYouTubeDuration = setYouTubeDuration;
@@ -1,245 +0,0 @@
1
- /**
2
- * Copyright (c) 2016-present, NDLA.
3
- *
4
- * This source code is licensed under the GPLv3 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
- $medium-viewport: '(max-width: 800px)';
10
- $small-viewport: '(max-width: 600px)';
11
-
12
- .c-video-search {
13
- padding: 1rem;
14
- border: 1px solid $brand-color--lighter;
15
- border-radius: 0.2rem;
16
- &__form-query {
17
- width: 88%;
18
- height: 3rem;
19
- margin-top: 0;
20
- margin-bottom: 0;
21
- box-shadow: none;
22
- border-width: 2px;
23
- float: left;
24
- border-radius: 5px 0 0 5px;
25
- }
26
-
27
- &__border {
28
- margin: 1em -2em;
29
- height: 1px;
30
- border-bottom: 1px solid $brand-color--lighter;
31
- }
32
-
33
- &__form {
34
- width: 100%;
35
- padding-left: 0;
36
- padding-right: 0;
37
- margin-bottom: 1em;
38
- padding-bottom: 1em;
39
- border-bottom: 1px solid #eaeaea;
40
- }
41
-
42
- &__form-button {
43
- width: 12%;
44
- height: 3rem;
45
- display: inline-block;
46
- margin-left: -2px;
47
- border-radius: 0 5px 5px 0;
48
- padding: 0.4em;
49
-
50
- &:hover {
51
- transform: none;
52
- }
53
- }
54
-
55
- &__search-form .search-form_btn--gray .icon {
56
- font-size: 1.5em;
57
- }
58
-
59
- &__list-item {
60
- width: 100%;
61
- margin-bottom: 3rem;
62
- }
63
-
64
- &__list-item:first-child {
65
- margin-top: 1rem;
66
- }
67
-
68
- &__list-item {
69
- &--active {
70
- height: inherit;
71
- }
72
- }
73
-
74
- &__list {
75
- display: flex;
76
- align-items: stretch;
77
- flex-flow: row wrap;
78
- position: relative;
79
- }
80
-
81
- &__list-inner {
82
- width: 100%;
83
- }
84
-
85
- &__list-item-inner {
86
- display: flex;
87
- align-items: flex-start;
88
- }
89
-
90
- &__list-item-inner img {
91
- width: 30%;
92
- }
93
-
94
- &__information {
95
- width: 70%;
96
- display: inline-block;
97
- padding-left: 2rem;
98
- }
99
-
100
- &__information > * {
101
- margin-top: 0.5rem;
102
- }
103
-
104
- &__header {
105
- margin-top: 0;
106
- line-height: 1;
107
- }
108
-
109
- &__header > svg {
110
- color: $brand-color;
111
- margin-left: 0.5rem;
112
- width: 1.5rem;
113
- height: 1.5rem;
114
- }
115
-
116
- &__title {
117
- padding-top: 0;
118
- margin: 0;
119
- }
120
-
121
- &__tags > b {
122
- display: block;
123
- margin-bottom: 1em;
124
- }
125
-
126
- &__tags > .tag_item {
127
- color: black;
128
- font-weight: 600;
129
- margin-right: 0.5em;
130
- margin-bottom: 0.4em;
131
- display: inline-block;
132
- }
133
-
134
- &__tags > .tag_item:hover {
135
- text-decoration: none;
136
- }
137
-
138
- &__button + &__button {
139
- margin-left: 0.5rem;
140
- }
141
-
142
- &__load-videos {
143
- width: 100%;
144
- text-align: center;
145
- }
146
-
147
- &__result-spinner,
148
- &__spinner {
149
- border: 0.4em solid $brand-grey--light;
150
- border-bottom-color: $brand-color;
151
- border-radius: 50%;
152
- margin: 0 auto;
153
- animation: loadVideoSpinner 0.7s linear infinite;
154
- }
155
-
156
- &__result-spinner {
157
- height: 3em;
158
- width: 3em;
159
- }
160
-
161
- &__spinner {
162
- border-color: $brand-grey;
163
- border-bottom-color: $brand-color;
164
- width: 2em;
165
- height: 2em;
166
- }
167
- }
168
-
169
- .c-video-preview {
170
- margin-top: 1rem;
171
- background-color: $brand-color--lighter;
172
- padding: 1rem;
173
-
174
- &__video {
175
- border: none;
176
- min-height: 300px;
177
- }
178
-
179
- &__close {
180
- float: right;
181
- height: 44px;
182
- width: 44px;
183
- margin-top: -20px;
184
- margin-right: -7px;
185
- color: red;
186
- }
187
-
188
- &__close svg {
189
- float: right;
190
- height: 15px;
191
- width: 15px;
192
- margin-right: 7px;
193
- color: $brand-grey;
194
- }
195
- }
196
-
197
- @media #{$medium-viewport} {
198
- .c-video-search {
199
- &__list-item-inner img {
200
- width: 100%;
201
- }
202
-
203
- &__information {
204
- width: 100%;
205
- display: block;
206
- padding-left: 0;
207
- padding-top: 2rem;
208
- }
209
- &__list-item-inner {
210
- flex-direction: column;
211
- }
212
- &__form-button {
213
- width: 20%;
214
- }
215
- &__form-query {
216
- width: 80%;
217
- }
218
- }
219
- }
220
-
221
- @media #{$small-viewport} {
222
- .c-video-search {
223
- &__button {
224
- display: block;
225
- }
226
- &__button + &__button {
227
- margin-left: 0;
228
- }
229
- &__form-button {
230
- width: 30%;
231
- }
232
- &__form-query {
233
- width: 70%;
234
- }
235
- }
236
- }
237
-
238
- @keyframes loadVideoSpinner {
239
- 0% {
240
- transform: rotate(0deg);
241
- }
242
- 100% {
243
- transform: rotate(360deg);
244
- }
245
- }