@micromag/screen-image 0.4.49 → 0.4.50
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 +120 -111
- package/package.json +12 -12
package/es/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { FormattedMessage, defineMessage } from 'react-intl';
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
3
4
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
5
|
import classNames from 'classnames';
|
|
5
|
-
import
|
|
6
|
+
import { useState, useCallback, useMemo } from 'react';
|
|
6
7
|
import { ScreenElement } from '@micromag/core/components';
|
|
7
8
|
import { useScreenSize, useScreenRenderContext, useViewerContext, useViewerWebView, usePlaybackContext, usePlaybackMediaRef } from '@micromag/core/contexts';
|
|
8
9
|
import { useDimensionObserver } from '@micromag/core/hooks';
|
|
@@ -15,13 +16,12 @@ import Heading from '@micromag/element-heading';
|
|
|
15
16
|
import Layout from '@micromag/element-layout';
|
|
16
17
|
import Text from '@micromag/element-text';
|
|
17
18
|
import Visual from '@micromag/element-visual';
|
|
19
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
18
20
|
import _objectDestructuringEmpty from '@babel/runtime/helpers/objectDestructuringEmpty';
|
|
19
21
|
import _extends from '@babel/runtime/helpers/extends';
|
|
20
22
|
|
|
21
23
|
var styles = {"container":"micromag-screen-image-container","background":"micromag-screen-image-background","content":"micromag-screen-image-content","emptyImage":"micromag-screen-image-emptyImage","emptyTitle":"micromag-screen-image-emptyTitle","emptyText":"micromag-screen-image-emptyText","emptyLegend":"micromag-screen-image-emptyLegend","imageContainer":"micromag-screen-image-imageContainer","image":"micromag-screen-image-image","placeholderImage":"micromag-screen-image-placeholderImage","isPlaceholder":"micromag-screen-image-isPlaceholder","layout":"micromag-screen-image-layout","isCard":"micromag-screen-image-isCard","isCardReverse":"micromag-screen-image-isCardReverse","footer":"micromag-screen-image-footer","isFullscreen":"micromag-screen-image-isFullscreen","header":"micromag-screen-image-header"};
|
|
22
24
|
|
|
23
|
-
// NOTE: should this be a scrolling element ?
|
|
24
|
-
|
|
25
25
|
function ImageScreen(_ref) {
|
|
26
26
|
var _ref$layout = _ref.layout,
|
|
27
27
|
layout = _ref$layout === void 0 ? 'normal' : _ref$layout,
|
|
@@ -124,45 +124,45 @@ function ImageScreen(_ref) {
|
|
|
124
124
|
marginTop: isCardReverse && !hasHeader ? finalSpacing : finalSpacing / 2,
|
|
125
125
|
marginBottom: isCard && !hasHeader ? finalSpacing : finalSpacing / 2
|
|
126
126
|
} : null;
|
|
127
|
-
var items = [/*#__PURE__*/
|
|
128
|
-
key: "image",
|
|
127
|
+
var items = [/*#__PURE__*/jsx("div", {
|
|
129
128
|
ref: imageCntRef,
|
|
130
129
|
className: styles.imageContainer,
|
|
131
130
|
style: !isPlaceholder ? {
|
|
132
131
|
margin: imageMargin
|
|
133
|
-
} : null
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
132
|
+
} : null,
|
|
133
|
+
children: /*#__PURE__*/jsx(ScreenElement, {
|
|
134
|
+
placeholder: "image",
|
|
135
|
+
placeholderProps: {
|
|
136
|
+
className: styles.placeholderImage,
|
|
137
|
+
height: '100%'
|
|
138
|
+
},
|
|
139
|
+
emptyLabel: /*#__PURE__*/jsx(FormattedMessage, {
|
|
140
|
+
id: "ebsPd4",
|
|
141
|
+
defaultMessage: [{
|
|
142
|
+
"type": 0,
|
|
143
|
+
"value": "Image"
|
|
144
|
+
}]
|
|
145
|
+
}),
|
|
146
|
+
emptyClassName: styles.emptyImage,
|
|
147
|
+
isEmpty: !hasImage,
|
|
148
|
+
children: hasImage ? /*#__PURE__*/jsx(Visual, {
|
|
149
|
+
className: styles.image,
|
|
150
|
+
media: image,
|
|
151
|
+
objectFit: finalImageFit,
|
|
152
|
+
width: imageWidth,
|
|
153
|
+
height: imageHeight,
|
|
154
|
+
resolution: resolution,
|
|
155
|
+
playing: backgroundPlaying,
|
|
156
|
+
muted: muted,
|
|
157
|
+
active: active,
|
|
158
|
+
shouldLoad: mediaShouldLoad,
|
|
159
|
+
withoutVideo: isPreview,
|
|
160
|
+
onLoaded: onImageLoaded
|
|
161
|
+
}) : null
|
|
162
|
+
})
|
|
163
|
+
}, "image"), withTitle && /*#__PURE__*/jsx(ScreenElement, {
|
|
164
164
|
placeholder: "title",
|
|
165
|
-
emptyLabel: /*#__PURE__*/
|
|
165
|
+
emptyLabel: /*#__PURE__*/jsx(FormattedMessage, {
|
|
166
166
|
id: "2ZOPe+",
|
|
167
167
|
defaultMessage: [{
|
|
168
168
|
"type": 0,
|
|
@@ -170,13 +170,14 @@ function ImageScreen(_ref) {
|
|
|
170
170
|
}]
|
|
171
171
|
}),
|
|
172
172
|
emptyClassName: styles.emptyTitle,
|
|
173
|
-
isEmpty: !hasTitle
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
173
|
+
isEmpty: !hasTitle,
|
|
174
|
+
children: hasTitle ? /*#__PURE__*/jsx("div", {
|
|
175
|
+
style: itemMarginStyle,
|
|
176
|
+
children: /*#__PURE__*/jsx(Heading, _objectSpread({}, title))
|
|
177
|
+
}) : null
|
|
178
|
+
}, "title"), withText && /*#__PURE__*/jsx(ScreenElement, {
|
|
178
179
|
placeholder: "text",
|
|
179
|
-
emptyLabel: /*#__PURE__*/
|
|
180
|
+
emptyLabel: /*#__PURE__*/jsx(FormattedMessage, {
|
|
180
181
|
id: "z4CiV1",
|
|
181
182
|
defaultMessage: [{
|
|
182
183
|
"type": 0,
|
|
@@ -184,13 +185,14 @@ function ImageScreen(_ref) {
|
|
|
184
185
|
}]
|
|
185
186
|
}),
|
|
186
187
|
emptyClassName: styles.emptyText,
|
|
187
|
-
isEmpty: !hasText
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
188
|
+
isEmpty: !hasText,
|
|
189
|
+
children: hasText ? /*#__PURE__*/jsx("div", {
|
|
190
|
+
style: itemMarginStyle,
|
|
191
|
+
children: /*#__PURE__*/jsx(Text, _objectSpread({}, text))
|
|
192
|
+
}) : null
|
|
193
|
+
}, "text"), withLegend && /*#__PURE__*/jsx(ScreenElement, {
|
|
192
194
|
placeholder: "shortText",
|
|
193
|
-
emptyLabel: /*#__PURE__*/
|
|
195
|
+
emptyLabel: /*#__PURE__*/jsx(FormattedMessage, {
|
|
194
196
|
id: "dqnkQk",
|
|
195
197
|
defaultMessage: [{
|
|
196
198
|
"type": 0,
|
|
@@ -198,10 +200,12 @@ function ImageScreen(_ref) {
|
|
|
198
200
|
}]
|
|
199
201
|
}),
|
|
200
202
|
emptyClassName: styles.emptyLegend,
|
|
201
|
-
isEmpty: !hasLegend
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
isEmpty: !hasLegend,
|
|
204
|
+
children: hasLegend ? /*#__PURE__*/jsx("div", {
|
|
205
|
+
style: itemMarginStyle,
|
|
206
|
+
children: /*#__PURE__*/jsx(Text, _objectSpread({}, legend))
|
|
207
|
+
}) : null
|
|
208
|
+
}, "legend")];
|
|
205
209
|
if (isReversed) {
|
|
206
210
|
items.reverse();
|
|
207
211
|
} else if (isTitleTop) {
|
|
@@ -219,87 +223,92 @@ function ImageScreen(_ref) {
|
|
|
219
223
|
paddingTop = current && !isPreview ? viewerTopHeight : 0;
|
|
220
224
|
paddingBottom = current && !isPreview ? viewerBottomHeight : 0;
|
|
221
225
|
}
|
|
222
|
-
return /*#__PURE__*/
|
|
226
|
+
return /*#__PURE__*/jsxs("div", {
|
|
223
227
|
className: classNames([styles.container, className, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, styles.isReversed, isReversed), styles.isPlaceholder, isPlaceholder), styles.isCard, isCard), styles.isCardReverse, isCardReverse), styles.isFullscreen, isFullscreen)]),
|
|
224
|
-
"data-screen-ready": ready
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
228
|
+
"data-screen-ready": ready,
|
|
229
|
+
children: [/*#__PURE__*/jsx(Container, {
|
|
230
|
+
width: width,
|
|
231
|
+
height: height,
|
|
232
|
+
className: styles.content,
|
|
233
|
+
children: /*#__PURE__*/jsxs(Layout, {
|
|
234
|
+
className: styles.layout,
|
|
235
|
+
fullscreen: true,
|
|
236
|
+
style: !isPlaceholder ? {
|
|
237
|
+
padding: finalSpacing / 2,
|
|
238
|
+
paddingTop: paddingTop,
|
|
239
|
+
paddingBottom: paddingBottom
|
|
240
|
+
} : null,
|
|
241
|
+
children: [!isPlaceholder && hasHeader ? /*#__PURE__*/jsx("div", {
|
|
242
|
+
className: styles.header,
|
|
243
|
+
style: isFullscreen || isCardReverse ? {
|
|
244
|
+
paddingTop: hasHeader ? spacing / 2 : spacing,
|
|
245
|
+
paddingBottom: hasHeader ? spacing / 2 : spacing,
|
|
246
|
+
paddingLeft: isCardReverse ? spacing / 2 : spacing,
|
|
247
|
+
paddingRight: isCardReverse ? spacing / 2 : spacing,
|
|
248
|
+
transform: !isPreview ? "translate(0, ".concat(viewerTopHeight, "px)") : null
|
|
249
|
+
} : {
|
|
250
|
+
paddingTop: isCardLayout ? spacing / 2 : null,
|
|
251
|
+
paddingBottom: isCardLayout ? spacing : spacing / 2,
|
|
252
|
+
paddingLeft: spacing / 2,
|
|
253
|
+
paddingRight: spacing / 2
|
|
254
|
+
},
|
|
255
|
+
children: /*#__PURE__*/jsx(Header, _objectSpread({}, header))
|
|
256
|
+
}) : null, items, !isPlaceholder && hasFooter ? /*#__PURE__*/jsx("div", {
|
|
257
|
+
className: styles.footer,
|
|
258
|
+
style: isFullscreen || isCardReverse ? {
|
|
259
|
+
paddingLeft: Math.max(spacing / 2, viewerBottomSidesWidth),
|
|
260
|
+
paddingRight: Math.max(spacing / 2, viewerBottomSidesWidth),
|
|
261
|
+
paddingTop: spacing / 2,
|
|
262
|
+
paddingBottom: spacing / 2,
|
|
263
|
+
transform: !isPreview ? "translate(0, -".concat(viewerBottomHeight, "px)") : null
|
|
264
|
+
} : {
|
|
265
|
+
paddingLeft: Math.max(viewerBottomSidesWidth - spacing, 0),
|
|
266
|
+
paddingRight: Math.max(viewerBottomSidesWidth - spacing, 0),
|
|
267
|
+
paddingTop: isCardLayout ? spacing / 2 : null,
|
|
268
|
+
paddingBottom: isCardLayout ? spacing / 2 : null
|
|
269
|
+
},
|
|
270
|
+
children: /*#__PURE__*/jsx(Footer, _objectSpread({}, footerProps))
|
|
271
|
+
}) : null]
|
|
272
|
+
})
|
|
273
|
+
}), !isPlaceholder ? /*#__PURE__*/jsx(Background, {
|
|
274
|
+
background: background,
|
|
275
|
+
width: width,
|
|
276
|
+
height: height,
|
|
277
|
+
resolution: resolution,
|
|
278
|
+
playing: backgroundPlaying,
|
|
279
|
+
muted: muted,
|
|
280
|
+
shouldLoad: mediaShouldLoad,
|
|
281
|
+
mediaRef: mediaRef,
|
|
282
|
+
withoutVideo: isPreview,
|
|
283
|
+
className: styles.background
|
|
284
|
+
}) : null]
|
|
285
|
+
});
|
|
277
286
|
}
|
|
278
287
|
|
|
279
288
|
function ImageLegendScreen(_ref) {
|
|
280
289
|
var props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
281
|
-
return /*#__PURE__*/
|
|
290
|
+
return /*#__PURE__*/jsx(ImageScreen, _objectSpread(_objectSpread({}, props), {}, {
|
|
282
291
|
withLegend: true
|
|
283
292
|
}));
|
|
284
293
|
}
|
|
285
294
|
|
|
286
295
|
function ImageTextScreen(_ref) {
|
|
287
296
|
var props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
288
|
-
return /*#__PURE__*/
|
|
297
|
+
return /*#__PURE__*/jsx(ImageScreen, _objectSpread(_objectSpread({}, props), {}, {
|
|
289
298
|
withText: true
|
|
290
299
|
}));
|
|
291
300
|
}
|
|
292
301
|
|
|
293
302
|
function ImageTitleScreen(_ref) {
|
|
294
303
|
var props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
295
|
-
return /*#__PURE__*/
|
|
304
|
+
return /*#__PURE__*/jsx(ImageScreen, _objectSpread(_objectSpread({}, props), {}, {
|
|
296
305
|
withTitle: true
|
|
297
306
|
}));
|
|
298
307
|
}
|
|
299
308
|
|
|
300
309
|
function ImageTitleTextScreen(_ref) {
|
|
301
310
|
var props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
302
|
-
return /*#__PURE__*/
|
|
311
|
+
return /*#__PURE__*/jsx(ImageScreen, _objectSpread(_objectSpread({}, props), {}, {
|
|
303
312
|
withTitle: true,
|
|
304
313
|
withText: true
|
|
305
314
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/screen-image",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.50",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -61,16 +61,16 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@babel/runtime": "^7.28.6",
|
|
64
|
-
"@micromag/core": "^0.4.
|
|
65
|
-
"@micromag/element-background": "^0.4.
|
|
66
|
-
"@micromag/element-container": "^0.4.
|
|
67
|
-
"@micromag/element-footer": "^0.4.
|
|
68
|
-
"@micromag/element-header": "^0.4.
|
|
69
|
-
"@micromag/element-heading": "^0.4.
|
|
70
|
-
"@micromag/element-layout": "^0.4.
|
|
71
|
-
"@micromag/element-text": "^0.4.
|
|
72
|
-
"@micromag/element-visual": "^0.4.
|
|
73
|
-
"@micromag/transforms": "^0.4.
|
|
64
|
+
"@micromag/core": "^0.4.50",
|
|
65
|
+
"@micromag/element-background": "^0.4.50",
|
|
66
|
+
"@micromag/element-container": "^0.4.50",
|
|
67
|
+
"@micromag/element-footer": "^0.4.50",
|
|
68
|
+
"@micromag/element-header": "^0.4.50",
|
|
69
|
+
"@micromag/element-heading": "^0.4.50",
|
|
70
|
+
"@micromag/element-layout": "^0.4.50",
|
|
71
|
+
"@micromag/element-text": "^0.4.50",
|
|
72
|
+
"@micromag/element-visual": "^0.4.50",
|
|
73
|
+
"@micromag/transforms": "^0.4.50",
|
|
74
74
|
"classnames": "^2.2.6",
|
|
75
75
|
"lodash": "^4.17.23",
|
|
76
76
|
"react-intl": "^8.1.3 || ^10.0.0",
|
|
@@ -80,6 +80,6 @@
|
|
|
80
80
|
"access": "public",
|
|
81
81
|
"registry": "https://registry.npmjs.org/"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "940d5ca98f8f448b79eaa3e2fa685c3ee95185b8",
|
|
84
84
|
"types": "es/index.d.ts"
|
|
85
85
|
}
|