@micromag/screen-article 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.
Files changed (2) hide show
  1. package/es/index.js +122 -110
  2. package/package.json +15 -15
package/es/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { useIntl, FormattedMessage, defineMessage } from 'react-intl';
2
2
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
3
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
+ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
4
5
  import classNames from 'classnames';
5
6
  import dayjs from 'dayjs';
6
- import React, { useMemo, useState, useCallback } from 'react';
7
+ import { useMemo, useState, useCallback } from 'react';
7
8
  import { ScreenElement } from '@micromag/core/components';
8
9
  import { useScreenSize, useViewerContext, useViewerWebView, usePlaybackContext, usePlaybackMediaRef, useScreenRenderContext } from '@micromag/core/contexts';
9
10
  import { useTrackScreenEvent, useDimensionObserver } from '@micromag/core/hooks';
@@ -18,6 +19,7 @@ import Layout from '@micromag/element-layout';
18
19
  import Scroll from '@micromag/element-scroll';
19
20
  import Text from '@micromag/element-text';
20
21
  import Visual from '@micromag/element-visual';
22
+ import { jsx, jsxs } from 'react/jsx-runtime';
21
23
 
22
24
  var styles = {"container":"micromag-screen-article-container","background":"micromag-screen-article-background","content":"micromag-screen-article-content","layout":"micromag-screen-article-layout","emptyTitle":"micromag-screen-article-emptyTitle","emptyAuthor":"micromag-screen-article-emptyAuthor","emptySubtitle":"micromag-screen-article-emptySubtitle","emptyText":"micromag-screen-article-emptyText","emptySurtitle":"micromag-screen-article-emptySurtitle","emptyDate":"micromag-screen-article-emptyDate","main":"micromag-screen-article-main","hasText":"micromag-screen-article-hasText","visualContainer":"micromag-screen-article-visualContainer","surtitle":"micromag-screen-article-surtitle","subtitle":"micromag-screen-article-subtitle","date":"micromag-screen-article-date","title":"micromag-screen-article-title","author":"micromag-screen-article-author","text":"micromag-screen-article-text","topContent":"micromag-screen-article-topContent","footer":"micromag-screen-article-footer","disabled":"micromag-screen-article-disabled","isPlaceholder":"micromag-screen-article-isPlaceholder"};
23
25
 
@@ -129,9 +131,9 @@ function ArticleScreen(_ref) {
129
131
  day: '2-digit'
130
132
  }), "</p>") : null;
131
133
  }, [partialDate]);
