@micromag/screen-urbania-article 0.3.742 → 0.3.744

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 +111 -93
  2. package/package.json +11 -11
package/es/index.js CHANGED
@@ -5,10 +5,10 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
5
5
  import { getJSON } from '@folklore/fetch';
6
6
  import PropTypes from 'prop-types';
7
7
  import React, { useMemo, useState, useEffect, useCallback } from 'react';
8
+ import { PropTypes as PropTypes$1 } from '@micromag/core';
8
9
  import { isTextFilled, isHeaderFilled, isFooterFilled, getFooterProps, getStyleFromColor, isValidUrl } from '@micromag/core/utils';
9
10
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
10
11
  import classNames from 'classnames';
11
- import { PropTypes as PropTypes$1 } from '@micromag/core';
12
12
  import { ScreenElement, Empty, PlaceholderSubtitle, PlaceholderTitle, PlaceholderImage, PlaceholderText, Close, Spinner } from '@micromag/core/components';
13
13
  import { useScreenSize, useScreenRenderContext, useViewerWebView, useViewerContext, useViewerInteraction, usePlaybackContext, usePlaybackMediaRef } from '@micromag/core/contexts';
14
14
  import { useDimensionObserver, useResizeObserver } from '@micromag/core/hooks';
@@ -455,10 +455,22 @@ var UrbaniaArticle = function UrbaniaArticle(_ref) {
455
455
  UrbaniaArticle.propTypes = propTypes$2;
456
456
  UrbaniaArticle.defaultProps = defaultProps$2;
457
457
 
458
- var _excluded = ["component", "theme", "url", "article"];
458
+ var _excluded = ["component", "title", "articleType", "overTitle", "sponsorLabel", "author", "image", "header", "footer", "url", "article"];
459
459
  var propTypes$1 = {
460
460
  component: PropTypes.elementType,
461
- theme: PropTypes.string,
461
+ // theme: PropTypes.string,
462
+ title: PropTypes$1.headingElement,
463
+ articleType: PropTypes.string,
464
+ overTitle: PropTypes.shape({
465
+ body: PropTypes.string
466
+ }),
467
+ sponsorLabel: PropTypes.shape({
468
+ body: PropTypes.string
469
+ }),
470
+ author: PropTypes$1.authorElement,
471
+ image: PropTypes$1.image,
472
+ header: PropTypes$1.header,
473
+ footer: PropTypes$1.footer,
462
474
  url: PropTypes.string,
463
475
  article: PropTypes.shape({
464
476
  type: PropTypes.string
@@ -466,109 +478,110 @@ var propTypes$1 = {
466
478
  };
467
479
  var defaultProps$1 = {
468
480
  component: UrbaniaArticle,
469
- theme: null,
481
+ // theme: null,
482
+ title: null,
483
+ articleType: null,
484
+ overTitle: null,
485
+ sponsorLabel: null,
486
+ author: null,
487
+ image: null,
488
+ header: null,
489
+ footer: null,
470
490
  url: null,
471
491
  article: null
472
492
  };
473
493
  var UrbaniaLoader = function UrbaniaLoader(_ref) {
474
- var Component = _ref.component;
475
- _ref.theme;
476
- var url = _ref.url,
494
+ var Component = _ref.component,
495
+ _ref$title = _ref.title,
496
+ title = _ref$title === void 0 ? null : _ref$title,
497
+ _ref$articleType = _ref.articleType,
498
+ articleType = _ref$articleType === void 0 ? null : _ref$articleType,
499
+ _ref$overTitle = _ref.overTitle,
500
+ overTitle = _ref$overTitle === void 0 ? null : _ref$overTitle,
501
+ _ref$sponsorLabel = _ref.sponsorLabel,
502
+ sponsorLabel = _ref$sponsorLabel === void 0 ? null : _ref$sponsorLabel,
503
+ _ref$author = _ref.author,
504
+ author = _ref$author === void 0 ? null : _ref$author,
505
+ _ref$image = _ref.image,
506
+ image = _ref$image === void 0 ? null : _ref$image,
507
+ _ref$header = _ref.header,
508
+ header = _ref$header === void 0 ? null : _ref$header,
509
+ _ref$footer = _ref.footer,
510
+ footer = _ref$footer === void 0 ? null : _ref$footer,
511
+ _ref$url = _ref.url,
512
+ url = _ref$url === void 0 ? null : _ref$url,
477
513
  initialArticle = _ref.article,
478
514
  props = _objectWithoutProperties(_ref, _excluded);
479
515
  var _useState = useState(initialArticle),
480
516
  _useState2 = _slicedToArray(_useState, 2),
481
517
  article = _useState2[0],
482
518
  setArticle = _useState2[1];
483
- // const { isView } = useScreenRenderContext();
484
-
485
- // const hostname = useMemo(() => {
486
- // const { hostname: urlHostname = null } =
487
- // url !== null && isValidUrl(url) ? new URL(url) : {};
488
- // return urlHostname;
489
- // }, [url]);
490
-
491
- var finalUrl = url !== null && isValidUrl(url) ? url.replace(/^https?:\/\/([^.]+\.)?urbania\.(ca|ƒr)\//, 'https://urbania.$2/') : url;
519
+ var finalUrl = url !== null && isValidUrl(url) ? url.replace(/^https?:\/\/([^.]+\.)?urbania\.(ca|ƒr)\//, 'https://urbania.$2/') : null;
492
520
  useEffect(function () {
493
- if (finalUrl !== null && isValidUrl(finalUrl)) {
521
+ if (finalUrl !== null) {
494
522
  getJSON("https://api.urbania.ca/documents?uri=".concat(finalUrl), {
495
523
  mode: 'cors'
496
524
  }).then(function (art) {
525
+ console.log('art loaded', art);
497
526
  setArticle(art || null);
498
- })["catch"](function () {
499
- return setArticle(null);
527
+ })["catch"](function (e) {
528
+ console.log('art error', e);
529
+ setArticle(null);
500
530
  });
501
531
  }
502
- }, [finalUrl, setArticle]);
532
+ }, [url, finalUrl, setArticle]);
503
533
  var values = useMemo(function () {
504
- var _ref2 = props || {},
505
- _ref2$articleType = _ref2.articleType,
506
- articleType = _ref2$articleType === void 0 ? null : _ref2$articleType,
507
- _ref2$title = _ref2.title,
508
- title = _ref2$title === void 0 ? {} : _ref2$title,
509
- _ref2$overTitle = _ref2.overTitle,
510
- overTitle = _ref2$overTitle === void 0 ? {} : _ref2$overTitle,
511
- _ref2$sponsorLabel = _ref2.sponsorLabel,
512
- sponsorLabel = _ref2$sponsorLabel === void 0 ? {} : _ref2$sponsorLabel,
513
- _ref2$author = _ref2.author,
514
- author = _ref2$author === void 0 ? null : _ref2$author,
515
- _ref2$image = _ref2.image,
516
- image = _ref2$image === void 0 ? {} : _ref2$image,
517
- _ref2$header = _ref2.header,
518
- header = _ref2$header === void 0 ? {} : _ref2$header,
519
- _ref2$footer = _ref2.footer,
520
- footer = _ref2$footer === void 0 ? {} : _ref2$footer;
521
- var _ref3 = image || {},
522
- _ref3$url = _ref3.url,
523
- imageUrl = _ref3$url === void 0 ? null : _ref3$url;
524
- var _ref4 = footer || {},
525
- _ref4$callToAction = _ref4.callToAction,
526
- callToAction = _ref4$callToAction === void 0 ? null : _ref4$callToAction;
527
- var _ref5 = callToAction || {},
528
- _ref5$url = _ref5.url,
529
- ctaUrl = _ref5$url === void 0 ? null : _ref5$url;
534
+ var _ref2 = image || {},
535
+ _ref2$url = _ref2.url,
536
+ imageUrl = _ref2$url === void 0 ? null : _ref2$url;
537
+ var _ref3 = footer || {},
538
+ _ref3$callToAction = _ref3.callToAction,
539
+ callToAction = _ref3$callToAction === void 0 ? null : _ref3$callToAction;
540
+ var _ref4 = callToAction || {},
541
+ _ref4$url = _ref4.url,
542
+ ctaUrl = _ref4$url === void 0 ? null : _ref4$url;
530
543
 
531
544
  // Straight from article
532
- var _ref6 = article || {},
533
- _ref6$type = _ref6.type,
534
- type = _ref6$type === void 0 ? null : _ref6$type,
535
- _ref6$title = _ref6.title,
536
- articleTitle = _ref6$title === void 0 ? null : _ref6$title,
537
- _ref6$image = _ref6.image,
538
- articleImage = _ref6$image === void 0 ? null : _ref6$image,
539
- _ref6$metadata = _ref6.metadata,
540
- metadata = _ref6$metadata === void 0 ? {} : _ref6$metadata;
545
+ var _ref5 = article || {},
546
+ _ref5$type = _ref5.type,
547
+ type = _ref5$type === void 0 ? null : _ref5$type,
548
+ _ref5$title = _ref5.title,
549
+ articleTitle = _ref5$title === void 0 ? null : _ref5$title,
550
+ _ref5$image = _ref5.image,
551
+ articleImage = _ref5$image === void 0 ? null : _ref5$image,
552
+ _ref5$metadata = _ref5.metadata,
553
+ metadata = _ref5$metadata === void 0 ? {} : _ref5$metadata;
541
554
  var hasArticle = article !== null;
542
- var _ref7 = metadata || {},
543
- _ref7$authors = _ref7.authors,
544
- authors = _ref7$authors === void 0 ? [] : _ref7$authors,
545
- _ref7$sponsors = _ref7.sponsors,
546
- sponsors = _ref7$sponsors === void 0 ? [] : _ref7$sponsors,
547
- _ref7$brands = _ref7.brands,
548
- brands = _ref7$brands === void 0 ? [] : _ref7$brands;
549
- var _ref8 = authors || [],
550
- _ref9 = _slicedToArray(_ref8, 1),
551
- _ref9$ = _ref9[0],
552
- creditAuthor = _ref9$ === void 0 ? null : _ref9$;
553
- var _ref0 = brands || [],
554
- _ref1 = _slicedToArray(_ref0, 1),
555
- _ref1$ = _ref1[0],
556
- _ref1$2 = _ref1$ === void 0 ? {} : _ref1$,
557
- _ref1$2$handle = _ref1$2.handle,
558
- site = _ref1$2$handle === void 0 ? null : _ref1$2$handle;
559
- var _ref10 = articleImage || {},
560
- _ref10$sizes = _ref10.sizes,
561
- sizes = _ref10$sizes === void 0 ? {} : _ref10$sizes;
562
- var _ref11 = sizes || {},
563
- _ref11$medium = _ref11.medium,
564
- medium = _ref11$medium === void 0 ? {} : _ref11$medium,
565
- _ref11$large = _ref11.large,
566
- large = _ref11$large === void 0 ? {} : _ref11$large;
567
- var _ref12 = creditAuthor || {},
568
- _ref12$name = _ref12.name,
569
- authorName = _ref12$name === void 0 ? null : _ref12$name,
570
- _ref12$image = _ref12.image,
571
- authorImage = _ref12$image === void 0 ? null : _ref12$image;
555
+ var _ref6 = metadata || {},
556
+ _ref6$authors = _ref6.authors,
557
+ authors = _ref6$authors === void 0 ? [] : _ref6$authors,
558
+ _ref6$sponsors = _ref6.sponsors,
559
+ sponsors = _ref6$sponsors === void 0 ? [] : _ref6$sponsors,
560
+ _ref6$brands = _ref6.brands,
561
+ brands = _ref6$brands === void 0 ? [] : _ref6$brands;
562
+ var _ref7 = authors || [],
563
+ _ref8 = _slicedToArray(_ref7, 1),
564
+ _ref8$ = _ref8[0],
565
+ creditAuthor = _ref8$ === void 0 ? null : _ref8$;
566
+ var _ref9 = brands || [],
567
+ _ref0 = _slicedToArray(_ref9, 1),
568
+ _ref0$ = _ref0[0],
569
+ _ref0$2 = _ref0$ === void 0 ? {} : _ref0$,
570
+ _ref0$2$handle = _ref0$2.handle,
571
+ site = _ref0$2$handle === void 0 ? null : _ref0$2$handle;
572
+ var _ref1 = articleImage || {},
573
+ _ref1$sizes = _ref1.sizes,
574
+ sizes = _ref1$sizes === void 0 ? {} : _ref1$sizes;
575
+ var _ref10 = sizes || {},
576
+ _ref10$medium = _ref10.medium,
577
+ medium = _ref10$medium === void 0 ? {} : _ref10$medium,
578
+ _ref10$large = _ref10.large,
579
+ large = _ref10$large === void 0 ? {} : _ref10$large;
580
+ var _ref11 = creditAuthor || {},
581
+ _ref11$name = _ref11.name,
582
+ authorName = _ref11$name === void 0 ? null : _ref11$name,
583
+ _ref11$image = _ref11.image,
584
+ authorImage = _ref11$image === void 0 ? null : _ref11$image;
572
585
  var finalArticleAuthor = _objectSpread(_objectSpread({}, authorName !== null ? {
573
586
  name: {
574
587
  body: "<p>".concat(authorName, "</p>")
@@ -581,11 +594,11 @@ var UrbaniaLoader = function UrbaniaLoader(_ref) {
581
594
  var defaultType = articleType || type;
582
595
 
583
596
  // Sponsors
584
- var defaultSponsor = (sponsors || []).length > 0 ? (sponsors || []).map(function (_ref13) {
585
- var _ref13$organisation = _ref13.organisation,
586
- _ref13$organisation2 = _ref13$organisation === void 0 ? {} : _ref13$organisation,
587
- _ref13$organisation2$ = _ref13$organisation2.name,
588
- name = _ref13$organisation2$ === void 0 ? null : _ref13$organisation2$;
597
+ var defaultSponsor = (sponsors || []).length > 0 ? (sponsors || []).map(function (_ref12) {
598
+ var _ref12$organisation = _ref12.organisation,
599
+ _ref12$organisation2 = _ref12$organisation === void 0 ? {} : _ref12$organisation,
600
+ _ref12$organisation2$ = _ref12$organisation2.name,
601
+ name = _ref12$organisation2$ === void 0 ? null : _ref12$organisation2$;
589
602
  return name;
590
603
  }).filter(function (name) {
591
604
  return name !== null;
@@ -643,9 +656,15 @@ var UrbaniaLoader = function UrbaniaLoader(_ref) {
643
656
  })
644
657
  })
645
658
  };
646
- }, [article, finalUrl, props]);
659
+ }, [article, url, title, finalUrl, props, articleType, overTitle, sponsorLabel, author, image, header, footer]);
660
+ var _ref13 = values || {},
661
+ _ref13$title = _ref13.title,
662
+ articleTitle = _ref13$title === void 0 ? null : _ref13$title;
663
+ var _ref14 = articleTitle || {},
664
+ _ref14$body = _ref14.body,
665
+ titleBody = _ref14$body === void 0 ? null : _ref14$body;
647
666
  return /*#__PURE__*/React.createElement(Component, Object.assign({}, props, values, {
648
- hasArticle: finalUrl !== null && article !== null
667
+ hasArticle: titleBody !== null
649
668
  }));
650
669
  };
651
670
  UrbaniaLoader.propTypes = propTypes$1;
@@ -1091,7 +1110,6 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
1091
1110
  setControlsSuggestPlay(true);
1092
1111
  }
1093
1112
  }, [isView, current, playing, isBackgroundVideo, setPlaying, setControlsSuggestPlay]);
1094
- console.log('hasUrl, hasArticle', hasUrl, hasArticle);
1095
1113
  return /*#__PURE__*/React.createElement("div", {
1096
1114
  className: classNames([styles.container, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, className, className !== null), styles.articleOpened, articleOpened), styles.isCurrent, current), styles.isPlaceholder, isPlaceholder)]),
1097
1115
  "data-screen-ready": isStatic || isCapture
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/screen-urbania-article",
3
- "version": "0.3.742",
3
+ "version": "0.3.744",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -63,19 +63,19 @@
63
63
  "@folklore/fetch": "^0.1.17",
64
64
  "@folklore/size": "^0.1.20",
65
65
  "@micromag/core": "^0.3.742",
66
- "@micromag/element-background": "^0.3.742",
66
+ "@micromag/element-background": "^0.3.743",
67
67
  "@micromag/element-button": "^0.3.742",
68
- "@micromag/element-closed-captions": "^0.3.742",
68
+ "@micromag/element-closed-captions": "^0.3.743",
69
69
  "@micromag/element-container": "^0.3.742",
70
- "@micromag/element-footer": "^0.3.742",
71
- "@micromag/element-header": "^0.3.742",
72
- "@micromag/element-heading": "^0.3.742",
70
+ "@micromag/element-footer": "^0.3.743",
71
+ "@micromag/element-header": "^0.3.743",
72
+ "@micromag/element-heading": "^0.3.743",
73
73
  "@micromag/element-image": "^0.3.742",
74
74
  "@micromag/element-layout": "^0.3.742",
75
- "@micromag/element-text": "^0.3.742",
76
- "@micromag/element-urbania-author": "^0.3.742",
77
- "@micromag/element-video": "^0.3.742",
78
- "@micromag/element-visual": "^0.3.742",
75
+ "@micromag/element-text": "^0.3.743",
76
+ "@micromag/element-urbania-author": "^0.3.743",
77
+ "@micromag/element-video": "^0.3.743",
78
+ "@micromag/element-visual": "^0.3.743",
79
79
  "@micromag/transforms": "^0.3.742",
80
80
  "@react-spring/web": "^9.6.1",
81
81
  "@use-gesture/react": "^10.3.0",
@@ -90,5 +90,5 @@
90
90
  "access": "public",
91
91
  "registry": "https://registry.npmjs.org/"
92
92
  },
93
- "gitHead": "6d91233414c1db0bd803e405210418d05064714c"
93
+ "gitHead": "44104ef3b161bec4ad6d4e7fc41723df053513a0"
94
94
  }