@micromag/screen-urbania-trivia 0.4.70 → 0.4.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/index.d.ts +3 -2
- package/es/index.js +175 -216
- package/package.json +16 -15
package/es/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { ForwardedRef } from 'react';
|
|
3
|
+
import { HeadingElement, VideoElement, BackgroundElement, MediaElement } from '@micromag/core';
|
|
3
4
|
|
|
4
5
|
interface UrbaniaTriviaProps {
|
|
5
6
|
layout?: 'middle' | 'full';
|
|
@@ -11,7 +12,7 @@ interface UrbaniaTriviaProps {
|
|
|
11
12
|
preload?: boolean;
|
|
12
13
|
spacing?: number;
|
|
13
14
|
padding?: number;
|
|
14
|
-
mediaRef?:
|
|
15
|
+
mediaRef?: ForwardedRef<MediaElement> | null;
|
|
15
16
|
className?: string | null;
|
|
16
17
|
}
|
|
17
18
|
declare function UrbaniaTrivia({ layout, title, video, gotoNextScreenOnEnd, background, current, preload, spacing, padding, mediaRef: customMediaRef, className, }: UrbaniaTriviaProps): react_jsx_runtime.JSX.Element;
|
package/es/index.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
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
2
|
import { getSizeWithinBounds } from '@folklore/size';
|
|
6
3
|
import classNames from 'classnames';
|
|
7
4
|
import isArray from 'lodash/isArray';
|
|
8
5
|
import { useEffect, useState, useCallback, useMemo } from 'react';
|
|
9
6
|
import { ScreenElement, Empty, PlaceholderTitle, PlaceholderVideo } from '@micromag/core/components';
|
|
10
|
-
import { useScreenSize, useScreenRenderContext, useViewerContext, useViewerNavigation, usePlaybackContext, usePlaybackMediaRef,
|
|
11
|
-
import { useTrackScreenMedia,
|
|
7
|
+
import { useScreenSize, useScreenRenderContext, useViewerContext, useViewerNavigation, usePlaybackContext, usePlaybackMediaRef, useViewerActivityDetected } from '@micromag/core/contexts';
|
|
8
|
+
import { useTrackScreenMedia, useDimensionObserver } from '@micromag/core/hooks';
|
|
12
9
|
import { isTextFilled } from '@micromag/core/utils';
|
|
13
10
|
import Background from '@micromag/element-background';
|
|
14
11
|
import ClosedCaptions from '@micromag/element-closed-captions';
|
|
@@ -18,13 +15,13 @@ import Image from '@micromag/element-image';
|
|
|
18
15
|
import Video from '@micromag/element-video';
|
|
19
16
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
20
17
|
|
|
18
|
+
var styles = {"container":"micromag-screen-urbania-trivia-container","background":"micromag-screen-urbania-trivia-background","content":"micromag-screen-urbania-trivia-content","emptyContainer":"micromag-screen-urbania-trivia-emptyContainer","empty":"micromag-screen-urbania-trivia-empty","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","heading":"micromag-screen-urbania-trivia-heading","placeholder":"micromag-screen-urbania-trivia-placeholder","videoPlaceholder":"micromag-screen-urbania-trivia-videoPlaceholder","bottomContent":"micromag-screen-urbania-trivia-bottomContent","fullscreen":"micromag-screen-urbania-trivia-fullscreen","image":"micromag-screen-urbania-trivia-image"};
|
|
19
|
+
|
|
21
20
|
var AnimeLinesGrey = "data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201083.95%201920%22%3E%20%20%20%20%3Cg%20id%3D%22a%22%2F%3E%20%20%20%20%3Cg%20id%3D%22b%22%3E%20%20%20%20%20%20%20%20%3Cg%20id%3D%22c%22%3E%20%20%20%20%20%20%20%20%20%20%20%20%3Cpath%20d%3D%22M1083.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%22%20fill%3D%22hsla%280%2C0%25%2C100%25%2C.6%29%22%2F%3E%20%20%20%20%20%20%20%20%3C%2Fg%3E%20%20%20%20%3C%2Fg%3E%3C%2Fsvg%3E";
|
|
22
21
|
|
|
23
22
|
var AnimeLines = "data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201083.95%201920%22%3E%20%20%20%20%3Cg%20id%3D%22a%22%2F%3E%20%20%20%20%3Cg%20id%3D%22b%22%3E%20%20%20%20%20%20%20%20%3Cg%20id%3D%22c%22%3E%20%20%20%20%20%20%20%20%20%20%20%20%3Cpath%20d%3D%22M1083.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%22%20fill%3D%22%2312bbd7%22%2F%3E%20%20%20%20%20%20%20%20%3C%2Fg%3E%20%20%20%20%3C%2Fg%3E%3C%2Fsvg%3E";
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var defaultBackground = {
|
|
24
|
+
const defaultBackground = {
|
|
28
25
|
image: {
|
|
29
26
|
type: 'image',
|
|
30
27
|
url: AnimeLines,
|
|
@@ -33,7 +30,7 @@ var defaultBackground = {
|
|
|
33
30
|
},
|
|
34
31
|
color: '#00cbff'
|
|
35
32
|
};
|
|
36
|
-
|
|
33
|
+
const placeholderBackground = {
|
|
37
34
|
image: {
|
|
38
35
|
type: 'image',
|
|
39
36
|
url: AnimeLinesGrey,
|
|
@@ -42,83 +39,72 @@ var placeholderBackground = {
|
|
|
42
39
|
},
|
|
43
40
|
color: null
|
|
44
41
|
};
|
|
45
|
-
function UrbaniaTrivia(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
var _useViewerNavigation = useViewerNavigation(),
|
|
83
|
-
gotoNextScreen = _useViewerNavigation.gotoNextScreen;
|
|
84
|
-
var hasTitle = isTextFilled(title);
|
|
85
|
-
var backgroundPlaying = current && (isView || isEdit);
|
|
86
|
-
var mediaShouldLoad = current || preload;
|
|
87
|
-
var shouldGotoNextScreenOnEnd = gotoNextScreenOnEnd && isView && current;
|
|
42
|
+
function UrbaniaTrivia({
|
|
43
|
+
layout = 'full',
|
|
44
|
+
title = null,
|
|
45
|
+
video = null,
|
|
46
|
+
gotoNextScreenOnEnd = false,
|
|
47
|
+
background = null,
|
|
48
|
+
current = true,
|
|
49
|
+
preload = true,
|
|
50
|
+
spacing = 20,
|
|
51
|
+
padding = 20,
|
|
52
|
+
mediaRef: customMediaRef = null,
|
|
53
|
+
className = null
|
|
54
|
+
}) {
|
|
55
|
+
const trackScreenMedia = useTrackScreenMedia('video');
|
|
56
|
+
const {
|
|
57
|
+
width,
|
|
58
|
+
height,
|
|
59
|
+
resolution
|
|
60
|
+
} = useScreenSize();
|
|
61
|
+
const {
|
|
62
|
+
isView,
|
|
63
|
+
isPreview,
|
|
64
|
+
isPlaceholder,
|
|
65
|
+
isEdit,
|
|
66
|
+
isStatic,
|
|
67
|
+
isCapture
|
|
68
|
+
} = useScreenRenderContext();
|
|
69
|
+
const {
|
|
70
|
+
bottomHeight: viewerBottomHeight
|
|
71
|
+
} = useViewerContext();
|
|
72
|
+
const {
|
|
73
|
+
gotoNextScreen
|
|
74
|
+
} = useViewerNavigation();
|
|
75
|
+
const hasTitle = isTextFilled(title);
|
|
76
|
+
const backgroundPlaying = current && (isView || isEdit);
|
|
77
|
+
const mediaShouldLoad = current || preload;
|
|
78
|
+
const shouldGotoNextScreenOnEnd = gotoNextScreenOnEnd && isView && current;
|
|
88
79
|
|
|
89
80
|
// get resized video style props
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
var _usePlaybackMediaRef = usePlaybackMediaRef(current),
|
|
116
|
-
mediaRef = _usePlaybackMediaRef.ref,
|
|
117
|
-
_usePlaybackMediaRef$ = _usePlaybackMediaRef.isCurrent,
|
|
118
|
-
isCurrentMedia = _usePlaybackMediaRef$ === void 0 ? false : _usePlaybackMediaRef$;
|
|
119
|
-
useEffect(function () {
|
|
81
|
+
const {
|
|
82
|
+
autoPlay = true,
|
|
83
|
+
media: videoMedia = null,
|
|
84
|
+
closedCaptions = null,
|
|
85
|
+
withSeekBar = false,
|
|
86
|
+
withControls = false,
|
|
87
|
+
color = null,
|
|
88
|
+
progressColor = null
|
|
89
|
+
} = video || {};
|
|
90
|
+
const {
|
|
91
|
+
playing,
|
|
92
|
+
muted,
|
|
93
|
+
setControls,
|
|
94
|
+
setControlsTheme,
|
|
95
|
+
setPlaying,
|
|
96
|
+
showControls,
|
|
97
|
+
hideControls,
|
|
98
|
+
currentQualityLevel,
|
|
99
|
+
setCurrentQualityLevel
|
|
100
|
+
} = usePlaybackContext();
|
|
101
|
+
const {
|
|
102
|
+
ref: mediaRef,
|
|
103
|
+
isCurrent: isCurrentMedia = false
|
|
104
|
+
} = usePlaybackMediaRef(current);
|
|
105
|
+
useEffect(() => {
|
|
120
106
|
if (!current) {
|
|
121
|
-
return
|
|
107
|
+
return () => {};
|
|
122
108
|
}
|
|
123
109
|
if (withControls || withSeekBar) {
|
|
124
110
|
setControls(true);
|
|
@@ -128,55 +114,51 @@ function UrbaniaTrivia(_ref) {
|
|
|
128
114
|
} else {
|
|
129
115
|
setControls(false);
|
|
130
116
|
}
|
|
131
|
-
return
|
|
117
|
+
return () => {
|
|
132
118
|
if (withControls || withSeekBar) {
|
|
133
119
|
setControls(false);
|
|
134
120
|
}
|
|
135
121
|
};
|
|
136
122
|
}, [current, withControls, setControls, withSeekBar, color, progressColor]);
|
|
137
|
-
useEffect(
|
|
123
|
+
useEffect(() => {
|
|
138
124
|
if (customMediaRef !== null) {
|
|
139
125
|
customMediaRef(mediaRef.current);
|
|
140
126
|
}
|
|
141
127
|
}, [mediaRef.current]);
|
|
142
128
|
|
|
143
129
|
// Get api state updates from callback
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
setCurrentTime = _useState2[1];
|
|
148
|
-
var _useState3 = useState(null),
|
|
149
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
150
|
-
duration = _useState4[0],
|
|
151
|
-
setDuration = _useState4[1];
|
|
152
|
-
useEffect(function () {
|
|
130
|
+
const [currentTime, setCurrentTime] = useState(null);
|
|
131
|
+
const [duration, setDuration] = useState(null);
|
|
132
|
+
useEffect(() => {
|
|
153
133
|
if (current && autoPlay && !playing) {
|
|
154
134
|
setPlaying(true);
|
|
155
135
|
}
|
|
156
136
|
}, [current, autoPlay]);
|
|
157
|
-
|
|
137
|
+
const onTimeUpdate = useCallback(time => {
|
|
158
138
|
setCurrentTime(time);
|
|
159
139
|
}, [setDuration, duration]);
|
|
160
|
-
|
|
161
|
-
trackScreenMedia(videoMedia,
|
|
140
|
+
const onProgressStep = useCallback((step, meta) => {
|
|
141
|
+
trackScreenMedia(videoMedia, `progress_${Math.round(step * 100, 10)}%`, meta);
|
|
162
142
|
}, [trackScreenMedia, videoMedia]);
|
|
163
|
-
|
|
143
|
+
const onDurationChange = useCallback(dur => {
|
|
164
144
|
setDuration(dur);
|
|
165
145
|
}, [setDuration]);
|
|
166
|
-
|
|
167
|
-
|
|
146
|
+
const onPlay = useCallback(({
|
|
147
|
+
initial
|
|
148
|
+
}) => {
|
|
168
149
|
trackScreenMedia(videoMedia, initial ? 'play' : 'resume');
|
|
169
150
|
}, [trackScreenMedia, videoMedia]);
|
|
170
|
-
|
|
171
|
-
|
|
151
|
+
const onPause = useCallback(({
|
|
152
|
+
midway
|
|
153
|
+
}) => {
|
|
172
154
|
trackScreenMedia(videoMedia, midway ? 'pause' : 'ended');
|
|
173
155
|
}, [trackScreenMedia, videoMedia]);
|
|
174
|
-
|
|
175
|
-
if (
|
|
156
|
+
const onSeeked = useCallback(time_0 => {
|
|
157
|
+
if (time_0 > 0) {
|
|
176
158
|
trackScreenMedia(videoMedia, 'seek');
|
|
177
159
|
}
|
|
178
160
|
}, [trackScreenMedia, videoMedia]);
|
|
179
|
-
|
|
161
|
+
const onEnded = useCallback(() => {
|
|
180
162
|
if (current && shouldGotoNextScreenOnEnd) {
|
|
181
163
|
gotoNextScreen();
|
|
182
164
|
}
|
|
@@ -184,14 +166,8 @@ function UrbaniaTrivia(_ref) {
|
|
|
184
166
|
setPlaying(false);
|
|
185
167
|
}
|
|
186
168
|
}, [current, shouldGotoNextScreenOnEnd, gotoNextScreen, setPlaying]);
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
element: viewerContainer,
|
|
190
|
-
disabled: !current || !isView,
|
|
191
|
-
timeout: 2000
|
|
192
|
-
}),
|
|
193
|
-
activityDetected = _useActivityDetector.detected;
|
|
194
|
-
useEffect(function () {
|
|
169
|
+
const activityDetected = useViewerActivityDetected();
|
|
170
|
+
useEffect(() => {
|
|
195
171
|
if (!current) {
|
|
196
172
|
return;
|
|
197
173
|
}
|
|
@@ -201,83 +177,82 @@ function UrbaniaTrivia(_ref) {
|
|
|
201
177
|
hideControls();
|
|
202
178
|
}
|
|
203
179
|
}, [activityDetected, showControls, hideControls]);
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
var videoMaxHeight = height - titleHeight - (padding ? padding * 2 : 40);
|
|
240
|
-
var _getSizeWithinBounds = getSizeWithinBounds(videoWidth, videoHeight, width, videoMaxHeight, {
|
|
241
|
-
cover: fullscreen
|
|
242
|
-
}),
|
|
243
|
-
resizedVideoWidth = _getSizeWithinBounds.width,
|
|
244
|
-
resizedVideoHeight = _getSizeWithinBounds.height;
|
|
245
|
-
var resizedVideoLeft = -(resizedVideoWidth - width) / 2;
|
|
180
|
+
const fullscreen = layout === 'full';
|
|
181
|
+
const {
|
|
182
|
+
image: backgroundImage = null,
|
|
183
|
+
video: backgroundVideo = null
|
|
184
|
+
} = background || {};
|
|
185
|
+
const isCustomBackground = background === null || backgroundImage === null && backgroundVideo === null;
|
|
186
|
+
const isAnimatedBackground = !isStatic && !isPreview && isCustomBackground;
|
|
187
|
+
const hasVideo = video !== null;
|
|
188
|
+
const [ready, setReady] = useState(hasVideo);
|
|
189
|
+
const finalVideo = useMemo(() => hasVideo ? {
|
|
190
|
+
...video,
|
|
191
|
+
autoPlay: !isPreview && !isStatic && !isCapture && autoPlay && current
|
|
192
|
+
} : null, [hasVideo, video, isPreview, isStatic, isCapture, autoPlay, current]);
|
|
193
|
+
const {
|
|
194
|
+
metadata: videoMetadata = null,
|
|
195
|
+
url: videoUrl = null,
|
|
196
|
+
thumbnail_url: thumbnailUrl = null
|
|
197
|
+
} = videoMedia || {};
|
|
198
|
+
const hasVideoUrl = videoUrl !== null;
|
|
199
|
+
const {
|
|
200
|
+
width: videoWidth = 0,
|
|
201
|
+
height: videoHeight = 0
|
|
202
|
+
} = videoMetadata || {};
|
|
203
|
+
const {
|
|
204
|
+
ref: titleRef,
|
|
205
|
+
height: titleHeight = 0
|
|
206
|
+
} = useDimensionObserver();
|
|
207
|
+
const videoMaxHeight = height - titleHeight - (padding ? padding * 2 : 40);
|
|
208
|
+
const {
|
|
209
|
+
width: resizedVideoWidth,
|
|
210
|
+
height: resizedVideoHeight
|
|
211
|
+
} = getSizeWithinBounds(videoWidth, videoHeight, width, videoMaxHeight, {
|
|
212
|
+
cover: fullscreen
|
|
213
|
+
});
|
|
214
|
+
const resizedVideoLeft = -(resizedVideoWidth - width) / 2;
|
|
246
215
|
// const resizedVideoTop = -(resizedVideoHeight - videoMaxHeight) / 2;
|
|
247
216
|
|
|
248
|
-
|
|
249
|
-
|
|
217
|
+
const verticalVideo = resizedVideoHeight > resizedVideoWidth;
|
|
218
|
+
const finalBackground = useMemo(() => {
|
|
250
219
|
if (isArray(background) && background.length > 0) {
|
|
251
220
|
return background;
|
|
252
221
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
_ref8$color = _ref8.color,
|
|
259
|
-
bgColor = _ref8$color === void 0 ? null : _ref8$color;
|
|
222
|
+
const {
|
|
223
|
+
image: bgImage = null,
|
|
224
|
+
video: bgVideo = null,
|
|
225
|
+
color: bgColor = null
|
|
226
|
+
} = background || {};
|
|
260
227
|
if (bgImage !== null || bgVideo !== null) {
|
|
261
|
-
return
|
|
228
|
+
return {
|
|
229
|
+
...defaultBackground,
|
|
230
|
+
...background
|
|
231
|
+
};
|
|
262
232
|
}
|
|
263
|
-
return
|
|
264
|
-
|
|
265
|
-
|
|
233
|
+
return {
|
|
234
|
+
...defaultBackground,
|
|
235
|
+
...(bgColor !== null ? {
|
|
236
|
+
color: bgColor
|
|
237
|
+
} : null)
|
|
238
|
+
};
|
|
266
239
|
}, [background]);
|
|
267
|
-
|
|
240
|
+
const placeholderProps = fullscreen ? {
|
|
268
241
|
width: '100%',
|
|
269
242
|
height: '100%'
|
|
270
243
|
} : {
|
|
271
244
|
width: '100%'
|
|
272
245
|
};
|
|
273
|
-
useEffect(
|
|
246
|
+
useEffect(() => {
|
|
274
247
|
setReady(!hasVideoUrl);
|
|
275
248
|
}, [videoUrl, hasVideoUrl, setReady]);
|
|
276
|
-
|
|
249
|
+
const onVideoReady = useCallback(() => {
|
|
277
250
|
setReady(true);
|
|
278
251
|
}, [setReady]);
|
|
279
252
|
return /*#__PURE__*/jsxs("div", {
|
|
280
|
-
className: classNames([styles.container, className,
|
|
253
|
+
className: classNames([styles.container, className, {
|
|
254
|
+
[styles.fullscreen]: fullscreen
|
|
255
|
+
}]),
|
|
281
256
|
"data-screen-ready": isStatic || isCapture || ready,
|
|
282
257
|
children: [/*#__PURE__*/jsx(Container, {
|
|
283
258
|
width: width,
|
|
@@ -296,45 +271,43 @@ function UrbaniaTrivia(_ref) {
|
|
|
296
271
|
},
|
|
297
272
|
children: [/*#__PURE__*/jsx(ScreenElement, {
|
|
298
273
|
className: styles.headingScreenElement,
|
|
299
|
-
placeholder: /*#__PURE__*/jsx(PlaceholderTitle,
|
|
300
|
-
className: styles.placeholder
|
|
301
|
-
|
|
274
|
+
placeholder: /*#__PURE__*/jsx(PlaceholderTitle, {
|
|
275
|
+
className: styles.placeholder,
|
|
276
|
+
...placeholderProps
|
|
277
|
+
}),
|
|
302
278
|
empty: /*#__PURE__*/jsx("div", {
|
|
303
279
|
className: styles.emptyContainer,
|
|
304
280
|
children: /*#__PURE__*/jsx(Empty, {
|
|
305
281
|
className: styles.empty,
|
|
306
282
|
children: /*#__PURE__*/jsx(FormattedMessage, {
|
|
307
283
|
id: "oAtOlP",
|
|
308
|
-
defaultMessage:
|
|
309
|
-
"type": 0,
|
|
310
|
-
"value": "Heading"
|
|
311
|
-
}]
|
|
284
|
+
defaultMessage: "Heading"
|
|
312
285
|
})
|
|
313
286
|
})
|
|
314
287
|
}),
|
|
315
288
|
isEmpty: !hasTitle,
|
|
316
289
|
children: hasTitle ? /*#__PURE__*/jsx("div", {
|
|
317
290
|
ref: titleRef,
|
|
318
|
-
children: /*#__PURE__*/jsx(Heading,
|
|
291
|
+
children: /*#__PURE__*/jsx(Heading, {
|
|
319
292
|
className: styles.heading
|
|
320
293
|
// body={body}
|
|
321
|
-
|
|
294
|
+
,
|
|
295
|
+
...title
|
|
296
|
+
})
|
|
322
297
|
}) : null
|
|
323
298
|
}, "heading"), /*#__PURE__*/jsx(ScreenElement, {
|
|
324
299
|
className: styles.videoScreenElement,
|
|
325
|
-
placeholder: /*#__PURE__*/jsx(PlaceholderVideo,
|
|
326
|
-
className: styles.videoPlaceholder
|
|
327
|
-
|
|
300
|
+
placeholder: /*#__PURE__*/jsx(PlaceholderVideo, {
|
|
301
|
+
className: styles.videoPlaceholder,
|
|
302
|
+
...placeholderProps
|
|
303
|
+
}),
|
|
328
304
|
empty: /*#__PURE__*/jsx("div", {
|
|
329
305
|
className: styles.emptyContainer,
|
|
330
306
|
children: /*#__PURE__*/jsx(Empty, {
|
|
331
307
|
className: styles.empty,
|
|
332
308
|
children: /*#__PURE__*/jsx(FormattedMessage, {
|
|
333
309
|
id: "3ext9Q",
|
|
334
|
-
defaultMessage:
|
|
335
|
-
"type": 0,
|
|
336
|
-
"value": "Video"
|
|
337
|
-
}]
|
|
310
|
+
defaultMessage: "Video"
|
|
338
311
|
})
|
|
339
312
|
})
|
|
340
313
|
}),
|
|
@@ -359,7 +332,8 @@ function UrbaniaTrivia(_ref) {
|
|
|
359
332
|
width: Math.min(width, resizedVideoWidth),
|
|
360
333
|
height: resizedVideoHeight,
|
|
361
334
|
resolution: resolution
|
|
362
|
-
}) : /*#__PURE__*/jsx(Video,
|
|
335
|
+
}) : /*#__PURE__*/jsx(Video, {
|
|
336
|
+
...finalVideo,
|
|
363
337
|
mediaRef: mediaRef,
|
|
364
338
|
paused: !current || !playing || !isCurrentMedia && isView,
|
|
365
339
|
muted: muted,
|
|
@@ -378,10 +352,10 @@ function UrbaniaTrivia(_ref) {
|
|
|
378
352
|
shouldLoad: mediaShouldLoad,
|
|
379
353
|
qualityStartLevel: currentQualityLevel,
|
|
380
354
|
onQualityLevelChange: setCurrentQualityLevel
|
|
381
|
-
})
|
|
355
|
+
}), current && !isPlaceholder ? /*#__PURE__*/jsx("div", {
|
|
382
356
|
className: styles.bottomContent,
|
|
383
357
|
style: {
|
|
384
|
-
transform:
|
|
358
|
+
transform: `translate(0, -${viewerBottomHeight}px)`
|
|
385
359
|
},
|
|
386
360
|
children: closedCaptions !== null && !isPreview && !isCapture && !isStatic ? /*#__PURE__*/jsx(ClosedCaptions, {
|
|
387
361
|
className: styles.closedCaptions,
|
|
@@ -395,7 +369,10 @@ function UrbaniaTrivia(_ref) {
|
|
|
395
369
|
})
|
|
396
370
|
}), !isPlaceholder ? /*#__PURE__*/jsx(Background, {
|
|
397
371
|
background: finalBackground,
|
|
398
|
-
className: classNames([styles.background, className,
|
|
372
|
+
className: classNames([styles.background, className, {
|
|
373
|
+
[styles.isCustomBackground]: isCustomBackground,
|
|
374
|
+
[styles.isAnimated]: isAnimatedBackground
|
|
375
|
+
}]),
|
|
399
376
|
width: width,
|
|
400
377
|
height: height,
|
|
401
378
|
resolution: resolution,
|
|
@@ -420,19 +397,13 @@ var definition = {
|
|
|
420
397
|
group: {
|
|
421
398
|
label: defineMessage({
|
|
422
399
|
id: "oPjl8f",
|
|
423
|
-
defaultMessage:
|
|
424
|
-
"type": 0,
|
|
425
|
-
"value": "Urbania"
|
|
426
|
-
}]
|
|
400
|
+
defaultMessage: "Urbania"
|
|
427
401
|
}),
|
|
428
402
|
order: 10
|
|
429
403
|
},
|
|
430
404
|
title: defineMessage({
|
|
431
405
|
id: "zDdDqI",
|
|
432
|
-
defaultMessage:
|
|
433
|
-
"type": 0,
|
|
434
|
-
"value": "Urbania trivia"
|
|
435
|
-
}]
|
|
406
|
+
defaultMessage: "Urbania trivia"
|
|
436
407
|
}),
|
|
437
408
|
component: UrbaniaTrivia,
|
|
438
409
|
fields: [{
|
|
@@ -440,10 +411,7 @@ var definition = {
|
|
|
440
411
|
type: 'heading-element',
|
|
441
412
|
label: defineMessage({
|
|
442
413
|
id: "N25iDO",
|
|
443
|
-
defaultMessage:
|
|
444
|
-
"type": 0,
|
|
445
|
-
"value": "Title"
|
|
446
|
-
}]
|
|
414
|
+
defaultMessage: "Title"
|
|
447
415
|
})
|
|
448
416
|
}, {
|
|
449
417
|
name: 'video',
|
|
@@ -453,10 +421,7 @@ var definition = {
|
|
|
453
421
|
},
|
|
454
422
|
label: defineMessage({
|
|
455
423
|
id: "tvl2Zc",
|
|
456
|
-
defaultMessage:
|
|
457
|
-
"type": 0,
|
|
458
|
-
"value": "Video"
|
|
459
|
-
}]
|
|
424
|
+
defaultMessage: "Video"
|
|
460
425
|
})
|
|
461
426
|
}, {
|
|
462
427
|
name: 'gotoNextScreenOnEnd',
|
|
@@ -464,20 +429,14 @@ var definition = {
|
|
|
464
429
|
defaultValue: false,
|
|
465
430
|
label: defineMessage({
|
|
466
431
|
id: "n8zmLY",
|
|
467
|
-
defaultMessage:
|
|
468
|
-
"type": 0,
|
|
469
|
-
"value": "Go to next screen on end"
|
|
470
|
-
}]
|
|
432
|
+
defaultMessage: "Go to next screen on end"
|
|
471
433
|
})
|
|
472
434
|
}, {
|
|
473
435
|
name: 'background',
|
|
474
436
|
type: 'background',
|
|
475
437
|
label: defineMessage({
|
|
476
438
|
id: "+MPZRu",
|
|
477
|
-
defaultMessage:
|
|
478
|
-
"type": 0,
|
|
479
|
-
"value": "Background"
|
|
480
|
-
}]
|
|
439
|
+
defaultMessage: "Background"
|
|
481
440
|
})
|
|
482
441
|
}]
|
|
483
442
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/screen-urbania-trivia",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.74",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"exports": {
|
|
37
37
|
".": {
|
|
38
38
|
"types": "./es/index.d.ts",
|
|
39
|
+
"style": "./assets/css/styles.css",
|
|
39
40
|
"import": "./es/index.js"
|
|
40
41
|
},
|
|
41
42
|
"./assets/css/styles": "./assets/css/styles.css",
|
|
@@ -53,25 +54,25 @@
|
|
|
53
54
|
"build": "../../scripts/prepare-package.sh --types"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
|
-
"react": "^
|
|
57
|
-
"react-dom": "^
|
|
57
|
+
"react": "^19.0.0",
|
|
58
|
+
"react-dom": "^19.0.0"
|
|
58
59
|
},
|
|
59
60
|
"peerDependencies": {
|
|
60
|
-
"react": "^
|
|
61
|
-
"react-dom": "^
|
|
61
|
+
"react": "^19.0.0",
|
|
62
|
+
"react-dom": "^19.0.0"
|
|
62
63
|
},
|
|
63
64
|
"dependencies": {
|
|
64
65
|
"@babel/runtime": "^7.28.6",
|
|
65
66
|
"@folklore/size": "^0.1.20",
|
|
66
|
-
"@micromag/core": "^0.4.
|
|
67
|
-
"@micromag/element-background": "^0.4.
|
|
68
|
-
"@micromag/element-call-to-action": "^0.4.
|
|
69
|
-
"@micromag/element-closed-captions": "^0.4.
|
|
70
|
-
"@micromag/element-container": "^0.4.
|
|
71
|
-
"@micromag/element-heading": "^0.4.
|
|
72
|
-
"@micromag/element-image": "^0.4.
|
|
73
|
-
"@micromag/element-video": "^0.4.
|
|
74
|
-
"@micromag/transforms": "^0.4.
|
|
67
|
+
"@micromag/core": "^0.4.74",
|
|
68
|
+
"@micromag/element-background": "^0.4.74",
|
|
69
|
+
"@micromag/element-call-to-action": "^0.4.74",
|
|
70
|
+
"@micromag/element-closed-captions": "^0.4.74",
|
|
71
|
+
"@micromag/element-container": "^0.4.74",
|
|
72
|
+
"@micromag/element-heading": "^0.4.74",
|
|
73
|
+
"@micromag/element-image": "^0.4.74",
|
|
74
|
+
"@micromag/element-video": "^0.4.74",
|
|
75
|
+
"@micromag/transforms": "^0.4.74",
|
|
75
76
|
"classnames": "^2.2.6",
|
|
76
77
|
"lodash": "^4.17.23",
|
|
77
78
|
"react-intl": "^8.1.3 || ^10.0.0",
|
|
@@ -81,6 +82,6 @@
|
|
|
81
82
|
"access": "public",
|
|
82
83
|
"registry": "https://registry.npmjs.org/"
|
|
83
84
|
},
|
|
84
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "fe510ee87845280d0760cb292aef9d2eb69e67c1",
|
|
85
86
|
"types": "es/index.d.ts"
|
|
86
87
|
}
|