132
- var imageElement = /*#__PURE__*/React.createElement(ScreenElement, {
134
+ var imageElement = /*#__PURE__*/jsx(ScreenElement, {
133
135
  placeholder: "image",
134
- emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
136
+ emptyLabel: /*#__PURE__*/jsx(FormattedMessage, {
135
137
  id: "ebsPd4",
136
138
  defaultMessage: [{
137
139
  "type": 0,
@@ -139,24 +141,25 @@ function ArticleScreen(_ref) {
139
141
  }]
140
142
  }),
141
143
  emptyClassName: styles.emptyText,
142
- isEmpty: !hasImage
143
- }, /*#__PURE__*/React.createElement("div", {
144
- ref: imageCntRef,
145
- className: styles.visualContainer
146
- }, hasImage ? /*#__PURE__*/React.createElement(Visual, {
147
- media: image
148
- // width={width - spacing * 2} // in layout flow
149
- ,
150
- width: width,
151
- height: mediaHeight,
152
- shouldLoad: mediaShouldLoad,
153
- resolution: resolution,
154
- className: styles.visual
155
- }) : null));
156
- var titleElement = /*#__PURE__*/React.createElement(ScreenElement, {
157
- key: "title",
144
+ isEmpty: !hasImage,
145
+ children: /*#__PURE__*/jsx("div", {
146
+ ref: imageCntRef,
147
+ className: styles.visualContainer,
148
+ children: hasImage ? /*#__PURE__*/jsx(Visual, {
149
+ media: image
150
+ // width={width - spacing * 2} // in layout flow
151
+ ,
152
+ width: width,
153
+ height: mediaHeight,
154
+ shouldLoad: mediaShouldLoad,
155
+ resolution: resolution,
156
+ className: styles.visual
157
+ }) : null
158
+ })
159
+ });
160
+ var titleElement = /*#__PURE__*/jsx(ScreenElement, {
158
161
  placeholder: "title",
159
- emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
162
+ emptyLabel: /*#__PURE__*/jsx(FormattedMessage, {
160
163
  id: "2ZOPe+",
161
164
  defaultMessage: [{
162
165
  "type": 0,
@@ -164,14 +167,14 @@ function ArticleScreen(_ref) {
164
167
  }]
165
168
  }),
166
169
  emptyClassName: styles.emptyTitle,
167
- isEmpty: !hasTitle
168
- }, hasTitle ? /*#__PURE__*/React.createElement(Heading, Object.assign({
169
- className: styles.title
170
- }, title)) : null);
171
- var surtitleElement = /*#__PURE__*/React.createElement(ScreenElement, {
172
- key: "surtitle",
170
+ isEmpty: !hasTitle,
171
+ children: hasTitle ? /*#__PURE__*/jsx(Heading, _objectSpread({
172
+ className: styles.title
173
+ }, title)) : null
174
+ }, "title");
175
+ var surtitleElement = /*#__PURE__*/jsx(ScreenElement, {
173
176
  placeholder: "line",
174
- emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
177
+ emptyLabel: /*#__PURE__*/jsx(FormattedMessage, {
175
178
  id: "vdWMTA",
176
179
  defaultMessage: [{
177
180
  "type": 0,
@@ -179,14 +182,14 @@ function ArticleScreen(_ref) {
179
182
  }]
180
183
  }),
181
184
  emptyClassName: styles.emptySurtitle,
182
- isEmpty: !hasSurtitle
183
- }, hasSurtitle ? /*#__PURE__*/React.createElement(Text, Object.assign({
184
- className: styles.surtitle
185
- }, surtitle)) : null);
186
- var subtitleElement = /*#__PURE__*/React.createElement(ScreenElement, {
187
- key: "subtitle",
185
+ isEmpty: !hasSurtitle,
186
+ children: hasSurtitle ? /*#__PURE__*/jsx(Text, _objectSpread({
187
+ className: styles.surtitle
188
+ }, surtitle)) : null
189
+ }, "surtitle");
190
+ var subtitleElement = /*#__PURE__*/jsx(ScreenElement, {
188
191
  placeholder: "line",
189
- emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
192
+ emptyLabel: /*#__PURE__*/jsx(FormattedMessage, {
190
193
  id: "d60tSn",
191
194
  defaultMessage: [{
192
195
  "type": 0,
@@ -194,14 +197,14 @@ function ArticleScreen(_ref) {
194
197
  }]
195
198
  }),
196
199
  emptyClassName: styles.emptySubtitle,
197
- isEmpty: !hasSubtitle
198
- }, hasSubtitle ? /*#__PURE__*/React.createElement(Text, Object.assign({
199
- className: styles.subtitle
200
- }, subtitle)) : null);
201
- var dateElement = /*#__PURE__*/React.createElement(ScreenElement, {
202
- key: "date",
200
+ isEmpty: !hasSubtitle,
201
+ children: hasSubtitle ? /*#__PURE__*/jsx(Text, _objectSpread({
202
+ className: styles.subtitle
203
+ }, subtitle)) : null
204
+ }, "subtitle");
205
+ var dateElement = /*#__PURE__*/jsx(ScreenElement, {
203
206
  placeholder: "line",
204
- emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
207
+ emptyLabel: /*#__PURE__*/jsx(FormattedMessage, {
205
208
  id: "/MsgWe",
206
209
  defaultMessage: [{
207
210
  "type": 0,
@@ -209,16 +212,16 @@ function ArticleScreen(_ref) {
209
212
  }]
210
213
  }),
211
214
  emptyClassName: styles.emptyDate,
212
- isEmpty: !hasDate
213
- }, hasDate ? /*#__PURE__*/React.createElement(Text, Object.assign({
214
- className: styles.date
215
- }, date, {
216
- body: finalDate
217
- })) : null);
218
- var authorElement = /*#__PURE__*/React.createElement(ScreenElement, {
219
- key: "author",
215
+ isEmpty: !hasDate,
216
+ children: hasDate ? /*#__PURE__*/jsx(Text, _objectSpread(_objectSpread({
217
+ className: styles.date
218
+ }, date), {}, {
219
+ body: finalDate
220
+ })) : null
221
+ }, "date");
222
+ var authorElement = /*#__PURE__*/jsxs(ScreenElement, {
220
223
  placeholder: "line",
221
- emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
224
+ emptyLabel: /*#__PURE__*/jsx(FormattedMessage, {
222
225
  id: "xYqGzM",
223
226
  defaultMessage: [{
224
227
  "type": 0,
@@ -226,15 +229,16 @@ function ArticleScreen(_ref) {
226
229
  }]
227
230
  }),
228
231
  emptyClassName: styles.emptyAuthor,
229
- isEmpty: !hasAuthor && !hasSimpleAuthor
230
- }, hasSimpleAuthor ? /*#__PURE__*/React.createElement(Text, Object.assign({
231
- className: styles.author
232
- }, author)) : null, hasAuthor ? /*#__PURE__*/React.createElement(Author, {
233
- author: author
234
- }) : null);
235
- var contentElement = /*#__PURE__*/React.createElement(ScreenElement, {
232
+ isEmpty: !hasAuthor && !hasSimpleAuthor,
233
+ children: [hasSimpleAuthor ? /*#__PURE__*/jsx(Text, _objectSpread({
234
+ className: styles.author
235
+ }, author)) : null, hasAuthor ? /*#__PURE__*/jsx(Author, {
236
+ author: author
237
+ }) : null]
238
+ }, "author");
239
+ var contentElement = /*#__PURE__*/jsx(ScreenElement, {
236
240
  placeholder: "text",
237
- emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
241
+ emptyLabel: /*#__PURE__*/jsx(FormattedMessage, {
238
242
  id: "z4CiV1",
239
243
  defaultMessage: [{
240
244
  "type": 0,
@@ -242,10 +246,11 @@ function ArticleScreen(_ref) {
242
246
  }]
243
247
  }),
244
248
  emptyClassName: styles.emptyText,
245
- isEmpty: !hasText
246
- }, hasText ? /*#__PURE__*/React.createElement(Text, Object.assign({
247
- className: styles.text
248
- }, text)) : null);
249
+ isEmpty: !hasText,
250
+ children: hasText ? /*#__PURE__*/jsx(Text, _objectSpread({
251
+ className: styles.text
252
+ }, text)) : null
253
+ });
249
254
  var _useState = useState(false),
250
255
  _useState2 = _slicedToArray(_useState, 2),
251
256
  scrolledBottom = _useState2[0],
@@ -269,55 +274,62 @@ function ArticleScreen(_ref) {
269
274
  var onScrolledNotBottom = useCallback(function () {
270
275
  setScrolledBottom(false);
271
276
  }, [setScrolledBottom]);
272
- return /*#__PURE__*/React.createElement("div", {
277
+ return /*#__PURE__*/jsxs("div", {
273
278
  className: classNames([styles.container, className, _defineProperty({}, styles.isPlaceholder, isPlaceholder)]),
274
- "data-screen-ready": ready
275
- }, /*#__PURE__*/React.createElement(Container, {
276
- width: width,
277
- height: height,
278
- className: styles.content
279
- }, /*#__PURE__*/React.createElement(Scroll, {
280
- disabled: scrollingDisabled,
281
- onScrolledTrigger: onScrolledTrigger,
282
- onScrolledBottom: onScrolledBottom,
283
- onScrolledNotBottom: onScrolledNotBottom,
284
- withShadow: true
285
- }, /*#__PURE__*/React.createElement(Layout, {
286
- className: styles.layout,
287
- style: !isPlaceholder ? {
288
- padding: spacing,
289
- paddingTop: hasHeader ? spacing / 2 + (!isPreview ? viewerTopHeight : 0) : spacing / 2 + imageHeight,
290
- paddingBottom: (current && !isPreview ? viewerBottomHeight : 0) + spacing / 2
291
- } : null
292
- }, !isPlaceholder && hasHeader ? /*#__PURE__*/React.createElement("div", {
293
- key: "header",
294
- style: {
295
- height: hasImage && imageHeight > 0 ? 0 : 'auto',
296
- paddingBottom: imageHeight > 0 ? imageHeight - viewerTopHeight : spacing
297
- }
298
- }, /*#__PURE__*/React.createElement(Header, header)) : null, /*#__PURE__*/React.createElement("div", {
299
- className: classNames([styles.main, _defineProperty({}, styles.hasText, hasText && hasAuthor)])
300
- }, imageElement, /*#__PURE__*/React.createElement("div", {
301
- className: styles.topContent
302
- }, surtitleElement, dateElement), titleElement, authorElement, subtitleElement), contentElement, !isPlaceholder && hasFooter ? /*#__PURE__*/React.createElement("div", {
303
- className: classNames([styles.footer, _defineProperty({}, styles.disabled, !scrolledBottom)]),
304
- style: {
305
- paddingLeft: Math.max(viewerBottomSidesWidth - spacing, 0),
306
- paddingRight: Math.max(viewerBottomSidesWidth - spacing, 0),
307
- paddingTop: spacing
308
- }
309
- }, /*#__PURE__*/React.createElement(Footer, footerProps)) : null))), !isPlaceholder ? /*#__PURE__*/React.createElement(Background, {
310
- background: background,
311
- width: width,
312
- height: height,
313
- resolution: resolution,
314
- playing: backgroundPlaying,
315
- muted: muted,
316
- shouldLoad: mediaShouldLoad,
317
- mediaRef: mediaRef,
318
- withoutVideo: isPreview,
319
- className: styles.background
320
- }) : null);
279
+ "data-screen-ready": ready,
280
+ children: [/*#__PURE__*/jsx(Container, {
281
+ width: width,
282
+ height: height,
283
+ className: styles.content,
284
+ children: /*#__PURE__*/jsx(Scroll, {
285
+ disabled: scrollingDisabled,
286
+ onScrolledTrigger: onScrolledTrigger,
287
+ onScrolledBottom: onScrolledBottom,
288
+ onScrolledNotBottom: onScrolledNotBottom,
289
+ withShadow: true,
290
+ children: /*#__PURE__*/jsxs(Layout, {
291
+ className: styles.layout,
292
+ style: !isPlaceholder ? {
293
+ padding: spacing,
294
+ paddingTop: hasHeader ? spacing / 2 + (!isPreview ? viewerTopHeight : 0) : spacing / 2 + imageHeight,
295
+ paddingBottom: (current && !isPreview ? viewerBottomHeight : 0) + spacing / 2
296
+ } : null,
297
+ children: [!isPlaceholder && hasHeader ? /*#__PURE__*/jsx("div", {
298
+ style: {
299
+ height: hasImage && imageHeight > 0 ? 0 : 'auto',
300
+ paddingBottom: imageHeight > 0 ? imageHeight - viewerTopHeight : spacing
301
+ },
302
+ children: /*#__PURE__*/jsx(Header, _objectSpread({}, header))
303
+ }, "header") : null, /*#__PURE__*/jsxs("div", {
304
+ className: classNames([styles.main, _defineProperty({}, styles.hasText, hasText && hasAuthor)]),
305
+ children: [imageElement, /*#__PURE__*/jsxs("div", {
306
+ className: styles.topContent,
307
+ children: [surtitleElement, dateElement]
308
+ }), titleElement, authorElement, subtitleElement]
309
+ }), contentElement, !isPlaceholder && hasFooter ? /*#__PURE__*/jsx("div", {
310
+ className: classNames([styles.footer, _defineProperty({}, styles.disabled, !scrolledBottom)]),
311
+ style: {
312
+ paddingLeft: Math.max(viewerBottomSidesWidth - spacing, 0),
313
+ paddingRight: Math.max(viewerBottomSidesWidth - spacing, 0),
314
+ paddingTop: spacing
315
+ },
316
+ children: /*#__PURE__*/jsx(Footer, _objectSpread({}, footerProps))
317
+ }) : null]
318
+ })
319
+ })
320
+ }), !isPlaceholder ? /*#__PURE__*/jsx(Background, {
321
+ background: background,
322
+ width: width,
323
+ height: height,
324
+ resolution: resolution,
325
+ playing: backgroundPlaying,
326
+ muted: muted,
327
+ shouldLoad: mediaShouldLoad,
328
+ mediaRef: mediaRef,
329
+ withoutVideo: isPreview,
330
+ className: styles.background
331
+ }) : null]
332
+ });
321
333
  }
322
334
 
323
335
  // import * as transforms from './transforms/index';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/screen-article",
3
- "version": "0.4.49",
3
+ "version": "0.4.50",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -57,19 +57,19 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "@babel/runtime": "^7.28.6",
60
- "@micromag/core": "^0.4.49",
61
- "@micromag/element-author": "^0.4.49",
62
- "@micromag/element-background": "^0.4.49",
63
- "@micromag/element-container": "^0.4.49",
64
- "@micromag/element-footer": "^0.4.49",
65
- "@micromag/element-header": "^0.4.49",
66
- "@micromag/element-heading": "^0.4.49",
67
- "@micromag/element-layout": "^0.4.49",
68
- "@micromag/element-scroll": "^0.4.49",
69
- "@micromag/element-stack": "^0.4.49",
70
- "@micromag/element-text": "^0.4.49",
71
- "@micromag/element-visual": "^0.4.49",
72
- "@micromag/transforms": "^0.4.49",
60
+ "@micromag/core": "^0.4.50",
61
+ "@micromag/element-author": "^0.4.50",
62
+ "@micromag/element-background": "^0.4.50",
63
+ "@micromag/element-container": "^0.4.50",
64
+ "@micromag/element-footer": "^0.4.50",
65
+ "@micromag/element-header": "^0.4.50",
66
+ "@micromag/element-heading": "^0.4.50",
67
+ "@micromag/element-layout": "^0.4.50",
68
+ "@micromag/element-scroll": "^0.4.50",
69
+ "@micromag/element-stack": "^0.4.50",
70
+ "@micromag/element-text": "^0.4.50",
71
+ "@micromag/element-visual": "^0.4.50",
72
+ "@micromag/transforms": "^0.4.50",
73
73
  "classnames": "^2.2.6",
74
74
  "dayjs": "^1.11.10",
75
75
  "lodash": "^4.17.23",
@@ -80,6 +80,6 @@
80
80
  "access": "public",
81
81
  "registry": "https://registry.npmjs.org/"
82
82
  },
83
- "gitHead": "0a225ff29387217cccb0fcc5a731e23c74bd202e",
83
+ "gitHead": "940d5ca98f8f448b79eaa3e2fa685c3ee95185b8",
84
84
  "types": "es/index.d.ts"
85
85
  }