@micromag/screen-urbania-trivia 0.3.57
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/assets/css/styles.css +1 -0
- package/es/index.js +585 -0
- package/lib/index.js +608 -0
- package/package.json +73 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.micromag-screen-urbania-trivia-container .micromag-screen-urbania-trivia-content,.micromag-screen-urbania-trivia-container .micromag-screen-urbania-trivia-empty,.micromag-screen-urbania-trivia-container .micromag-screen-urbania-trivia-emptyContainer,.micromag-screen-urbania-trivia-container.micromag-screen-urbania-trivia-fullscreen .micromag-screen-urbania-trivia-image,.micromag-screen-urbania-trivia-container.micromag-screen-urbania-trivia-fullscreen .micromag-screen-urbania-trivia-placeholder{position:absolute;top:0;left:0;width:100%;height:100%}.micromag-screen-urbania-trivia-container{position:relative;width:100%;height:100%;overflow:hidden}.micromag-screen-urbania-trivia-disabled.micromag-screen-urbania-trivia-container{overflow:hidden;pointer-events:none}.micromag-screen-urbania-trivia-hidden.micromag-screen-urbania-trivia-container{display:none;visibility:hidden}.micromag-screen-urbania-trivia-placeholder.micromag-screen-urbania-trivia-container .micromag-screen-urbania-trivia-content{position:relative;padding:6px}.micromag-screen-urbania-trivia-container .micromag-screen-urbania-trivia-empty{margin:5px auto;border:2px dashed #343434;color:#343434;margin:0}.micromag-screen-urbania-trivia-container .micromag-screen-urbania-trivia-itemsContainer{display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;min-width:80%}.micromag-screen-urbania-trivia-container .micromag-screen-urbania-trivia-content{display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-align-items:center;-ms-flex-align:center;align-items:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;overflow:hidden}.micromag-screen-urbania-trivia-container .micromag-screen-urbania-trivia-videoContainer{position:relative;overflow:hidden}.micromag-screen-urbania-trivia-container .micromag-screen-urbania-trivia-video{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.micromag-screen-urbania-trivia-container .micromag-screen-urbania-trivia-isCustomBackground{-webkit-transform-origin:center;-ms-transform-origin:center;transform-origin:center}.micromag-screen-urbania-trivia-container .micromag-screen-urbania-trivia-isAnimated{-webkit-transform:scale(3);-ms-transform:scale(3);transform:scale(3);-webkit-animation:micromag-screen-urbania-trivia-spin 9s linear 0ms infinite;animation:micromag-screen-urbania-trivia-spin 9s linear 0ms infinite}@-webkit-keyframes micromag-screen-urbania-trivia-spin{0%{-webkit-transform:scale(3) rotate(0deg);transform:scale(3) rotate(0deg)}to{-webkit-transform:scale(3) rotate(1turn);transform:scale(3) rotate(1turn)}}@keyframes micromag-screen-urbania-trivia-spin{0%{-webkit-transform:scale(3) rotate(0deg);transform:scale(3) rotate(0deg)}to{-webkit-transform:scale(3) rotate(1turn);transform:scale(3) rotate(1turn)}}.micromag-screen-urbania-trivia-container .micromag-screen-urbania-trivia-heading{width:320px;padding:16px 5px 10px;border-top:1px solid #000;border-bottom:1px solid #000;background-color:#fff800;color:#000;font-family:AgrandirWide,sans-serif;font-size:26px;font-weight:800;text-align:center;text-shadow:-2px -2px 0 #fff;text-transform:uppercase}.micromag-screen-urbania-trivia-container .micromag-screen-urbania-trivia-heading.micromag-screen-urbania-trivia-hideHeading{display:none}.micromag-screen-urbania-trivia-container .micromag-screen-urbania-trivia-callToAction{padding-bottom:5px}.micromag-screen-urbania-trivia-container .micromag-screen-urbania-trivia-bottom{-webkit-transition:opacity .15s linear;-o-transition:opacity .15s linear;transition:opacity .15s linear;opacity:0}.micromag-screen-urbania-trivia-container .micromag-screen-urbania-trivia-bottom.micromag-screen-urbania-trivia-visible{opacity:1}.micromag-screen-urbania-trivia-container .micromag-screen-urbania-trivia-bottom.micromag-screen-urbania-trivia-withGradient{background:-webkit-gradient(linear,left top, left bottom,from(rgba(0,0,0,0)),to(rgba(0,0,0,.4)));background:-o-linear-gradient(rgba(0,0,0,0),rgba(0,0,0,.4));background:linear-gradient(rgba(0,0,0,0),rgba(0,0,0,.4))}.micromag-screen-urbania-trivia-container .micromag-screen-urbania-trivia-mediaControls{padding:10px 20px 20px}.micromag-screen-urbania-trivia-container .micromag-screen-urbania-trivia-placeholder{display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;mix-blend-mode:normal}.micromag-screen-urbania-trivia-container .micromag-screen-urbania-trivia-videoPlaceholder{mix-blend-mode:normal;background-color:#adadad}.micromag-screen-urbania-trivia-container .micromag-screen-urbania-trivia-bottomContent{position:absolute;bottom:0;width:100%}.micromag-screen-urbania-trivia-container.micromag-screen-urbania-trivia-fullscreen .micromag-screen-urbania-trivia-emptyContainer{top:0;height:100%;padding-bottom:0;-webkit-transform:none;-ms-transform:none;transform:none}
|
package/es/index.js
ADDED
|
@@ -0,0 +1,585 @@
|
|
|
1
|
+
import { FormattedMessage, defineMessage } from 'react-intl';
|
|
2
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
4
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
5
|
+
import { getSizeWithinBounds } from '@folklore/size';
|
|
6
|
+
import classNames from 'classnames';
|
|
7
|
+
import isArray from 'lodash/isArray';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import React, { useRef, useEffect, useState, useCallback, useMemo } from 'react';
|
|
10
|
+
import { PropTypes as PropTypes$1 } from '@micromag/core';
|
|
11
|
+
import { ScreenElement, PlaceholderTitle, Empty, PlaceholderVideo, Transitions } from '@micromag/core/components';
|
|
12
|
+
import { useScreenSize, useScreenRenderContext, useViewerNavigation } from '@micromag/core/contexts';
|
|
13
|
+
import { useTrackScreenMedia, useLongPress, useResizeObserver } from '@micromag/core/hooks';
|
|
14
|
+
import Background from '@micromag/element-background';
|
|
15
|
+
import CallToAction from '@micromag/element-call-to-action';
|
|
16
|
+
import ClosedCaptions from '@micromag/element-closed-captions';
|
|
17
|
+
import Container from '@micromag/element-container';
|
|
18
|
+
import Heading from '@micromag/element-heading';
|
|
19
|
+
import Image from '@micromag/element-image';
|
|
20
|
+
import MediaControls from '@micromag/element-media-controls';
|
|
21
|
+
import Video from '@micromag/element-video';
|
|
22
|
+
|
|
23
|
+
var img$1 = "data:image/svg+xml,%3c%3fxml version='1.0' encoding='UTF-8'%3f%3e%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1083.95 1920'%3e %3cg id='a'/%3e %3cg id='b'%3e %3cg id='c'%3e %3cpath d='M1083.95%2c0h-103.4l-438.55%2c959.95L1083.95%2c109.31V0Zm0%2c295L542.02%2c959.96l541.93-498.87v-166.08Zm0%2c274.99l-541.92%2c389.98%2c541.92-279.64v-110.34Zm0%2c190.53l-541.92%2c199.46%2c541.92-110.89v-88.57Zm0%2c158.17l-541.92%2c41.31%2c541.92%2c41.31v-82.61Zm0%2c152.21l-541.92-110.89%2c541.92%2c199.46v-88.58Zm0%2c168.77l-541.92-279.64%2c541.92%2c389.98v-110.34Zm0%2c219.25l-541.93-498.87%2c541.93%2c664.95v-166.08Zm0%2c351.77L542%2c960.05l438.55%2c959.95h103.4v-109.31ZM854.8%2c0h-138.91l-173.9%2c959.94L854.8%2c0Zm0%2c1920l-312.81-959.94%2c173.9%2c959.94h138.91ZM606.75%2c0h-129.56l64.78%2c959.94L606.75%2c0Zm0%2c1920l-64.78-959.94-64.78%2c959.94h129.56Zm-64.79-960.06L368.06%2c0H229.15l312.81%2c959.94Zm0%2c.12L229.15%2c1920h138.91l173.9-959.94Zm-.01-.11L103.4%2c0H0V109.31L541.94%2c959.95Zm0%2c.11L0%2c1810.69v109.31H103.4l438.55-959.95Zm-.01-.1L0%2c295.01v166.08l541.93%2c498.87Zm0%2c.09L0%2c1458.91v166.08L541.93%2c960.04Zm-.01-.07L0%2c570v110.34l541.92%2c279.63Zm0%2c.02L0%2c760.52v88.57l541.92%2c110.89Zm0%2c.02L0%2c918.69v82.61l541.92-41.31Zm0%2c.02L0%2c1070.9v88.57l541.92-199.46Zm0%2c.02L0%2c1239.66v110.34l541.92-389.97Z' fill='hsla(0%2c0%25%2c100%25%2c.6)'/%3e %3c/g%3e %3c/g%3e%3c/svg%3e";
|
|
24
|
+
|
|
25
|
+
var img = "data:image/svg+xml,%3c%3fxml version='1.0' encoding='UTF-8'%3f%3e%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1083.95 1920'%3e %3cg id='a'/%3e %3cg id='b'%3e %3cg id='c'%3e %3cpath d='M1083.95%2c0h-103.4l-438.55%2c959.95L1083.95%2c109.31V0Zm0%2c295L542.02%2c959.96l541.93-498.87v-166.08Zm0%2c274.99l-541.92%2c389.98%2c541.92-279.64v-110.34Zm0%2c190.53l-541.92%2c199.46%2c541.92-110.89v-88.57Zm0%2c158.17l-541.92%2c41.31%2c541.92%2c41.31v-82.61Zm0%2c152.21l-541.92-110.89%2c541.92%2c199.46v-88.58Zm0%2c168.77l-541.92-279.64%2c541.92%2c389.98v-110.34Zm0%2c219.25l-541.93-498.87%2c541.93%2c664.95v-166.08Zm0%2c351.77L542%2c960.05l438.55%2c959.95h103.4v-109.31ZM854.8%2c0h-138.91l-173.9%2c959.94L854.8%2c0Zm0%2c1920l-312.81-959.94%2c173.9%2c959.94h138.91ZM606.75%2c0h-129.56l64.78%2c959.94L606.75%2c0Zm0%2c1920l-64.78-959.94-64.78%2c959.94h129.56Zm-64.79-960.06L368.06%2c0H229.15l312.81%2c959.94Zm0%2c.12L229.15%2c1920h138.91l173.9-959.94Zm-.01-.11L103.4%2c0H0V109.31L541.94%2c959.95Zm0%2c.11L0%2c1810.69v109.31H103.4l438.55-959.95Zm-.01-.1L0%2c295.01v166.08l541.93%2c498.87Zm0%2c.09L0%2c1458.91v166.08L541.93%2c960.04Zm-.01-.07L0%2c570v110.34l541.92%2c279.63Zm0%2c.02L0%2c760.52v88.57l541.92%2c110.89Zm0%2c.02L0%2c918.69v82.61l541.92-41.31Zm0%2c.02L0%2c1070.9v88.57l541.92-199.46Zm0%2c.02L0%2c1239.66v110.34l541.92-389.97Z' fill='%2312bbd7'/%3e %3c/g%3e %3c/g%3e%3c/svg%3e";
|
|
26
|
+
|
|
27
|
+
var styles = {"container":"micromag-screen-urbania-trivia-container","content":"micromag-screen-urbania-trivia-content","empty":"micromag-screen-urbania-trivia-empty","emptyContainer":"micromag-screen-urbania-trivia-emptyContainer","fullscreen":"micromag-screen-urbania-trivia-fullscreen","image":"micromag-screen-urbania-trivia-image","placeholder":"micromag-screen-urbania-trivia-placeholder","disabled":"micromag-screen-urbania-trivia-disabled","hidden":"micromag-screen-urbania-trivia-hidden","itemsContainer":"micromag-screen-urbania-trivia-itemsContainer","videoContainer":"micromag-screen-urbania-trivia-videoContainer","video":"micromag-screen-urbania-trivia-video","isCustomBackground":"micromag-screen-urbania-trivia-isCustomBackground","isAnimated":"micromag-screen-urbania-trivia-isAnimated","spin":"micromag-screen-urbania-trivia-spin","heading":"micromag-screen-urbania-trivia-heading","hideHeading":"micromag-screen-urbania-trivia-hideHeading","callToAction":"micromag-screen-urbania-trivia-callToAction","bottom":"micromag-screen-urbania-trivia-bottom","visible":"micromag-screen-urbania-trivia-visible","withGradient":"micromag-screen-urbania-trivia-withGradient","mediaControls":"micromag-screen-urbania-trivia-mediaControls","videoPlaceholder":"micromag-screen-urbania-trivia-videoPlaceholder","bottomContent":"micromag-screen-urbania-trivia-bottomContent"};
|
|
28
|
+
|
|
29
|
+
var defaultBackground = {
|
|
30
|
+
image: {
|
|
31
|
+
type: 'image',
|
|
32
|
+
url: img,
|
|
33
|
+
width: 1083,
|
|
34
|
+
height: 1919
|
|
35
|
+
},
|
|
36
|
+
color: '#00cbff'
|
|
37
|
+
};
|
|
38
|
+
var placeholderBackground = {
|
|
39
|
+
image: {
|
|
40
|
+
type: 'image',
|
|
41
|
+
url: img$1,
|
|
42
|
+
width: 1083,
|
|
43
|
+
height: 1919
|
|
44
|
+
},
|
|
45
|
+
color: null
|
|
46
|
+
};
|
|
47
|
+
var propTypes = {
|
|
48
|
+
layout: PropTypes.oneOf(['middle', 'full']),
|
|
49
|
+
title: PropTypes$1.headingElement,
|
|
50
|
+
video: PropTypes$1.videoElement,
|
|
51
|
+
gotoNextScreenOnEnd: PropTypes.bool,
|
|
52
|
+
background: PropTypes$1.backgroundElement,
|
|
53
|
+
callToAction: PropTypes$1.callToAction,
|
|
54
|
+
current: PropTypes.bool,
|
|
55
|
+
active: PropTypes.bool,
|
|
56
|
+
transitions: PropTypes$1.transitions,
|
|
57
|
+
spacing: PropTypes.number,
|
|
58
|
+
padding: PropTypes.number,
|
|
59
|
+
getMediaRef: PropTypes.func,
|
|
60
|
+
className: PropTypes.string
|
|
61
|
+
};
|
|
62
|
+
var defaultProps = {
|
|
63
|
+
layout: 'full',
|
|
64
|
+
title: null,
|
|
65
|
+
video: null,
|
|
66
|
+
gotoNextScreenOnEnd: false,
|
|
67
|
+
background: null,
|
|
68
|
+
callToAction: null,
|
|
69
|
+
current: true,
|
|
70
|
+
active: true,
|
|
71
|
+
transitions: null,
|
|
72
|
+
spacing: 20,
|
|
73
|
+
padding: 20,
|
|
74
|
+
getMediaRef: null,
|
|
75
|
+
className: null
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
var UrbaniaTrivia = function UrbaniaTrivia(_ref) {
|
|
79
|
+
var _ref11, _ref12, _ref14, _ref15;
|
|
80
|
+
|
|
81
|
+
var layout = _ref.layout,
|
|
82
|
+
title = _ref.title,
|
|
83
|
+
video = _ref.video,
|
|
84
|
+
gotoNextScreenOnEnd = _ref.gotoNextScreenOnEnd,
|
|
85
|
+
background = _ref.background,
|
|
86
|
+
callToAction = _ref.callToAction,
|
|
87
|
+
current = _ref.current,
|
|
88
|
+
active = _ref.active,
|
|
89
|
+
transitions = _ref.transitions,
|
|
90
|
+
spacing = _ref.spacing,
|
|
91
|
+
padding = _ref.padding,
|
|
92
|
+
getMediaRef = _ref.getMediaRef,
|
|
93
|
+
className = _ref.className;
|
|
94
|
+
var trackScreenMedia = useTrackScreenMedia('video');
|
|
95
|
+
|
|
96
|
+
var _useScreenSize = useScreenSize(),
|
|
97
|
+
width = _useScreenSize.width,
|
|
98
|
+
height = _useScreenSize.height;
|
|
99
|
+
|
|
100
|
+
var _useScreenRenderConte = useScreenRenderContext(),
|
|
101
|
+
isView = _useScreenRenderConte.isView,
|
|
102
|
+
isPreview = _useScreenRenderConte.isPreview,
|
|
103
|
+
isPlaceholder = _useScreenRenderConte.isPlaceholder,
|
|
104
|
+
isEdit = _useScreenRenderConte.isEdit,
|
|
105
|
+
isStatic = _useScreenRenderConte.isStatic,
|
|
106
|
+
isCapture = _useScreenRenderConte.isCapture;
|
|
107
|
+
|
|
108
|
+
var _useViewerNavigation = useViewerNavigation(),
|
|
109
|
+
gotoNextScreen = _useViewerNavigation.gotoNextScreen;
|
|
110
|
+
|
|
111
|
+
var backgroundPlaying = current && (isView || isEdit);
|
|
112
|
+
var backgroundShouldLoad = current || active || !isView;
|
|
113
|
+
var videoShouldLoad = current || active || !isView;
|
|
114
|
+
var shouldGotoNextScreenOnEnd = gotoNextScreenOnEnd && isView && current;
|
|
115
|
+
|
|
116
|
+
var _ref2 = title || {},
|
|
117
|
+
_ref2$body = _ref2.body,
|
|
118
|
+
body = _ref2$body === void 0 ? '' : _ref2$body; // get resized video style props
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
var _ref3 = video || {},
|
|
122
|
+
_ref3$autoPlay = _ref3.autoPlay,
|
|
123
|
+
autoPlay = _ref3$autoPlay === void 0 ? true : _ref3$autoPlay,
|
|
124
|
+
_ref3$media = _ref3.media,
|
|
125
|
+
videoMedia = _ref3$media === void 0 ? null : _ref3$media,
|
|
126
|
+
_ref3$closedCaptions = _ref3.closedCaptions,
|
|
127
|
+
closedCaptions = _ref3$closedCaptions === void 0 ? null : _ref3$closedCaptions,
|
|
128
|
+
_ref3$withSeekBar = _ref3.withSeekBar,
|
|
129
|
+
withSeekBar = _ref3$withSeekBar === void 0 ? false : _ref3$withSeekBar,
|
|
130
|
+
_ref3$withPlayPause = _ref3.withPlayPause,
|
|
131
|
+
withPlayPause = _ref3$withPlayPause === void 0 ? false : _ref3$withPlayPause,
|
|
132
|
+
_ref3$withTime = _ref3.withTime,
|
|
133
|
+
withTime = _ref3$withTime === void 0 ? false : _ref3$withTime;
|
|
134
|
+
|
|
135
|
+
var apiRef = useRef();
|
|
136
|
+
|
|
137
|
+
var _ref4 = apiRef.current || {},
|
|
138
|
+
togglePlay = _ref4.togglePlay,
|
|
139
|
+
toggleMute = _ref4.toggleMute,
|
|
140
|
+
seek = _ref4.seek,
|
|
141
|
+
play = _ref4.play,
|
|
142
|
+
pause = _ref4.pause,
|
|
143
|
+
_ref4$mediaRef = _ref4.mediaRef,
|
|
144
|
+
apiMediaRef = _ref4$mediaRef === void 0 ? null : _ref4$mediaRef;
|
|
145
|
+
|
|
146
|
+
useEffect(function () {
|
|
147
|
+
if (apiMediaRef !== null && getMediaRef !== null) {
|
|
148
|
+
getMediaRef(apiMediaRef.current);
|
|
149
|
+
}
|
|
150
|
+
}, [apiMediaRef, getMediaRef]);
|
|
151
|
+
var mouseMoveRef = useRef(null);
|
|
152
|
+
|
|
153
|
+
var _useState = useState(false),
|
|
154
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
155
|
+
showMediaControls = _useState2[0],
|
|
156
|
+
setShowMediaControls = _useState2[1]; // Get api state updates from callback
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
var _useState3 = useState(null),
|
|
160
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
161
|
+
currentTime = _useState4[0],
|
|
162
|
+
setCurrentTime = _useState4[1];
|
|
163
|
+
|
|
164
|
+
var _useState5 = useState(null),
|
|
165
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
166
|
+
duration = _useState6[0],
|
|
167
|
+
setDuration = _useState6[1];
|
|
168
|
+
|
|
169
|
+
var _useState7 = useState(false),
|
|
170
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
171
|
+
playing = _useState8[0],
|
|
172
|
+
setPlaying = _useState8[1];
|
|
173
|
+
|
|
174
|
+
var _useState9 = useState(false),
|
|
175
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
176
|
+
muted = _useState10[0],
|
|
177
|
+
setMuted = _useState10[1];
|
|
178
|
+
|
|
179
|
+
var onTimeUpdate = useCallback(function (time) {
|
|
180
|
+
setCurrentTime(time);
|
|
181
|
+
}, [setDuration, duration]);
|
|
182
|
+
var onProgressStep = useCallback(function (step) {
|
|
183
|
+
trackScreenMedia(video, "progress_".concat(Math.round(step * 100, 10), "%"));
|
|
184
|
+
}, [trackScreenMedia, video]);
|
|
185
|
+
var onDurationChanged = useCallback(function (dur) {
|
|
186
|
+
setDuration(dur);
|
|
187
|
+
}, [setDuration]);
|
|
188
|
+
var onPlay = useCallback(function (_ref5) {
|
|
189
|
+
var initial = _ref5.initial;
|
|
190
|
+
setPlaying(true);
|
|
191
|
+
trackScreenMedia(video, initial ? 'play' : 'resume');
|
|
192
|
+
}, [trackScreenMedia, video]);
|
|
193
|
+
var onPause = useCallback(function (_ref6) {
|
|
194
|
+
var midway = _ref6.midway;
|
|
195
|
+
setPlaying(false);
|
|
196
|
+
trackScreenMedia(video, midway ? 'pause' : 'ended');
|
|
197
|
+
}, [trackScreenMedia, video]);
|
|
198
|
+
var onVolumeChanged = useCallback(function (isMuted) {
|
|
199
|
+
setMuted(isMuted);
|
|
200
|
+
trackScreenMedia(video, isMuted ? 'mute' : 'unmute');
|
|
201
|
+
}, [trackScreenMedia, video]);
|
|
202
|
+
var onSeek = useCallback(function (e) {
|
|
203
|
+
seek(e);
|
|
204
|
+
play();
|
|
205
|
+
}, [seek, play]);
|
|
206
|
+
var onSeeked = useCallback(function (time) {
|
|
207
|
+
if (time > 0) {
|
|
208
|
+
trackScreenMedia(video, 'seek');
|
|
209
|
+
}
|
|
210
|
+
}, [trackScreenMedia, video]);
|
|
211
|
+
var onToggleMute = useCallback(function () {
|
|
212
|
+
if (muted && !playing) {
|
|
213
|
+
play();
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
toggleMute();
|
|
217
|
+
}, [muted, toggleMute]);
|
|
218
|
+
var onEnded = useCallback(function () {
|
|
219
|
+
if (shouldGotoNextScreenOnEnd) {
|
|
220
|
+
gotoNextScreen();
|
|
221
|
+
}
|
|
222
|
+
}, [shouldGotoNextScreenOnEnd, seek, gotoNextScreen]);
|
|
223
|
+
useEffect(function () {
|
|
224
|
+
if (!current && playing) {
|
|
225
|
+
pause();
|
|
226
|
+
}
|
|
227
|
+
}, [playing, current]);
|
|
228
|
+
var onMouseMove = useCallback(function (e) {
|
|
229
|
+
var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1800;
|
|
230
|
+
setShowMediaControls(true);
|
|
231
|
+
|
|
232
|
+
if (mouseMoveRef.current !== null) {
|
|
233
|
+
clearTimeout(mouseMoveRef.current);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
mouseMoveRef.current = setTimeout(function () {
|
|
237
|
+
setShowMediaControls(false);
|
|
238
|
+
mouseMoveRef.current = null;
|
|
239
|
+
}, time);
|
|
240
|
+
}, [setShowMediaControls]);
|
|
241
|
+
var onLongPress = useCallback(function () {
|
|
242
|
+
if (!playing) {
|
|
243
|
+
play();
|
|
244
|
+
} else if (withPlayPause) {
|
|
245
|
+
onMouseMove(null, 3000);
|
|
246
|
+
} else {
|
|
247
|
+
pause();
|
|
248
|
+
}
|
|
249
|
+
}, [play, playing, pause, onMouseMove, withPlayPause, setShowMediaControls]);
|
|
250
|
+
var longPressBind = useLongPress({
|
|
251
|
+
onLongPress: onLongPress,
|
|
252
|
+
onClick: onMouseMove
|
|
253
|
+
});
|
|
254
|
+
var fullscreen = layout === 'full';
|
|
255
|
+
var hasCallToAction = callToAction !== null && callToAction.active === true;
|
|
256
|
+
|
|
257
|
+
var _ref7 = background || {},
|
|
258
|
+
_ref7$image = _ref7.image,
|
|
259
|
+
backgroundImage = _ref7$image === void 0 ? null : _ref7$image,
|
|
260
|
+
_ref7$video = _ref7.video,
|
|
261
|
+
backgroundVideo = _ref7$video === void 0 ? null : _ref7$video;
|
|
262
|
+
|
|
263
|
+
var isCustomBackground = background === null || backgroundImage === null && backgroundVideo === null;
|
|
264
|
+
var hasVideo = video !== null;
|
|
265
|
+
|
|
266
|
+
var _useState11 = useState(hasVideo),
|
|
267
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
268
|
+
ready = _useState12[0],
|
|
269
|
+
setReady = _useState12[1];
|
|
270
|
+
|
|
271
|
+
var transitionPlaying = current && ready;
|
|
272
|
+
var transitionDisabled = isStatic || isCapture || isPlaceholder || isPreview || isEdit;
|
|
273
|
+
var finalVideo = useMemo(function () {
|
|
274
|
+
return hasVideo ? _objectSpread(_objectSpread({}, video), {}, {
|
|
275
|
+
autoPlay: !isPreview && !isStatic && !isCapture && autoPlay && current
|
|
276
|
+
}) : null;
|
|
277
|
+
}, [hasVideo, video, isPreview, isStatic, isCapture, autoPlay, current]);
|
|
278
|
+
|
|
279
|
+
var _ref8 = videoMedia || {},
|
|
280
|
+
_ref8$metadata = _ref8.metadata,
|
|
281
|
+
videoMetadata = _ref8$metadata === void 0 ? null : _ref8$metadata,
|
|
282
|
+
_ref8$url = _ref8.url,
|
|
283
|
+
videoUrl = _ref8$url === void 0 ? null : _ref8$url,
|
|
284
|
+
_ref8$thumbnail_url = _ref8.thumbnail_url,
|
|
285
|
+
thumbnailUrl = _ref8$thumbnail_url === void 0 ? null : _ref8$thumbnail_url;
|
|
286
|
+
|
|
287
|
+
var hasVideoUrl = videoUrl !== null;
|
|
288
|
+
|
|
289
|
+
var _ref9 = videoMetadata || {},
|
|
290
|
+
_ref9$width = _ref9.width,
|
|
291
|
+
videoWidth = _ref9$width === void 0 ? 0 : _ref9$width,
|
|
292
|
+
_ref9$height = _ref9.height,
|
|
293
|
+
videoHeight = _ref9$height === void 0 ? 0 : _ref9$height;
|
|
294
|
+
|
|
295
|
+
var _useResizeObserver = useResizeObserver(),
|
|
296
|
+
titleRef = _useResizeObserver.ref,
|
|
297
|
+
_useResizeObserver$en = _useResizeObserver.entry.contentRect,
|
|
298
|
+
contentRect = _useResizeObserver$en === void 0 ? null : _useResizeObserver$en;
|
|
299
|
+
|
|
300
|
+
var _ref10 = contentRect || {},
|
|
301
|
+
_ref10$height = _ref10.height,
|
|
302
|
+
titleHeight = _ref10$height === void 0 ? 0 : _ref10$height;
|
|
303
|
+
|
|
304
|
+
var videoMaxHeight = height - titleHeight - (padding ? padding * 2 : 40);
|
|
305
|
+
|
|
306
|
+
var _getSizeWithinBounds = getSizeWithinBounds(videoWidth, videoHeight, width, videoMaxHeight, {
|
|
307
|
+
cover: fullscreen
|
|
308
|
+
}),
|
|
309
|
+
resizedVideoWidth = _getSizeWithinBounds.width,
|
|
310
|
+
resizedVideoHeight = _getSizeWithinBounds.height;
|
|
311
|
+
|
|
312
|
+
var resizedVideoLeft = -(resizedVideoWidth - width) / 2; // const resizedVideoTop = -(resizedVideoHeight - videoMaxHeight) / 2;
|
|
313
|
+
|
|
314
|
+
var finalBackground = useMemo(function () {
|
|
315
|
+
if (isArray(background) && background.length > 0) {
|
|
316
|
+
return background;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (background !== null) {
|
|
320
|
+
return _objectSpread(_objectSpread({}, defaultBackground), background);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
return defaultBackground;
|
|
324
|
+
}, [background]);
|
|
325
|
+
var placeholderProps = fullscreen ? {
|
|
326
|
+
width: '100%',
|
|
327
|
+
height: '100%'
|
|
328
|
+
} : {
|
|
329
|
+
width: '100%'
|
|
330
|
+
};
|
|
331
|
+
useEffect(function () {
|
|
332
|
+
setReady(!hasVideoUrl);
|
|
333
|
+
}, [videoUrl, hasVideoUrl, setReady]);
|
|
334
|
+
var onVideoReady = useCallback(function () {
|
|
335
|
+
setReady(true);
|
|
336
|
+
}, [setReady]);
|
|
337
|
+
var visibleControls = !autoPlay && !playing || muted || showMediaControls;
|
|
338
|
+
var items = [/*#__PURE__*/React.createElement(Container, {
|
|
339
|
+
className: styles.itemsContainer
|
|
340
|
+
}, /*#__PURE__*/React.createElement(ScreenElement, {
|
|
341
|
+
key: "heading",
|
|
342
|
+
className: styles.headingScreenElement,
|
|
343
|
+
placeholder: /*#__PURE__*/React.createElement(PlaceholderTitle, Object.assign({
|
|
344
|
+
className: styles.placeholder
|
|
345
|
+
}, placeholderProps)),
|
|
346
|
+
empty: /*#__PURE__*/React.createElement("div", {
|
|
347
|
+
className: styles.emptyContainer
|
|
348
|
+
}, /*#__PURE__*/React.createElement(Empty, {
|
|
349
|
+
className: styles.empty
|
|
350
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
351
|
+
id: "oAtOlP",
|
|
352
|
+
defaultMessage: [{
|
|
353
|
+
"type": 0,
|
|
354
|
+
"value": "Heading"
|
|
355
|
+
}]
|
|
356
|
+
}))),
|
|
357
|
+
isEmpty: body.length === 0
|
|
358
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
359
|
+
ref: titleRef
|
|
360
|
+
}, /*#__PURE__*/React.createElement(Heading, Object.assign({
|
|
361
|
+
className: classNames([styles.heading, (_ref11 = {}, _defineProperty(_ref11, className, className !== null), _defineProperty(_ref11, styles.hideHeading, body.length === 0), _ref11)]),
|
|
362
|
+
body: body
|
|
363
|
+
}, title)))), /*#__PURE__*/React.createElement(ScreenElement, {
|
|
364
|
+
key: "video",
|
|
365
|
+
className: styles.videoScreenElement,
|
|
366
|
+
placeholder: /*#__PURE__*/React.createElement(PlaceholderVideo, Object.assign({
|
|
367
|
+
className: styles.videoPlaceholder,
|
|
368
|
+
height: "300px"
|
|
369
|
+
}, placeholderProps)),
|
|
370
|
+
empty: /*#__PURE__*/React.createElement("div", {
|
|
371
|
+
className: styles.emptyContainer
|
|
372
|
+
}, /*#__PURE__*/React.createElement(Empty, {
|
|
373
|
+
className: styles.empty
|
|
374
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
375
|
+
id: "3ext9Q",
|
|
376
|
+
defaultMessage: [{
|
|
377
|
+
"type": 0,
|
|
378
|
+
"value": "Video"
|
|
379
|
+
}]
|
|
380
|
+
}))),
|
|
381
|
+
isEmpty: !hasVideoUrl
|
|
382
|
+
}, hasVideoUrl ? /*#__PURE__*/React.createElement("div", {
|
|
383
|
+
className: styles.videoContainer,
|
|
384
|
+
style: {
|
|
385
|
+
width: Math.min(width, resizedVideoWidth),
|
|
386
|
+
height: resizedVideoHeight,
|
|
387
|
+
left: resizedVideoLeft > 0 ? resizedVideoLeft : null,
|
|
388
|
+
maxHeight: videoMaxHeight
|
|
389
|
+
}
|
|
390
|
+
}, isPreview || isCapture ? /*#__PURE__*/React.createElement(Image, {
|
|
391
|
+
className: styles.image,
|
|
392
|
+
media: {
|
|
393
|
+
url: thumbnailUrl,
|
|
394
|
+
metadata: {
|
|
395
|
+
width: videoWidth,
|
|
396
|
+
height: videoHeight
|
|
397
|
+
}
|
|
398
|
+
},
|
|
399
|
+
width: "100%",
|
|
400
|
+
height: "100%"
|
|
401
|
+
}) : /*#__PURE__*/React.createElement(Video, Object.assign({}, finalVideo, {
|
|
402
|
+
ref: apiRef,
|
|
403
|
+
width: resizedVideoWidth,
|
|
404
|
+
height: resizedVideoHeight,
|
|
405
|
+
className: styles.video,
|
|
406
|
+
onReady: onVideoReady,
|
|
407
|
+
onPlay: onPlay,
|
|
408
|
+
onPause: onPause,
|
|
409
|
+
onTimeUpdate: onTimeUpdate,
|
|
410
|
+
onProgressStep: onProgressStep,
|
|
411
|
+
onDurationChanged: onDurationChanged,
|
|
412
|
+
onSeeked: onSeeked,
|
|
413
|
+
onEnded: onEnded,
|
|
414
|
+
onVolumeChanged: onVolumeChanged,
|
|
415
|
+
focusable: current && isView,
|
|
416
|
+
preload: videoShouldLoad ? 'auto' : 'metadata'
|
|
417
|
+
})), !isPlaceholder ? /*#__PURE__*/React.createElement("div", {
|
|
418
|
+
key: "bottom-content",
|
|
419
|
+
className: styles.bottomContent
|
|
420
|
+
}, /*#__PURE__*/React.createElement(Transitions, {
|
|
421
|
+
playing: transitionPlaying,
|
|
422
|
+
transitions: transitions,
|
|
423
|
+
disabled: transitionDisabled
|
|
424
|
+
}, closedCaptions !== null && !isPreview && !isCapture && !isStatic ? /*#__PURE__*/React.createElement(ClosedCaptions, {
|
|
425
|
+
className: styles.closedCaptions,
|
|
426
|
+
media: closedCaptions,
|
|
427
|
+
currentTime: currentTime
|
|
428
|
+
}) : null, /*#__PURE__*/React.createElement("div", {
|
|
429
|
+
className: classNames([styles.bottom, (_ref12 = {}, _defineProperty(_ref12, styles.visible, visibleControls), _defineProperty(_ref12, styles.withGradient, withSeekBar || withPlayPause || muted), _ref12)])
|
|
430
|
+
}, hasVideoUrl ? /*#__PURE__*/React.createElement(MediaControls, {
|
|
431
|
+
className: classNames([styles.mediaControls, _defineProperty({}, styles.visible, visibleControls)]),
|
|
432
|
+
withSeekBar: withSeekBar,
|
|
433
|
+
withPlayPause: withPlayPause,
|
|
434
|
+
withTime: withTime,
|
|
435
|
+
playing: playing,
|
|
436
|
+
muted: muted,
|
|
437
|
+
currentTime: currentTime,
|
|
438
|
+
duration: duration,
|
|
439
|
+
onTogglePlay: togglePlay,
|
|
440
|
+
onToggleMute: onToggleMute,
|
|
441
|
+
onSeek: onSeek,
|
|
442
|
+
focusable: current && isView
|
|
443
|
+
}) : null, hasCallToAction ? /*#__PURE__*/React.createElement("div", {
|
|
444
|
+
style: {
|
|
445
|
+
marginTop: -spacing / 2
|
|
446
|
+
}
|
|
447
|
+
}, /*#__PURE__*/React.createElement(CallToAction, {
|
|
448
|
+
className: styles.callToAction,
|
|
449
|
+
callToAction: callToAction,
|
|
450
|
+
animationDisabled: isPreview,
|
|
451
|
+
focusable: current && isView,
|
|
452
|
+
screenSize: {
|
|
453
|
+
width: width,
|
|
454
|
+
height: height
|
|
455
|
+
}
|
|
456
|
+
})) : null))) : null) : null))];
|
|
457
|
+
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
458
|
+
className: classNames([styles.container, (_ref14 = {}, _defineProperty(_ref14, className, className !== null), _defineProperty(_ref14, styles.fullscreen, fullscreen), _ref14)]),
|
|
459
|
+
"data-screen-ready": isStatic || isCapture || ready
|
|
460
|
+
}, longPressBind, {
|
|
461
|
+
onMouseMove: onMouseMove
|
|
462
|
+
}), !isPlaceholder ? /*#__PURE__*/React.createElement(Background, {
|
|
463
|
+
background: finalBackground,
|
|
464
|
+
className: classNames([styles.background, (_ref15 = {}, _defineProperty(_ref15, className, className !== null), _defineProperty(_ref15, styles.isCustomBackground, isCustomBackground), _defineProperty(_ref15, styles.isAnimated, !isStatic && !isPreview && isCustomBackground), _ref15)]),
|
|
465
|
+
width: width,
|
|
466
|
+
height: height,
|
|
467
|
+
playing: backgroundPlaying,
|
|
468
|
+
shouldLoad: backgroundShouldLoad
|
|
469
|
+
}) : /*#__PURE__*/React.createElement(Background, {
|
|
470
|
+
background: placeholderBackground,
|
|
471
|
+
className: styles.background,
|
|
472
|
+
width: width,
|
|
473
|
+
height: height,
|
|
474
|
+
styles: {
|
|
475
|
+
backgroundColor: 'red'
|
|
476
|
+
}
|
|
477
|
+
}), /*#__PURE__*/React.createElement(Container, {
|
|
478
|
+
width: width,
|
|
479
|
+
height: height
|
|
480
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
481
|
+
className: styles.content
|
|
482
|
+
}, items)));
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
UrbaniaTrivia.propTypes = propTypes;
|
|
486
|
+
UrbaniaTrivia.defaultProps = defaultProps;
|
|
487
|
+
var UrbaniaTriviaScreen = /*#__PURE__*/React.memo(UrbaniaTrivia);
|
|
488
|
+
|
|
489
|
+
var transform = function transform() {
|
|
490
|
+
return null;
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
// eslint-disable-next-line
|
|
494
|
+
|
|
495
|
+
var transforms = /*#__PURE__*/Object.freeze({
|
|
496
|
+
__proto__: null,
|
|
497
|
+
appleNews: transform
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
var definition = {
|
|
501
|
+
id: 'urbania-trivia',
|
|
502
|
+
type: 'screen',
|
|
503
|
+
namespaces: ['urbania'],
|
|
504
|
+
group: {
|
|
505
|
+
label: defineMessage({
|
|
506
|
+
id: "oPjl8f",
|
|
507
|
+
defaultMessage: [{
|
|
508
|
+
"type": 0,
|
|
509
|
+
"value": "Urbania"
|
|
510
|
+
}]
|
|
511
|
+
}),
|
|
512
|
+
order: 10
|
|
513
|
+
},
|
|
514
|
+
title: defineMessage({
|
|
515
|
+
id: "eA6lME",
|
|
516
|
+
defaultMessage: [{
|
|
517
|
+
"type": 0,
|
|
518
|
+
"value": "Urbania trivia screen"
|
|
519
|
+
}]
|
|
520
|
+
}),
|
|
521
|
+
component: UrbaniaTriviaScreen,
|
|
522
|
+
transforms: transforms,
|
|
523
|
+
fields: [{
|
|
524
|
+
name: 'title',
|
|
525
|
+
type: 'heading-element',
|
|
526
|
+
theme: {
|
|
527
|
+
textStyle: 'heading1'
|
|
528
|
+
},
|
|
529
|
+
label: defineMessage({
|
|
530
|
+
id: "N25iDO",
|
|
531
|
+
defaultMessage: [{
|
|
532
|
+
"type": 0,
|
|
533
|
+
"value": "Title"
|
|
534
|
+
}]
|
|
535
|
+
})
|
|
536
|
+
}, {
|
|
537
|
+
name: 'video',
|
|
538
|
+
type: 'video-element',
|
|
539
|
+
theme: {
|
|
540
|
+
color: 'primary'
|
|
541
|
+
},
|
|
542
|
+
defaultValue: {
|
|
543
|
+
autoPlay: true
|
|
544
|
+
},
|
|
545
|
+
label: defineMessage({
|
|
546
|
+
id: "tvl2Zc",
|
|
547
|
+
defaultMessage: [{
|
|
548
|
+
"type": 0,
|
|
549
|
+
"value": "Video"
|
|
550
|
+
}]
|
|
551
|
+
})
|
|
552
|
+
}, {
|
|
553
|
+
name: 'gotoNextScreenOnEnd',
|
|
554
|
+
type: 'toggle',
|
|
555
|
+
defaultValue: false,
|
|
556
|
+
label: defineMessage({
|
|
557
|
+
id: "n8zmLY",
|
|
558
|
+
defaultMessage: [{
|
|
559
|
+
"type": 0,
|
|
560
|
+
"value": "Go to next screen on end"
|
|
561
|
+
}]
|
|
562
|
+
})
|
|
563
|
+
}, {
|
|
564
|
+
name: 'background',
|
|
565
|
+
type: 'background',
|
|
566
|
+
label: defineMessage({
|
|
567
|
+
id: "+MPZRu",
|
|
568
|
+
defaultMessage: [{
|
|
569
|
+
"type": 0,
|
|
570
|
+
"value": "Background"
|
|
571
|
+
}]
|
|
572
|
+
})
|
|
573
|
+
} // {
|
|
574
|
+
// name: 'callToAction',
|
|
575
|
+
// type: 'call-to-action',
|
|
576
|
+
// theme: {
|
|
577
|
+
// label: {
|
|
578
|
+
// textStyle: 'heading2',
|
|
579
|
+
// },
|
|
580
|
+
// },
|
|
581
|
+
// },
|
|
582
|
+
]
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
export { UrbaniaTriviaScreen as UrbaniaTrivia, definition as default };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,608 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var reactIntl = require('react-intl');
|
|
6
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
7
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
8
|
+
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
9
|
+
var size = require('@folklore/size');
|
|
10
|
+
var classNames = require('classnames');
|
|
11
|
+
var isArray = require('lodash/isArray');
|
|
12
|
+
var PropTypes = require('prop-types');
|
|
13
|
+
var React = require('react');
|
|
14
|
+
var core = require('@micromag/core');
|
|
15
|
+
var components = require('@micromag/core/components');
|
|
16
|
+
var contexts = require('@micromag/core/contexts');
|
|
17
|
+
var hooks = require('@micromag/core/hooks');
|
|
18
|
+
var Background = require('@micromag/element-background');
|
|
19
|
+
var CallToAction = require('@micromag/element-call-to-action');
|
|
20
|
+
var ClosedCaptions = require('@micromag/element-closed-captions');
|
|
21
|
+
var Container = require('@micromag/element-container');
|
|
22
|
+
var Heading = require('@micromag/element-heading');
|
|
23
|
+
var Image = require('@micromag/element-image');
|
|
24
|
+
var MediaControls = require('@micromag/element-media-controls');
|
|
25
|
+
var Video = require('@micromag/element-video');
|
|
26
|
+
|
|
27
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
28
|
+
|
|
29
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
30
|
+
var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);
|
|
31
|
+
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
32
|
+
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
33
|
+
var isArray__default = /*#__PURE__*/_interopDefaultLegacy(isArray);
|
|
34
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
35
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
36
|
+
var Background__default = /*#__PURE__*/_interopDefaultLegacy(Background);
|
|
37
|
+
var CallToAction__default = /*#__PURE__*/_interopDefaultLegacy(CallToAction);
|
|
38
|
+
var ClosedCaptions__default = /*#__PURE__*/_interopDefaultLegacy(ClosedCaptions);
|
|
39
|
+
var Container__default = /*#__PURE__*/_interopDefaultLegacy(Container);
|
|
40
|
+
var Heading__default = /*#__PURE__*/_interopDefaultLegacy(Heading);
|
|
41
|
+
var Image__default = /*#__PURE__*/_interopDefaultLegacy(Image);
|
|
42
|
+
var MediaControls__default = /*#__PURE__*/_interopDefaultLegacy(MediaControls);
|
|
43
|
+
var Video__default = /*#__PURE__*/_interopDefaultLegacy(Video);
|
|
44
|
+
|
|
45
|
+
var img$1 = "data:image/svg+xml,%3c%3fxml version='1.0' encoding='UTF-8'%3f%3e%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1083.95 1920'%3e %3cg id='a'/%3e %3cg id='b'%3e %3cg id='c'%3e %3cpath d='M1083.95%2c0h-103.4l-438.55%2c959.95L1083.95%2c109.31V0Zm0%2c295L542.02%2c959.96l541.93-498.87v-166.08Zm0%2c274.99l-541.92%2c389.98%2c541.92-279.64v-110.34Zm0%2c190.53l-541.92%2c199.46%2c541.92-110.89v-88.57Zm0%2c158.17l-541.92%2c41.31%2c541.92%2c41.31v-82.61Zm0%2c152.21l-541.92-110.89%2c541.92%2c199.46v-88.58Zm0%2c168.77l-541.92-279.64%2c541.92%2c389.98v-110.34Zm0%2c219.25l-541.93-498.87%2c541.93%2c664.95v-166.08Zm0%2c351.77L542%2c960.05l438.55%2c959.95h103.4v-109.31ZM854.8%2c0h-138.91l-173.9%2c959.94L854.8%2c0Zm0%2c1920l-312.81-959.94%2c173.9%2c959.94h138.91ZM606.75%2c0h-129.56l64.78%2c959.94L606.75%2c0Zm0%2c1920l-64.78-959.94-64.78%2c959.94h129.56Zm-64.79-960.06L368.06%2c0H229.15l312.81%2c959.94Zm0%2c.12L229.15%2c1920h138.91l173.9-959.94Zm-.01-.11L103.4%2c0H0V109.31L541.94%2c959.95Zm0%2c.11L0%2c1810.69v109.31H103.4l438.55-959.95Zm-.01-.1L0%2c295.01v166.08l541.93%2c498.87Zm0%2c.09L0%2c1458.91v166.08L541.93%2c960.04Zm-.01-.07L0%2c570v110.34l541.92%2c279.63Zm0%2c.02L0%2c760.52v88.57l541.92%2c110.89Zm0%2c.02L0%2c918.69v82.61l541.92-41.31Zm0%2c.02L0%2c1070.9v88.57l541.92-199.46Zm0%2c.02L0%2c1239.66v110.34l541.92-389.97Z' fill='hsla(0%2c0%25%2c100%25%2c.6)'/%3e %3c/g%3e %3c/g%3e%3c/svg%3e";
|
|
46
|
+
|
|
47
|
+
var img = "data:image/svg+xml,%3c%3fxml version='1.0' encoding='UTF-8'%3f%3e%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1083.95 1920'%3e %3cg id='a'/%3e %3cg id='b'%3e %3cg id='c'%3e %3cpath d='M1083.95%2c0h-103.4l-438.55%2c959.95L1083.95%2c109.31V0Zm0%2c295L542.02%2c959.96l541.93-498.87v-166.08Zm0%2c274.99l-541.92%2c389.98%2c541.92-279.64v-110.34Zm0%2c190.53l-541.92%2c199.46%2c541.92-110.89v-88.57Zm0%2c158.17l-541.92%2c41.31%2c541.92%2c41.31v-82.61Zm0%2c152.21l-541.92-110.89%2c541.92%2c199.46v-88.58Zm0%2c168.77l-541.92-279.64%2c541.92%2c389.98v-110.34Zm0%2c219.25l-541.93-498.87%2c541.93%2c664.95v-166.08Zm0%2c351.77L542%2c960.05l438.55%2c959.95h103.4v-109.31ZM854.8%2c0h-138.91l-173.9%2c959.94L854.8%2c0Zm0%2c1920l-312.81-959.94%2c173.9%2c959.94h138.91ZM606.75%2c0h-129.56l64.78%2c959.94L606.75%2c0Zm0%2c1920l-64.78-959.94-64.78%2c959.94h129.56Zm-64.79-960.06L368.06%2c0H229.15l312.81%2c959.94Zm0%2c.12L229.15%2c1920h138.91l173.9-959.94Zm-.01-.11L103.4%2c0H0V109.31L541.94%2c959.95Zm0%2c.11L0%2c1810.69v109.31H103.4l438.55-959.95Zm-.01-.1L0%2c295.01v166.08l541.93%2c498.87Zm0%2c.09L0%2c1458.91v166.08L541.93%2c960.04Zm-.01-.07L0%2c570v110.34l541.92%2c279.63Zm0%2c.02L0%2c760.52v88.57l541.92%2c110.89Zm0%2c.02L0%2c918.69v82.61l541.92-41.31Zm0%2c.02L0%2c1070.9v88.57l541.92-199.46Zm0%2c.02L0%2c1239.66v110.34l541.92-389.97Z' fill='%2312bbd7'/%3e %3c/g%3e %3c/g%3e%3c/svg%3e";
|
|
48
|
+
|
|
49
|
+
var styles = {"container":"micromag-screen-urbania-trivia-container","content":"micromag-screen-urbania-trivia-content","empty":"micromag-screen-urbania-trivia-empty","emptyContainer":"micromag-screen-urbania-trivia-emptyContainer","fullscreen":"micromag-screen-urbania-trivia-fullscreen","image":"micromag-screen-urbania-trivia-image","placeholder":"micromag-screen-urbania-trivia-placeholder","disabled":"micromag-screen-urbania-trivia-disabled","hidden":"micromag-screen-urbania-trivia-hidden","itemsContainer":"micromag-screen-urbania-trivia-itemsContainer","videoContainer":"micromag-screen-urbania-trivia-videoContainer","video":"micromag-screen-urbania-trivia-video","isCustomBackground":"micromag-screen-urbania-trivia-isCustomBackground","isAnimated":"micromag-screen-urbania-trivia-isAnimated","spin":"micromag-screen-urbania-trivia-spin","heading":"micromag-screen-urbania-trivia-heading","hideHeading":"micromag-screen-urbania-trivia-hideHeading","callToAction":"micromag-screen-urbania-trivia-callToAction","bottom":"micromag-screen-urbania-trivia-bottom","visible":"micromag-screen-urbania-trivia-visible","withGradient":"micromag-screen-urbania-trivia-withGradient","mediaControls":"micromag-screen-urbania-trivia-mediaControls","videoPlaceholder":"micromag-screen-urbania-trivia-videoPlaceholder","bottomContent":"micromag-screen-urbania-trivia-bottomContent"};
|
|
50
|
+
|
|
51
|
+
var defaultBackground = {
|
|
52
|
+
image: {
|
|
53
|
+
type: 'image',
|
|
54
|
+
url: img,
|
|
55
|
+
width: 1083,
|
|
56
|
+
height: 1919
|
|
57
|
+
},
|
|
58
|
+
color: '#00cbff'
|
|
59
|
+
};
|
|
60
|
+
var placeholderBackground = {
|
|
61
|
+
image: {
|
|
62
|
+
type: 'image',
|
|
63
|
+
url: img$1,
|
|
64
|
+
width: 1083,
|
|
65
|
+
height: 1919
|
|
66
|
+
},
|
|
67
|
+
color: null
|
|
68
|
+
};
|
|
69
|
+
var propTypes = {
|
|
70
|
+
layout: PropTypes__default["default"].oneOf(['middle', 'full']),
|
|
71
|
+
title: core.PropTypes.headingElement,
|
|
72
|
+
video: core.PropTypes.videoElement,
|
|
73
|
+
gotoNextScreenOnEnd: PropTypes__default["default"].bool,
|
|
74
|
+
background: core.PropTypes.backgroundElement,
|
|
75
|
+
callToAction: core.PropTypes.callToAction,
|
|
76
|
+
current: PropTypes__default["default"].bool,
|
|
77
|
+
active: PropTypes__default["default"].bool,
|
|
78
|
+
transitions: core.PropTypes.transitions,
|
|
79
|
+
spacing: PropTypes__default["default"].number,
|
|
80
|
+
padding: PropTypes__default["default"].number,
|
|
81
|
+
getMediaRef: PropTypes__default["default"].func,
|
|
82
|
+
className: PropTypes__default["default"].string
|
|
83
|
+
};
|
|
84
|
+
var defaultProps = {
|
|
85
|
+
layout: 'full',
|
|
86
|
+
title: null,
|
|
87
|
+
video: null,
|
|
88
|
+
gotoNextScreenOnEnd: false,
|
|
89
|
+
background: null,
|
|
90
|
+
callToAction: null,
|
|
91
|
+
current: true,
|
|
92
|
+
active: true,
|
|
93
|
+
transitions: null,
|
|
94
|
+
spacing: 20,
|
|
95
|
+
padding: 20,
|
|
96
|
+
getMediaRef: null,
|
|
97
|
+
className: null
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
var UrbaniaTrivia = function UrbaniaTrivia(_ref) {
|
|
101
|
+
var _ref11, _ref12, _ref14, _ref15;
|
|
102
|
+
|
|
103
|
+
var layout = _ref.layout,
|
|
104
|
+
title = _ref.title,
|
|
105
|
+
video = _ref.video,
|
|
106
|
+
gotoNextScreenOnEnd = _ref.gotoNextScreenOnEnd,
|
|
107
|
+
background = _ref.background,
|
|
108
|
+
callToAction = _ref.callToAction,
|
|
109
|
+
current = _ref.current,
|
|
110
|
+
active = _ref.active,
|
|
111
|
+
transitions = _ref.transitions,
|
|
112
|
+
spacing = _ref.spacing,
|
|
113
|
+
padding = _ref.padding,
|
|
114
|
+
getMediaRef = _ref.getMediaRef,
|
|
115
|
+
className = _ref.className;
|
|
116
|
+
var trackScreenMedia = hooks.useTrackScreenMedia('video');
|
|
117
|
+
|
|
118
|
+
var _useScreenSize = contexts.useScreenSize(),
|
|
119
|
+
width = _useScreenSize.width,
|
|
120
|
+
height = _useScreenSize.height;
|
|
121
|
+
|
|
122
|
+
var _useScreenRenderConte = contexts.useScreenRenderContext(),
|
|
123
|
+
isView = _useScreenRenderConte.isView,
|
|
124
|
+
isPreview = _useScreenRenderConte.isPreview,
|
|
125
|
+
isPlaceholder = _useScreenRenderConte.isPlaceholder,
|
|
126
|
+
isEdit = _useScreenRenderConte.isEdit,
|
|
127
|
+
isStatic = _useScreenRenderConte.isStatic,
|
|
128
|
+
isCapture = _useScreenRenderConte.isCapture;
|
|
129
|
+
|
|
130
|
+
var _useViewerNavigation = contexts.useViewerNavigation(),
|
|
131
|
+
gotoNextScreen = _useViewerNavigation.gotoNextScreen;
|
|
132
|
+
|
|
133
|
+
var backgroundPlaying = current && (isView || isEdit);
|
|
134
|
+
var backgroundShouldLoad = current || active || !isView;
|
|
135
|
+
var videoShouldLoad = current || active || !isView;
|
|
136
|
+
var shouldGotoNextScreenOnEnd = gotoNextScreenOnEnd && isView && current;
|
|
137
|
+
|
|
138
|
+
var _ref2 = title || {},
|
|
139
|
+
_ref2$body = _ref2.body,
|
|
140
|
+
body = _ref2$body === void 0 ? '' : _ref2$body; // get resized video style props
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
var _ref3 = video || {},
|
|
144
|
+
_ref3$autoPlay = _ref3.autoPlay,
|
|
145
|
+
autoPlay = _ref3$autoPlay === void 0 ? true : _ref3$autoPlay,
|
|
146
|
+
_ref3$media = _ref3.media,
|
|
147
|
+
videoMedia = _ref3$media === void 0 ? null : _ref3$media,
|
|
148
|
+
_ref3$closedCaptions = _ref3.closedCaptions,
|
|
149
|
+
closedCaptions = _ref3$closedCaptions === void 0 ? null : _ref3$closedCaptions,
|
|
150
|
+
_ref3$withSeekBar = _ref3.withSeekBar,
|
|
151
|
+
withSeekBar = _ref3$withSeekBar === void 0 ? false : _ref3$withSeekBar,
|
|
152
|
+
_ref3$withPlayPause = _ref3.withPlayPause,
|
|
153
|
+
withPlayPause = _ref3$withPlayPause === void 0 ? false : _ref3$withPlayPause,
|
|
154
|
+
_ref3$withTime = _ref3.withTime,
|
|
155
|
+
withTime = _ref3$withTime === void 0 ? false : _ref3$withTime;
|
|
156
|
+
|
|
157
|
+
var apiRef = React.useRef();
|
|
158
|
+
|
|
159
|
+
var _ref4 = apiRef.current || {},
|
|
160
|
+
togglePlay = _ref4.togglePlay,
|
|
161
|
+
toggleMute = _ref4.toggleMute,
|
|
162
|
+
seek = _ref4.seek,
|
|
163
|
+
play = _ref4.play,
|
|
164
|
+
pause = _ref4.pause,
|
|
165
|
+
_ref4$mediaRef = _ref4.mediaRef,
|
|
166
|
+
apiMediaRef = _ref4$mediaRef === void 0 ? null : _ref4$mediaRef;
|
|
167
|
+
|
|
168
|
+
React.useEffect(function () {
|
|
169
|
+
if (apiMediaRef !== null && getMediaRef !== null) {
|
|
170
|
+
getMediaRef(apiMediaRef.current);
|
|
171
|
+
}
|
|
172
|
+
}, [apiMediaRef, getMediaRef]);
|
|
173
|
+
var mouseMoveRef = React.useRef(null);
|
|
174
|
+
|
|
175
|
+
var _useState = React.useState(false),
|
|
176
|
+
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
177
|
+
showMediaControls = _useState2[0],
|
|
178
|
+
setShowMediaControls = _useState2[1]; // Get api state updates from callback
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
var _useState3 = React.useState(null),
|
|
182
|
+
_useState4 = _slicedToArray__default["default"](_useState3, 2),
|
|
183
|
+
currentTime = _useState4[0],
|
|
184
|
+
setCurrentTime = _useState4[1];
|
|
185
|
+
|
|
186
|
+
var _useState5 = React.useState(null),
|
|
187
|
+
_useState6 = _slicedToArray__default["default"](_useState5, 2),
|
|
188
|
+
duration = _useState6[0],
|
|
189
|
+
setDuration = _useState6[1];
|
|
190
|
+
|
|
191
|
+
var _useState7 = React.useState(false),
|
|
192
|
+
_useState8 = _slicedToArray__default["default"](_useState7, 2),
|
|
193
|
+
playing = _useState8[0],
|
|
194
|
+
setPlaying = _useState8[1];
|
|
195
|
+
|
|
196
|
+
var _useState9 = React.useState(false),
|
|
197
|
+
_useState10 = _slicedToArray__default["default"](_useState9, 2),
|
|
198
|
+
muted = _useState10[0],
|
|
199
|
+
setMuted = _useState10[1];
|
|
200
|
+
|
|
201
|
+
var onTimeUpdate = React.useCallback(function (time) {
|
|
202
|
+
setCurrentTime(time);
|
|
203
|
+
}, [setDuration, duration]);
|
|
204
|
+
var onProgressStep = React.useCallback(function (step) {
|
|
205
|
+
trackScreenMedia(video, "progress_".concat(Math.round(step * 100, 10), "%"));
|
|
206
|
+
}, [trackScreenMedia, video]);
|
|
207
|
+
var onDurationChanged = React.useCallback(function (dur) {
|
|
208
|
+
setDuration(dur);
|
|
209
|
+
}, [setDuration]);
|
|
210
|
+
var onPlay = React.useCallback(function (_ref5) {
|
|
211
|
+
var initial = _ref5.initial;
|
|
212
|
+
setPlaying(true);
|
|
213
|
+
trackScreenMedia(video, initial ? 'play' : 'resume');
|
|
214
|
+
}, [trackScreenMedia, video]);
|
|
215
|
+
var onPause = React.useCallback(function (_ref6) {
|
|
216
|
+
var midway = _ref6.midway;
|
|
217
|
+
setPlaying(false);
|
|
218
|
+
trackScreenMedia(video, midway ? 'pause' : 'ended');
|
|
219
|
+
}, [trackScreenMedia, video]);
|
|
220
|
+
var onVolumeChanged = React.useCallback(function (isMuted) {
|
|
221
|
+
setMuted(isMuted);
|
|
222
|
+
trackScreenMedia(video, isMuted ? 'mute' : 'unmute');
|
|
223
|
+
}, [trackScreenMedia, video]);
|
|
224
|
+
var onSeek = React.useCallback(function (e) {
|
|
225
|
+
seek(e);
|
|
226
|
+
play();
|
|
227
|
+
}, [seek, play]);
|
|
228
|
+
var onSeeked = React.useCallback(function (time) {
|
|
229
|
+
if (time > 0) {
|
|
230
|
+
trackScreenMedia(video, 'seek');
|
|
231
|
+
}
|
|
232
|
+
}, [trackScreenMedia, video]);
|
|
233
|
+
var onToggleMute = React.useCallback(function () {
|
|
234
|
+
if (muted && !playing) {
|
|
235
|
+
play();
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
toggleMute();
|
|
239
|
+
}, [muted, toggleMute]);
|
|
240
|
+
var onEnded = React.useCallback(function () {
|
|
241
|
+
if (shouldGotoNextScreenOnEnd) {
|
|
242
|
+
gotoNextScreen();
|
|
243
|
+
}
|
|
244
|
+
}, [shouldGotoNextScreenOnEnd, seek, gotoNextScreen]);
|
|
245
|
+
React.useEffect(function () {
|
|
246
|
+
if (!current && playing) {
|
|
247
|
+
pause();
|
|
248
|
+
}
|
|
249
|
+
}, [playing, current]);
|
|
250
|
+
var onMouseMove = React.useCallback(function (e) {
|
|
251
|
+
var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1800;
|
|
252
|
+
setShowMediaControls(true);
|
|
253
|
+
|
|
254
|
+
if (mouseMoveRef.current !== null) {
|
|
255
|
+
clearTimeout(mouseMoveRef.current);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
mouseMoveRef.current = setTimeout(function () {
|
|
259
|
+
setShowMediaControls(false);
|
|
260
|
+
mouseMoveRef.current = null;
|
|
261
|
+
}, time);
|
|
262
|
+
}, [setShowMediaControls]);
|
|
263
|
+
var onLongPress = React.useCallback(function () {
|
|
264
|
+
if (!playing) {
|
|
265
|
+
play();
|
|
266
|
+
} else if (withPlayPause) {
|
|
267
|
+
onMouseMove(null, 3000);
|
|
268
|
+
} else {
|
|
269
|
+
pause();
|
|
270
|
+
}
|
|
271
|
+
}, [play, playing, pause, onMouseMove, withPlayPause, setShowMediaControls]);
|
|
272
|
+
var longPressBind = hooks.useLongPress({
|
|
273
|
+
onLongPress: onLongPress,
|
|
274
|
+
onClick: onMouseMove
|
|
275
|
+
});
|
|
276
|
+
var fullscreen = layout === 'full';
|
|
277
|
+
var hasCallToAction = callToAction !== null && callToAction.active === true;
|
|
278
|
+
|
|
279
|
+
var _ref7 = background || {},
|
|
280
|
+
_ref7$image = _ref7.image,
|
|
281
|
+
backgroundImage = _ref7$image === void 0 ? null : _ref7$image,
|
|
282
|
+
_ref7$video = _ref7.video,
|
|
283
|
+
backgroundVideo = _ref7$video === void 0 ? null : _ref7$video;
|
|
284
|
+
|
|
285
|
+
var isCustomBackground = background === null || backgroundImage === null && backgroundVideo === null;
|
|
286
|
+
var hasVideo = video !== null;
|
|
287
|
+
|
|
288
|
+
var _useState11 = React.useState(hasVideo),
|
|
289
|
+
_useState12 = _slicedToArray__default["default"](_useState11, 2),
|
|
290
|
+
ready = _useState12[0],
|
|
291
|
+
setReady = _useState12[1];
|
|
292
|
+
|
|
293
|
+
var transitionPlaying = current && ready;
|
|
294
|
+
var transitionDisabled = isStatic || isCapture || isPlaceholder || isPreview || isEdit;
|
|
295
|
+
var finalVideo = React.useMemo(function () {
|
|
296
|
+
return hasVideo ? _objectSpread__default["default"](_objectSpread__default["default"]({}, video), {}, {
|
|
297
|
+
autoPlay: !isPreview && !isStatic && !isCapture && autoPlay && current
|
|
298
|
+
}) : null;
|
|
299
|
+
}, [hasVideo, video, isPreview, isStatic, isCapture, autoPlay, current]);
|
|
300
|
+
|
|
301
|
+
var _ref8 = videoMedia || {},
|
|
302
|
+
_ref8$metadata = _ref8.metadata,
|
|
303
|
+
videoMetadata = _ref8$metadata === void 0 ? null : _ref8$metadata,
|
|
304
|
+
_ref8$url = _ref8.url,
|
|
305
|
+
videoUrl = _ref8$url === void 0 ? null : _ref8$url,
|
|
306
|
+
_ref8$thumbnail_url = _ref8.thumbnail_url,
|
|
307
|
+
thumbnailUrl = _ref8$thumbnail_url === void 0 ? null : _ref8$thumbnail_url;
|
|
308
|
+
|
|
309
|
+
var hasVideoUrl = videoUrl !== null;
|
|
310
|
+
|
|
311
|
+
var _ref9 = videoMetadata || {},
|
|
312
|
+
_ref9$width = _ref9.width,
|
|
313
|
+
videoWidth = _ref9$width === void 0 ? 0 : _ref9$width,
|
|
314
|
+
_ref9$height = _ref9.height,
|
|
315
|
+
videoHeight = _ref9$height === void 0 ? 0 : _ref9$height;
|
|
316
|
+
|
|
317
|
+
var _useResizeObserver = hooks.useResizeObserver(),
|
|
318
|
+
titleRef = _useResizeObserver.ref,
|
|
319
|
+
_useResizeObserver$en = _useResizeObserver.entry.contentRect,
|
|
320
|
+
contentRect = _useResizeObserver$en === void 0 ? null : _useResizeObserver$en;
|
|
321
|
+
|
|
322
|
+
var _ref10 = contentRect || {},
|
|
323
|
+
_ref10$height = _ref10.height,
|
|
324
|
+
titleHeight = _ref10$height === void 0 ? 0 : _ref10$height;
|
|
325
|
+
|
|
326
|
+
var videoMaxHeight = height - titleHeight - (padding ? padding * 2 : 40);
|
|
327
|
+
|
|
328
|
+
var _getSizeWithinBounds = size.getSizeWithinBounds(videoWidth, videoHeight, width, videoMaxHeight, {
|
|
329
|
+
cover: fullscreen
|
|
330
|
+
}),
|
|
331
|
+
resizedVideoWidth = _getSizeWithinBounds.width,
|
|
332
|
+
resizedVideoHeight = _getSizeWithinBounds.height;
|
|
333
|
+
|
|
334
|
+
var resizedVideoLeft = -(resizedVideoWidth - width) / 2; // const resizedVideoTop = -(resizedVideoHeight - videoMaxHeight) / 2;
|
|
335
|
+
|
|
336
|
+
var finalBackground = React.useMemo(function () {
|
|
337
|
+
if (isArray__default["default"](background) && background.length > 0) {
|
|
338
|
+
return background;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (background !== null) {
|
|
342
|
+
return _objectSpread__default["default"](_objectSpread__default["default"]({}, defaultBackground), background);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
return defaultBackground;
|
|
346
|
+
}, [background]);
|
|
347
|
+
var placeholderProps = fullscreen ? {
|
|
348
|
+
width: '100%',
|
|
349
|
+
height: '100%'
|
|
350
|
+
} : {
|
|
351
|
+
width: '100%'
|
|
352
|
+
};
|
|
353
|
+
React.useEffect(function () {
|
|
354
|
+
setReady(!hasVideoUrl);
|
|
355
|
+
}, [videoUrl, hasVideoUrl, setReady]);
|
|
356
|
+
var onVideoReady = React.useCallback(function () {
|
|
357
|
+
setReady(true);
|
|
358
|
+
}, [setReady]);
|
|
359
|
+
var visibleControls = !autoPlay && !playing || muted || showMediaControls;
|
|
360
|
+
var items = [/*#__PURE__*/React__default["default"].createElement(Container__default["default"], {
|
|
361
|
+
className: styles.itemsContainer
|
|
362
|
+
}, /*#__PURE__*/React__default["default"].createElement(components.ScreenElement, {
|
|
363
|
+
key: "heading",
|
|
364
|
+
className: styles.headingScreenElement,
|
|
365
|
+
placeholder: /*#__PURE__*/React__default["default"].createElement(components.PlaceholderTitle, Object.assign({
|
|
366
|
+
className: styles.placeholder
|
|
367
|
+
}, placeholderProps)),
|
|
368
|
+
empty: /*#__PURE__*/React__default["default"].createElement("div", {
|
|
369
|
+
className: styles.emptyContainer
|
|
370
|
+
}, /*#__PURE__*/React__default["default"].createElement(components.Empty, {
|
|
371
|
+
className: styles.empty
|
|
372
|
+
}, /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
|
|
373
|
+
id: "oAtOlP",
|
|
374
|
+
defaultMessage: [{
|
|
375
|
+
"type": 0,
|
|
376
|
+
"value": "Heading"
|
|
377
|
+
}]
|
|
378
|
+
}))),
|
|
379
|
+
isEmpty: body.length === 0
|
|
380
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
381
|
+
ref: titleRef
|
|
382
|
+
}, /*#__PURE__*/React__default["default"].createElement(Heading__default["default"], Object.assign({
|
|
383
|
+
className: classNames__default["default"]([styles.heading, (_ref11 = {}, _defineProperty__default["default"](_ref11, className, className !== null), _defineProperty__default["default"](_ref11, styles.hideHeading, body.length === 0), _ref11)]),
|
|
384
|
+
body: body
|
|
385
|
+
}, title)))), /*#__PURE__*/React__default["default"].createElement(components.ScreenElement, {
|
|
386
|
+
key: "video",
|
|
387
|
+
className: styles.videoScreenElement,
|
|
388
|
+
placeholder: /*#__PURE__*/React__default["default"].createElement(components.PlaceholderVideo, Object.assign({
|
|
389
|
+
className: styles.videoPlaceholder,
|
|
390
|
+
height: "300px"
|
|
391
|
+
}, placeholderProps)),
|
|
392
|
+
empty: /*#__PURE__*/React__default["default"].createElement("div", {
|
|
393
|
+
className: styles.emptyContainer
|
|
394
|
+
}, /*#__PURE__*/React__default["default"].createElement(components.Empty, {
|
|
395
|
+
className: styles.empty
|
|
396
|
+
}, /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
|
|
397
|
+
id: "3ext9Q",
|
|
398
|
+
defaultMessage: [{
|
|
399
|
+
"type": 0,
|
|
400
|
+
"value": "Video"
|
|
401
|
+
}]
|
|
402
|
+
}))),
|
|
403
|
+
isEmpty: !hasVideoUrl
|
|
404
|
+
}, hasVideoUrl ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
405
|
+
className: styles.videoContainer,
|
|
406
|
+
style: {
|
|
407
|
+
width: Math.min(width, resizedVideoWidth),
|
|
408
|
+
height: resizedVideoHeight,
|
|
409
|
+
left: resizedVideoLeft > 0 ? resizedVideoLeft : null,
|
|
410
|
+
maxHeight: videoMaxHeight
|
|
411
|
+
}
|
|
412
|
+
}, isPreview || isCapture ? /*#__PURE__*/React__default["default"].createElement(Image__default["default"], {
|
|
413
|
+
className: styles.image,
|
|
414
|
+
media: {
|
|
415
|
+
url: thumbnailUrl,
|
|
416
|
+
metadata: {
|
|
417
|
+
width: videoWidth,
|
|
418
|
+
height: videoHeight
|
|
419
|
+
}
|
|
420
|
+
},
|
|
421
|
+
width: "100%",
|
|
422
|
+
height: "100%"
|
|
423
|
+
}) : /*#__PURE__*/React__default["default"].createElement(Video__default["default"], Object.assign({}, finalVideo, {
|
|
424
|
+
ref: apiRef,
|
|
425
|
+
width: resizedVideoWidth,
|
|
426
|
+
height: resizedVideoHeight,
|
|
427
|
+
className: styles.video,
|
|
428
|
+
onReady: onVideoReady,
|
|
429
|
+
onPlay: onPlay,
|
|
430
|
+
onPause: onPause,
|
|
431
|
+
onTimeUpdate: onTimeUpdate,
|
|
432
|
+
onProgressStep: onProgressStep,
|
|
433
|
+
onDurationChanged: onDurationChanged,
|
|
434
|
+
onSeeked: onSeeked,
|
|
435
|
+
onEnded: onEnded,
|
|
436
|
+
onVolumeChanged: onVolumeChanged,
|
|
437
|
+
focusable: current && isView,
|
|
438
|
+
preload: videoShouldLoad ? 'auto' : 'metadata'
|
|
439
|
+
})), !isPlaceholder ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
440
|
+
key: "bottom-content",
|
|
441
|
+
className: styles.bottomContent
|
|
442
|
+
}, /*#__PURE__*/React__default["default"].createElement(components.Transitions, {
|
|
443
|
+
playing: transitionPlaying,
|
|
444
|
+
transitions: transitions,
|
|
445
|
+
disabled: transitionDisabled
|
|
446
|
+
}, closedCaptions !== null && !isPreview && !isCapture && !isStatic ? /*#__PURE__*/React__default["default"].createElement(ClosedCaptions__default["default"], {
|
|
447
|
+
className: styles.closedCaptions,
|
|
448
|
+
media: closedCaptions,
|
|
449
|
+
currentTime: currentTime
|
|
450
|
+
}) : null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
451
|
+
className: classNames__default["default"]([styles.bottom, (_ref12 = {}, _defineProperty__default["default"](_ref12, styles.visible, visibleControls), _defineProperty__default["default"](_ref12, styles.withGradient, withSeekBar || withPlayPause || muted), _ref12)])
|
|
452
|
+
}, hasVideoUrl ? /*#__PURE__*/React__default["default"].createElement(MediaControls__default["default"], {
|
|
453
|
+
className: classNames__default["default"]([styles.mediaControls, _defineProperty__default["default"]({}, styles.visible, visibleControls)]),
|
|
454
|
+
withSeekBar: withSeekBar,
|
|
455
|
+
withPlayPause: withPlayPause,
|
|
456
|
+
withTime: withTime,
|
|
457
|
+
playing: playing,
|
|
458
|
+
muted: muted,
|
|
459
|
+
currentTime: currentTime,
|
|
460
|
+
duration: duration,
|
|
461
|
+
onTogglePlay: togglePlay,
|
|
462
|
+
onToggleMute: onToggleMute,
|
|
463
|
+
onSeek: onSeek,
|
|
464
|
+
focusable: current && isView
|
|
465
|
+
}) : null, hasCallToAction ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
466
|
+
style: {
|
|
467
|
+
marginTop: -spacing / 2
|
|
468
|
+
}
|
|
469
|
+
}, /*#__PURE__*/React__default["default"].createElement(CallToAction__default["default"], {
|
|
470
|
+
className: styles.callToAction,
|
|
471
|
+
callToAction: callToAction,
|
|
472
|
+
animationDisabled: isPreview,
|
|
473
|
+
focusable: current && isView,
|
|
474
|
+
screenSize: {
|
|
475
|
+
width: width,
|
|
476
|
+
height: height
|
|
477
|
+
}
|
|
478
|
+
})) : null))) : null) : null))];
|
|
479
|
+
return /*#__PURE__*/React__default["default"].createElement("div", Object.assign({
|
|
480
|
+
className: classNames__default["default"]([styles.container, (_ref14 = {}, _defineProperty__default["default"](_ref14, className, className !== null), _defineProperty__default["default"](_ref14, styles.fullscreen, fullscreen), _ref14)]),
|
|
481
|
+
"data-screen-ready": isStatic || isCapture || ready
|
|
482
|
+
}, longPressBind, {
|
|
483
|
+
onMouseMove: onMouseMove
|
|
484
|
+
}), !isPlaceholder ? /*#__PURE__*/React__default["default"].createElement(Background__default["default"], {
|
|
485
|
+
background: finalBackground,
|
|
486
|
+
className: classNames__default["default"]([styles.background, (_ref15 = {}, _defineProperty__default["default"](_ref15, className, className !== null), _defineProperty__default["default"](_ref15, styles.isCustomBackground, isCustomBackground), _defineProperty__default["default"](_ref15, styles.isAnimated, !isStatic && !isPreview && isCustomBackground), _ref15)]),
|
|
487
|
+
width: width,
|
|
488
|
+
height: height,
|
|
489
|
+
playing: backgroundPlaying,
|
|
490
|
+
shouldLoad: backgroundShouldLoad
|
|
491
|
+
}) : /*#__PURE__*/React__default["default"].createElement(Background__default["default"], {
|
|
492
|
+
background: placeholderBackground,
|
|
493
|
+
className: styles.background,
|
|
494
|
+
width: width,
|
|
495
|
+
height: height,
|
|
496
|
+
styles: {
|
|
497
|
+
backgroundColor: 'red'
|
|
498
|
+
}
|
|
499
|
+
}), /*#__PURE__*/React__default["default"].createElement(Container__default["default"], {
|
|
500
|
+
width: width,
|
|
501
|
+
height: height
|
|
502
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
503
|
+
className: styles.content
|
|
504
|
+
}, items)));
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
UrbaniaTrivia.propTypes = propTypes;
|
|
508
|
+
UrbaniaTrivia.defaultProps = defaultProps;
|
|
509
|
+
var UrbaniaTriviaScreen = /*#__PURE__*/React__default["default"].memo(UrbaniaTrivia);
|
|
510
|
+
|
|
511
|
+
var transform = function transform() {
|
|
512
|
+
return null;
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
// eslint-disable-next-line
|
|
516
|
+
|
|
517
|
+
var transforms = /*#__PURE__*/Object.freeze({
|
|
518
|
+
__proto__: null,
|
|
519
|
+
appleNews: transform
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
var definition = {
|
|
523
|
+
id: 'urbania-trivia',
|
|
524
|
+
type: 'screen',
|
|
525
|
+
namespaces: ['urbania'],
|
|
526
|
+
group: {
|
|
527
|
+
label: reactIntl.defineMessage({
|
|
528
|
+
id: "oPjl8f",
|
|
529
|
+
defaultMessage: [{
|
|
530
|
+
"type": 0,
|
|
531
|
+
"value": "Urbania"
|
|
532
|
+
}]
|
|
533
|
+
}),
|
|
534
|
+
order: 10
|
|
535
|
+
},
|
|
536
|
+
title: reactIntl.defineMessage({
|
|
537
|
+
id: "eA6lME",
|
|
538
|
+
defaultMessage: [{
|
|
539
|
+
"type": 0,
|
|
540
|
+
"value": "Urbania trivia screen"
|
|
541
|
+
}]
|
|
542
|
+
}),
|
|
543
|
+
component: UrbaniaTriviaScreen,
|
|
544
|
+
transforms: transforms,
|
|
545
|
+
fields: [{
|
|
546
|
+
name: 'title',
|
|
547
|
+
type: 'heading-element',
|
|
548
|
+
theme: {
|
|
549
|
+
textStyle: 'heading1'
|
|
550
|
+
},
|
|
551
|
+
label: reactIntl.defineMessage({
|
|
552
|
+
id: "N25iDO",
|
|
553
|
+
defaultMessage: [{
|
|
554
|
+
"type": 0,
|
|
555
|
+
"value": "Title"
|
|
556
|
+
}]
|
|
557
|
+
})
|
|
558
|
+
}, {
|
|
559
|
+
name: 'video',
|
|
560
|
+
type: 'video-element',
|
|
561
|
+
theme: {
|
|
562
|
+
color: 'primary'
|
|
563
|
+
},
|
|
564
|
+
defaultValue: {
|
|
565
|
+
autoPlay: true
|
|
566
|
+
},
|
|
567
|
+
label: reactIntl.defineMessage({
|
|
568
|
+
id: "tvl2Zc",
|
|
569
|
+
defaultMessage: [{
|
|
570
|
+
"type": 0,
|
|
571
|
+
"value": "Video"
|
|
572
|
+
}]
|
|
573
|
+
})
|
|
574
|
+
}, {
|
|
575
|
+
name: 'gotoNextScreenOnEnd',
|
|
576
|
+
type: 'toggle',
|
|
577
|
+
defaultValue: false,
|
|
578
|
+
label: reactIntl.defineMessage({
|
|
579
|
+
id: "n8zmLY",
|
|
580
|
+
defaultMessage: [{
|
|
581
|
+
"type": 0,
|
|
582
|
+
"value": "Go to next screen on end"
|
|
583
|
+
}]
|
|
584
|
+
})
|
|
585
|
+
}, {
|
|
586
|
+
name: 'background',
|
|
587
|
+
type: 'background',
|
|
588
|
+
label: reactIntl.defineMessage({
|
|
589
|
+
id: "+MPZRu",
|
|
590
|
+
defaultMessage: [{
|
|
591
|
+
"type": 0,
|
|
592
|
+
"value": "Background"
|
|
593
|
+
}]
|
|
594
|
+
})
|
|
595
|
+
} // {
|
|
596
|
+
// name: 'callToAction',
|
|
597
|
+
// type: 'call-to-action',
|
|
598
|
+
// theme: {
|
|
599
|
+
// label: {
|
|
600
|
+
// textStyle: 'heading2',
|
|
601
|
+
// },
|
|
602
|
+
// },
|
|
603
|
+
// },
|
|
604
|
+
]
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
exports.UrbaniaTrivia = UrbaniaTriviaScreen;
|
|
608
|
+
exports["default"] = definition;
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@micromag/screen-urbania-trivia",
|
|
3
|
+
"version": "0.3.57",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"javascript"
|
|
7
|
+
],
|
|
8
|
+
"homepage": "https://github.com/urbania-media/micromag-js",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/urbania-media/micromag-js.git"
|
|
12
|
+
},
|
|
13
|
+
"author": {
|
|
14
|
+
"name": "Folklore",
|
|
15
|
+
"email": "info@folklore.email"
|
|
16
|
+
},
|
|
17
|
+
"contributors": [
|
|
18
|
+
{
|
|
19
|
+
"name": "David Mongeau-Petitpas",
|
|
20
|
+
"email": "dmp@folklore.email"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "Nicolas Roy-Bourdages",
|
|
24
|
+
"email": "nrb@folklore.email"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "Joseph Blais",
|
|
28
|
+
"email": "joseph@folklore.email"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"license": "ISC",
|
|
32
|
+
"main": "lib/index.js",
|
|
33
|
+
"module": "es/index.js",
|
|
34
|
+
"files": [
|
|
35
|
+
"lib",
|
|
36
|
+
"es",
|
|
37
|
+
"assets"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"prepare": "../../scripts/prepare-package.sh"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"react": "^16.8.0 || ^17.0.0",
|
|
44
|
+
"react-dom": "^16.8.0 || ^17.0.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"react": "^16.8.0 || ^17.0.0",
|
|
48
|
+
"react-dom": "^16.8.0 || ^17.0.0"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@babel/runtime": "^7.13.10",
|
|
52
|
+
"@folklore/size": "^0.1.15",
|
|
53
|
+
"@micromag/core": "^0.3.57",
|
|
54
|
+
"@micromag/element-background": "^0.3.57",
|
|
55
|
+
"@micromag/element-call-to-action": "^0.3.57",
|
|
56
|
+
"@micromag/element-closed-captions": "^0.3.57",
|
|
57
|
+
"@micromag/element-container": "^0.3.57",
|
|
58
|
+
"@micromag/element-heading": "^0.3.57",
|
|
59
|
+
"@micromag/element-image": "^0.3.57",
|
|
60
|
+
"@micromag/element-media-controls": "^0.3.57",
|
|
61
|
+
"@micromag/element-video": "^0.3.57",
|
|
62
|
+
"@micromag/transforms": "^0.3.57",
|
|
63
|
+
"classnames": "^2.2.6",
|
|
64
|
+
"lodash": "^4.17.21",
|
|
65
|
+
"prop-types": "^15.7.2",
|
|
66
|
+
"react-intl": "^5.12.1",
|
|
67
|
+
"uuid": "^8.3.2"
|
|
68
|
+
},
|
|
69
|
+
"publishConfig": {
|
|
70
|
+
"access": "public"
|
|
71
|
+
},
|
|
72
|
+
"gitHead": "0cd1abafd1bee77d9dccbedde58f7b83f2351794"
|
|
73
|
+
}
|