@quintype/components 3.8.2 → 3.8.3-youtube-button.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/cjs/index.js
CHANGED
|
@@ -3272,7 +3272,7 @@ function loadLibrary() {
|
|
|
3272
3272
|
'react-youtube')); }).then(function (YT) {
|
|
3273
3273
|
YouTube = YT["default"];
|
|
3274
3274
|
})["catch"](function (err) {
|
|
3275
|
-
console.log(
|
|
3275
|
+
console.log('Failed to load react-youtube', err);
|
|
3276
3276
|
return Promise.reject();
|
|
3277
3277
|
});
|
|
3278
3278
|
}
|
|
@@ -3284,6 +3284,26 @@ function isLibraryLoaded() {
|
|
|
3284
3284
|
return YouTube !== null;
|
|
3285
3285
|
}
|
|
3286
3286
|
|
|
3287
|
+
function getYoutubeButton(onClick) {
|
|
3288
|
+
return /*#__PURE__*/React__default["default"].createElement("button", {
|
|
3289
|
+
onClick: onClick,
|
|
3290
|
+
className: "youtube-playBtn",
|
|
3291
|
+
"aria-label": "Play Video"
|
|
3292
|
+
}, /*#__PURE__*/React__default["default"].createElement("svg", {
|
|
3293
|
+
width: "68",
|
|
3294
|
+
height: "48",
|
|
3295
|
+
viewBox: "0 0 68 48",
|
|
3296
|
+
fill: "none",
|
|
3297
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
3298
|
+
}, /*#__PURE__*/React__default["default"].createElement("path", {
|
|
3299
|
+
d: "M66.52 7.74C65.74 4.81 64.03 2.33 61.1 1.55C55.79 0.13 34 0 34 0C34 0 12.21 0.13 6.9 1.55C3.97 2.33 2.27 4.81 1.48 7.74C0.0600001 13.05 0 24 0 24C0 24 0.0600001 34.95 1.48 40.26C2.26 43.19 3.97 45.67 6.9 46.45C12.21 47.87 34 48 34 48C34 48 55.79 47.87 61.1 46.45C64.03 45.67 65.74 43.19 66.52 40.26C67.94 34.95 68 24 68 24C68 24 67.94 13.05 66.52 7.74Z",
|
|
3300
|
+
fill: "#FF0000"
|
|
3301
|
+
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
3302
|
+
d: "M43 24L25 14V34",
|
|
3303
|
+
fill: "white"
|
|
3304
|
+
})));
|
|
3305
|
+
}
|
|
3306
|
+
|
|
3287
3307
|
var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
|
|
3288
3308
|
_inherits__default["default"](CustomStoryElementYoutube, _React$Component);
|
|
3289
3309
|
|
|
@@ -3317,24 +3337,24 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
|
|
|
3317
3337
|
element = _this$props$element === void 0 ? {} : _this$props$element;
|
|
3318
3338
|
|
|
3319
3339
|
var qliticsData = _objectSpread$3(_objectSpread$3({}, getQliticsSchema(story, card, element)), {
|
|
3320
|
-
|
|
3340
|
+
'story-element-action': action
|
|
3321
3341
|
});
|
|
3322
3342
|
|
|
3323
3343
|
if (global.qlitics) {
|
|
3324
|
-
global.qlitics(
|
|
3344
|
+
global.qlitics('track', 'story-element-action', qliticsData);
|
|
3325
3345
|
} else {
|
|
3326
3346
|
global.qlitics = global.qlitics || function () {
|
|
3327
3347
|
(qlitics.q = qlitics.q || []).push(arguments);
|
|
3328
3348
|
};
|
|
3329
3349
|
|
|
3330
|
-
qlitics.qlitics.q.push(
|
|
3350
|
+
qlitics.qlitics.q.push('track', 'story-element-action', qliticsData);
|
|
3331
3351
|
}
|
|
3332
3352
|
});
|
|
3333
3353
|
|
|
3334
3354
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "onPlayCallback", function (event) {
|
|
3335
|
-
_this.triggerQlitics(
|
|
3355
|
+
_this.triggerQlitics('play');
|
|
3336
3356
|
|
|
3337
|
-
_this.props.onPlay ===
|
|
3357
|
+
_this.props.onPlay === 'function' && _this.props.onPlay(event);
|
|
3338
3358
|
_this.videoRef.current = event.target;
|
|
3339
3359
|
|
|
3340
3360
|
var targetElement = _this.videoRef.current.getIframe();
|
|
@@ -3357,9 +3377,9 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
|
|
|
3357
3377
|
});
|
|
3358
3378
|
|
|
3359
3379
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "onPauseCallback", function (event) {
|
|
3360
|
-
_this.triggerQlitics(
|
|
3380
|
+
_this.triggerQlitics('pause');
|
|
3361
3381
|
|
|
3362
|
-
_this.props.onPause ===
|
|
3382
|
+
_this.props.onPause === 'function' && _this.props.onPause(event);
|
|
3363
3383
|
var videoPausedByObserver = _this.videoPausedByObserver.current;
|
|
3364
3384
|
|
|
3365
3385
|
if (videoPausedByObserver) {
|
|
@@ -3370,9 +3390,9 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
|
|
|
3370
3390
|
});
|
|
3371
3391
|
|
|
3372
3392
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "onEndCallback", function (event) {
|
|
3373
|
-
_this.triggerQlitics(
|
|
3393
|
+
_this.triggerQlitics('end');
|
|
3374
3394
|
|
|
3375
|
-
_this.props.onEnd ===
|
|
3395
|
+
_this.props.onEnd === 'function' && _this.props.onEnd(event);
|
|
3376
3396
|
});
|
|
3377
3397
|
|
|
3378
3398
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "triggerIframe", function () {
|
|
@@ -3442,11 +3462,7 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
|
|
|
3442
3462
|
if (this.props.loadIframeOnClick) {
|
|
3443
3463
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
3444
3464
|
className: "thumbnail-wrapper"
|
|
3445
|
-
}, !this.state.showVideo && /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("
|
|
3446
|
-
className: "youtube-playBtn",
|
|
3447
|
-
onClick: this.renderVideo,
|
|
3448
|
-
"aria-label": "Play Video"
|
|
3449
|
-
}), /*#__PURE__*/React__default["default"].createElement("img", {
|
|
3465
|
+
}, !this.state.showVideo && /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, getYoutubeButton(this.renderVideo), /*#__PURE__*/React__default["default"].createElement("img", {
|
|
3450
3466
|
className: "youtube-thumbnail",
|
|
3451
3467
|
onClick: this.renderVideo,
|
|
3452
3468
|
src: "https://i.ytimg.com/vi/".concat(getYouTubeID__default["default"](this.props.element.url), "/hqdefault.jpg"),
|
|
@@ -14,11 +14,11 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
14
14
|
|
|
15
15
|
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; } }
|
|
16
16
|
|
|
17
|
-
import getYouTubeID from
|
|
18
|
-
import { bool, func, object } from
|
|
19
|
-
import React from
|
|
20
|
-
import { disconnectObserver, getQliticsSchema, initiateNewObserver } from
|
|
21
|
-
import { WithLazy } from
|
|
17
|
+
import getYouTubeID from 'get-youtube-id';
|
|
18
|
+
import { bool, func, object } from 'prop-types';
|
|
19
|
+
import React from 'react';
|
|
20
|
+
import { disconnectObserver, getQliticsSchema, initiateNewObserver } from '../../utils';
|
|
21
|
+
import { WithLazy } from '../with-lazy';
|
|
22
22
|
var YouTube = null;
|
|
23
23
|
var loaderPromise = null;
|
|
24
24
|
|
|
@@ -26,10 +26,10 @@ function loadLibrary() {
|
|
|
26
26
|
if (loaderPromise === null) {
|
|
27
27
|
loaderPromise = import(
|
|
28
28
|
/* webpackChunkName: "qtc-react-youtube" */
|
|
29
|
-
|
|
29
|
+
'react-youtube').then(function (YT) {
|
|
30
30
|
YouTube = YT["default"];
|
|
31
31
|
})["catch"](function (err) {
|
|
32
|
-
console.log(
|
|
32
|
+
console.log('Failed to load react-youtube', err);
|
|
33
33
|
return Promise.reject();
|
|
34
34
|
});
|
|
35
35
|
}
|
|
@@ -41,6 +41,26 @@ function isLibraryLoaded() {
|
|
|
41
41
|
return YouTube !== null;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
function getYoutubeButton(onClick) {
|
|
45
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
46
|
+
onClick: onClick,
|
|
47
|
+
className: "youtube-playBtn",
|
|
48
|
+
"aria-label": "Play Video"
|
|
49
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
50
|
+
width: "68",
|
|
51
|
+
height: "48",
|
|
52
|
+
viewBox: "0 0 68 48",
|
|
53
|
+
fill: "none",
|
|
54
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
55
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
56
|
+
d: "M66.52 7.74C65.74 4.81 64.03 2.33 61.1 1.55C55.79 0.13 34 0 34 0C34 0 12.21 0.13 6.9 1.55C3.97 2.33 2.27 4.81 1.48 7.74C0.0600001 13.05 0 24 0 24C0 24 0.0600001 34.95 1.48 40.26C2.26 43.19 3.97 45.67 6.9 46.45C12.21 47.87 34 48 34 48C34 48 55.79 47.87 61.1 46.45C64.03 45.67 65.74 43.19 66.52 40.26C67.94 34.95 68 24 68 24C68 24 67.94 13.05 66.52 7.74Z",
|
|
57
|
+
fill: "#FF0000"
|
|
58
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
59
|
+
d: "M43 24L25 14V34",
|
|
60
|
+
fill: "white"
|
|
61
|
+
})));
|
|
62
|
+
}
|
|
63
|
+
|
|
44
64
|
var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
|
|
45
65
|
_inherits(CustomStoryElementYoutube, _React$Component);
|
|
46
66
|
|
|
@@ -74,24 +94,24 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
|
|
|
74
94
|
element = _this$props$element === void 0 ? {} : _this$props$element;
|
|
75
95
|
|
|
76
96
|
var qliticsData = _objectSpread(_objectSpread({}, getQliticsSchema(story, card, element)), {
|
|
77
|
-
|
|
97
|
+
'story-element-action': action
|
|
78
98
|
});
|
|
79
99
|
|
|
80
100
|
if (global.qlitics) {
|
|
81
|
-
global.qlitics(
|
|
101
|
+
global.qlitics('track', 'story-element-action', qliticsData);
|
|
82
102
|
} else {
|
|
83
103
|
global.qlitics = global.qlitics || function () {
|
|
84
104
|
(qlitics.q = qlitics.q || []).push(arguments);
|
|
85
105
|
};
|
|
86
106
|
|
|
87
|
-
qlitics.qlitics.q.push(
|
|
107
|
+
qlitics.qlitics.q.push('track', 'story-element-action', qliticsData);
|
|
88
108
|
}
|
|
89
109
|
});
|
|
90
110
|
|
|
91
111
|
_defineProperty(_assertThisInitialized(_this), "onPlayCallback", function (event) {
|
|
92
|
-
_this.triggerQlitics(
|
|
112
|
+
_this.triggerQlitics('play');
|
|
93
113
|
|
|
94
|
-
_this.props.onPlay ===
|
|
114
|
+
_this.props.onPlay === 'function' && _this.props.onPlay(event);
|
|
95
115
|
_this.videoRef.current = event.target;
|
|
96
116
|
|
|
97
117
|
var targetElement = _this.videoRef.current.getIframe();
|
|
@@ -114,9 +134,9 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
|
|
|
114
134
|
});
|
|
115
135
|
|
|
116
136
|
_defineProperty(_assertThisInitialized(_this), "onPauseCallback", function (event) {
|
|
117
|
-
_this.triggerQlitics(
|
|
137
|
+
_this.triggerQlitics('pause');
|
|
118
138
|
|
|
119
|
-
_this.props.onPause ===
|
|
139
|
+
_this.props.onPause === 'function' && _this.props.onPause(event);
|
|
120
140
|
var videoPausedByObserver = _this.videoPausedByObserver.current;
|
|
121
141
|
|
|
122
142
|
if (videoPausedByObserver) {
|
|
@@ -127,9 +147,9 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
|
|
|
127
147
|
});
|
|
128
148
|
|
|
129
149
|
_defineProperty(_assertThisInitialized(_this), "onEndCallback", function (event) {
|
|
130
|
-
_this.triggerQlitics(
|
|
150
|
+
_this.triggerQlitics('end');
|
|
131
151
|
|
|
132
|
-
_this.props.onEnd ===
|
|
152
|
+
_this.props.onEnd === 'function' && _this.props.onEnd(event);
|
|
133
153
|
});
|
|
134
154
|
|
|
135
155
|
_defineProperty(_assertThisInitialized(_this), "triggerIframe", function () {
|
|
@@ -199,11 +219,7 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
|
|
|
199
219
|
if (this.props.loadIframeOnClick) {
|
|
200
220
|
return /*#__PURE__*/React.createElement("div", {
|
|
201
221
|
className: "thumbnail-wrapper"
|
|
202
|
-
}, !this.state.showVideo && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("
|
|
203
|
-
className: "youtube-playBtn",
|
|
204
|
-
onClick: this.renderVideo,
|
|
205
|
-
"aria-label": "Play Video"
|
|
206
|
-
}), /*#__PURE__*/React.createElement("img", {
|
|
222
|
+
}, !this.state.showVideo && /*#__PURE__*/React.createElement(React.Fragment, null, getYoutubeButton(this.renderVideo), /*#__PURE__*/React.createElement("img", {
|
|
207
223
|
className: "youtube-thumbnail",
|
|
208
224
|
onClick: this.renderVideo,
|
|
209
225
|
src: "https://i.ytimg.com/vi/".concat(getYouTubeID(this.props.element.url), "/hqdefault.jpg"),
|