@micromag/screen-timeline 0.3.123 → 0.3.124
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.js +25 -14
- package/lib/index.js +24 -13
- package/package.json +12 -12
package/es/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
|
5
5
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
import React, { useState, useCallback, useRef, useEffect } from 'react';
|
|
8
|
+
import React, { useMemo, useState, useCallback, useRef, useEffect } from 'react';
|
|
9
9
|
import { PropTypes as PropTypes$1 } from '@micromag/core';
|
|
10
10
|
import { Transitions, ScreenElement } from '@micromag/core/components';
|
|
11
11
|
import { useScreenSize, useViewer, useScreenRenderContext } from '@micromag/core/contexts';
|
|
@@ -66,7 +66,7 @@ var defaultProps = {
|
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
var Timeline = function Timeline(_ref) {
|
|
69
|
-
var
|
|
69
|
+
var _ref10;
|
|
70
70
|
|
|
71
71
|
var layout = _ref.layout,
|
|
72
72
|
items = _ref.items,
|
|
@@ -105,9 +105,11 @@ var Timeline = function Timeline(_ref) {
|
|
|
105
105
|
isStatic = _useScreenRenderConte.isStatic,
|
|
106
106
|
isCapture = _useScreenRenderConte.isCapture;
|
|
107
107
|
|
|
108
|
-
var finalItems =
|
|
109
|
-
return {
|
|
110
|
-
|
|
108
|
+
var finalItems = useMemo(function () {
|
|
109
|
+
return isPlaceholder ? _toConsumableArray(new Array(5)).map(function () {
|
|
110
|
+
return {};
|
|
111
|
+
}) : items || [null];
|
|
112
|
+
}, [isPlaceholder, items]);
|
|
111
113
|
var itemsCount = finalItems !== null ? finalItems.length : 0;
|
|
112
114
|
var hasItems = finalItems !== null && itemsCount;
|
|
113
115
|
var imagesCount = hasItems ? finalItems.reduce(function (acc, curr) {
|
|
@@ -130,8 +132,10 @@ var Timeline = function Timeline(_ref) {
|
|
|
130
132
|
var backgroundPlaying = current && (isView || isEdit);
|
|
131
133
|
var mediaShouldLoad = current || active;
|
|
132
134
|
var onImageLoaded = useCallback(function () {
|
|
133
|
-
setImagesLoaded(
|
|
134
|
-
|
|
135
|
+
setImagesLoaded(function (count) {
|
|
136
|
+
return count + 1;
|
|
137
|
+
});
|
|
138
|
+
}, [setImagesLoaded]);
|
|
135
139
|
var firstLineRef = useRef(null);
|
|
136
140
|
var firstContentRef = useRef(null);
|
|
137
141
|
|
|
@@ -164,6 +168,10 @@ var Timeline = function Timeline(_ref) {
|
|
|
164
168
|
}
|
|
165
169
|
|
|
166
170
|
var typesCount = elementsTypes.length;
|
|
171
|
+
|
|
172
|
+
var _ref4 = description || {},
|
|
173
|
+
descriptionTextStyle = _ref4.textStyle;
|
|
174
|
+
|
|
167
175
|
return /*#__PURE__*/React.createElement("div", {
|
|
168
176
|
className: styles.item,
|
|
169
177
|
key: "item-".concat(itemI)
|
|
@@ -217,6 +225,7 @@ var Timeline = function Timeline(_ref) {
|
|
|
217
225
|
width: imageWidth,
|
|
218
226
|
resolution: resolution,
|
|
219
227
|
playing: backgroundPlaying,
|
|
228
|
+
active: active,
|
|
220
229
|
shouldLoad: mediaShouldLoad,
|
|
221
230
|
onLoaded: onImageLoaded
|
|
222
231
|
}) : null));
|
|
@@ -238,7 +247,9 @@ var Timeline = function Timeline(_ref) {
|
|
|
238
247
|
}),
|
|
239
248
|
emptyClassName: styles.empty,
|
|
240
249
|
isEmpty: !hasDescription
|
|
241
|
-
}, hasElement ? /*#__PURE__*/React.createElement(Text, description
|
|
250
|
+
}, hasElement ? /*#__PURE__*/React.createElement(Text, Object.assign({}, description, {
|
|
251
|
+
textStyle: getStyleFromColor(descriptionTextStyle)
|
|
252
|
+
})) : null));
|
|
242
253
|
break;
|
|
243
254
|
}
|
|
244
255
|
|
|
@@ -280,12 +291,12 @@ var Timeline = function Timeline(_ref) {
|
|
|
280
291
|
callToActionRef = _useResizeObserver.ref,
|
|
281
292
|
callToActionRect = _useResizeObserver.entry.contentRect;
|
|
282
293
|
|
|
283
|
-
var
|
|
284
|
-
|
|
285
|
-
callToActionHeight =
|
|
294
|
+
var _ref8 = callToActionRect || {},
|
|
295
|
+
_ref8$height = _ref8.height,
|
|
296
|
+
callToActionHeight = _ref8$height === void 0 ? 0 : _ref8$height;
|
|
286
297
|
|
|
287
|
-
var onScrolledBottom = useCallback(function (
|
|
288
|
-
var initial =
|
|
298
|
+
var onScrolledBottom = useCallback(function (_ref9) {
|
|
299
|
+
var initial = _ref9.initial;
|
|
289
300
|
|
|
290
301
|
if (initial) {
|
|
291
302
|
trackScreenEvent('scroll', 'Screen');
|
|
@@ -297,7 +308,7 @@ var Timeline = function Timeline(_ref) {
|
|
|
297
308
|
setScrolledBottom(false);
|
|
298
309
|
}, [setScrolledBottom]);
|
|
299
310
|
return /*#__PURE__*/React.createElement("div", {
|
|
300
|
-
className: classNames([styles.container, (
|
|
311
|
+
className: classNames([styles.container, (_ref10 = {}, _defineProperty(_ref10, className, className !== null), _defineProperty(_ref10, styles.isPlaceholder, isPlaceholder), _defineProperty(_ref10, styles["".concat(bulletShape, "BulletShape")], bulletShape !== null), _defineProperty(_ref10, styles.withoutLines, itemsCount < 2), _ref10)]),
|
|
301
312
|
"data-screen-ready": ready
|
|
302
313
|
}, !isPlaceholder ? /*#__PURE__*/React.createElement(Background, {
|
|
303
314
|
background: background,
|
package/lib/index.js
CHANGED
|
@@ -89,7 +89,7 @@ var defaultProps = {
|
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
var Timeline = function Timeline(_ref) {
|
|
92
|
-
var
|
|
92
|
+
var _ref10;
|
|
93
93
|
|
|
94
94
|
var layout = _ref.layout,
|
|
95
95
|
items = _ref.items,
|
|
@@ -128,9 +128,11 @@ var Timeline = function Timeline(_ref) {
|
|
|
128
128
|
isStatic = _useScreenRenderConte.isStatic,
|
|
129
129
|
isCapture = _useScreenRenderConte.isCapture;
|
|
130
130
|
|
|
131
|
-
var finalItems =
|
|
132
|
-
return {
|
|
133
|
-
|
|
131
|
+
var finalItems = React.useMemo(function () {
|
|
132
|
+
return isPlaceholder ? _toConsumableArray__default["default"](new Array(5)).map(function () {
|
|
133
|
+
return {};
|
|
134
|
+
}) : items || [null];
|
|
135
|
+
}, [isPlaceholder, items]);
|
|
134
136
|
var itemsCount = finalItems !== null ? finalItems.length : 0;
|
|
135
137
|
var hasItems = finalItems !== null && itemsCount;
|
|
136
138
|
var imagesCount = hasItems ? finalItems.reduce(function (acc, curr) {
|
|
@@ -153,8 +155,10 @@ var Timeline = function Timeline(_ref) {
|
|
|
153
155
|
var backgroundPlaying = current && (isView || isEdit);
|
|
154
156
|
var mediaShouldLoad = current || active;
|
|
155
157
|
var onImageLoaded = React.useCallback(function () {
|
|
156
|
-
setImagesLoaded(
|
|
157
|
-
|
|
158
|
+
setImagesLoaded(function (count) {
|
|
159
|
+
return count + 1;
|
|
160
|
+
});
|
|
161
|
+
}, [setImagesLoaded]);
|
|
158
162
|
var firstLineRef = React.useRef(null);
|
|
159
163
|
var firstContentRef = React.useRef(null);
|
|
160
164
|
|
|
@@ -187,6 +191,10 @@ var Timeline = function Timeline(_ref) {
|
|
|
187
191
|
}
|
|
188
192
|
|
|
189
193
|
var typesCount = elementsTypes.length;
|
|
194
|
+
|
|
195
|
+
var _ref4 = description || {},
|
|
196
|
+
descriptionTextStyle = _ref4.textStyle;
|
|
197
|
+
|
|
190
198
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
191
199
|
className: styles.item,
|
|
192
200
|
key: "item-".concat(itemI)
|
|
@@ -240,6 +248,7 @@ var Timeline = function Timeline(_ref) {
|
|
|
240
248
|
width: imageWidth,
|
|
241
249
|
resolution: resolution,
|
|
242
250
|
playing: backgroundPlaying,
|
|
251
|
+
active: active,
|
|
243
252
|
shouldLoad: mediaShouldLoad,
|
|
244
253
|
onLoaded: onImageLoaded
|
|
245
254
|
}) : null));
|
|
@@ -261,7 +270,9 @@ var Timeline = function Timeline(_ref) {
|
|
|
261
270
|
}),
|
|
262
271
|
emptyClassName: styles.empty,
|
|
263
272
|
isEmpty: !hasDescription
|
|
264
|
-
}, hasElement ? /*#__PURE__*/React__default["default"].createElement(Text__default["default"], description
|
|
273
|
+
}, hasElement ? /*#__PURE__*/React__default["default"].createElement(Text__default["default"], Object.assign({}, description, {
|
|
274
|
+
textStyle: utils.getStyleFromColor(descriptionTextStyle)
|
|
275
|
+
})) : null));
|
|
265
276
|
break;
|
|
266
277
|
}
|
|
267
278
|
|
|
@@ -303,12 +314,12 @@ var Timeline = function Timeline(_ref) {
|
|
|
303
314
|
callToActionRef = _useResizeObserver.ref,
|
|
304
315
|
callToActionRect = _useResizeObserver.entry.contentRect;
|
|
305
316
|
|
|
306
|
-
var
|
|
307
|
-
|
|
308
|
-
callToActionHeight =
|
|
317
|
+
var _ref8 = callToActionRect || {},
|
|
318
|
+
_ref8$height = _ref8.height,
|
|
319
|
+
callToActionHeight = _ref8$height === void 0 ? 0 : _ref8$height;
|
|
309
320
|
|
|
310
|
-
var onScrolledBottom = React.useCallback(function (
|
|
311
|
-
var initial =
|
|
321
|
+
var onScrolledBottom = React.useCallback(function (_ref9) {
|
|
322
|
+
var initial = _ref9.initial;
|
|
312
323
|
|
|
313
324
|
if (initial) {
|
|
314
325
|
trackScreenEvent('scroll', 'Screen');
|
|
@@ -320,7 +331,7 @@ var Timeline = function Timeline(_ref) {
|
|
|
320
331
|
setScrolledBottom(false);
|
|
321
332
|
}, [setScrolledBottom]);
|
|
322
333
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
323
|
-
className: classNames__default["default"]([styles.container, (
|
|
334
|
+
className: classNames__default["default"]([styles.container, (_ref10 = {}, _defineProperty__default["default"](_ref10, className, className !== null), _defineProperty__default["default"](_ref10, styles.isPlaceholder, isPlaceholder), _defineProperty__default["default"](_ref10, styles["".concat(bulletShape, "BulletShape")], bulletShape !== null), _defineProperty__default["default"](_ref10, styles.withoutLines, itemsCount < 2), _ref10)]),
|
|
324
335
|
"data-screen-ready": ready
|
|
325
336
|
}, !isPlaceholder ? /*#__PURE__*/React__default["default"].createElement(Background__default["default"], {
|
|
326
337
|
background: background,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/screen-timeline",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.124",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -49,16 +49,16 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@babel/runtime": "^7.13.10",
|
|
52
|
-
"@micromag/core": "^0.3.
|
|
53
|
-
"@micromag/element-background": "^0.3.
|
|
54
|
-
"@micromag/element-call-to-action": "^0.3.
|
|
55
|
-
"@micromag/element-container": "^0.3.
|
|
56
|
-
"@micromag/element-heading": "^0.3.
|
|
57
|
-
"@micromag/element-layout": "^0.3.
|
|
58
|
-
"@micromag/element-scroll": "^0.3.
|
|
59
|
-
"@micromag/element-text": "^0.3.
|
|
60
|
-
"@micromag/element-visual": "^0.3.
|
|
61
|
-
"@micromag/transforms": "^0.3.
|
|
52
|
+
"@micromag/core": "^0.3.124",
|
|
53
|
+
"@micromag/element-background": "^0.3.124",
|
|
54
|
+
"@micromag/element-call-to-action": "^0.3.124",
|
|
55
|
+
"@micromag/element-container": "^0.3.124",
|
|
56
|
+
"@micromag/element-heading": "^0.3.124",
|
|
57
|
+
"@micromag/element-layout": "^0.3.124",
|
|
58
|
+
"@micromag/element-scroll": "^0.3.124",
|
|
59
|
+
"@micromag/element-text": "^0.3.124",
|
|
60
|
+
"@micromag/element-visual": "^0.3.124",
|
|
61
|
+
"@micromag/transforms": "^0.3.124",
|
|
62
62
|
"classnames": "^2.2.6",
|
|
63
63
|
"lodash": "^4.17.21",
|
|
64
64
|
"prop-types": "^15.7.2",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"publishConfig": {
|
|
69
69
|
"access": "public"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "9050944df1d66cae14e04a771f739e2743894fb8"
|
|
72
72
|
}
|