@micromag/screen-urbania-article 0.3.743 → 0.3.745

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 +146 -192
  2. package/package.json +2 -2
package/es/index.js CHANGED
@@ -5,11 +5,11 @@ 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
- import { ScreenElement, Empty, PlaceholderSubtitle, PlaceholderTitle, PlaceholderImage, PlaceholderText, Close, Spinner } from '@micromag/core/components';
12
+ import { ScreenElement, Empty, PlaceholderSubtitle, PlaceholderTitle, PlaceholderImage, PlaceholderText } 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';
15
15
  import Background from '@micromag/element-background';
@@ -24,7 +24,6 @@ import { useSpring, easings, animated } from '@react-spring/web';
24
24
  import { useGesture } from '@use-gesture/react';
25
25
  import isString from 'lodash/isString';
26
26
  import queryString from 'query-string';
27
- import Button from '@micromag/element-button';
28
27
  import Layout from '@micromag/element-layout';
29
28
 
30
29
  var propTypes$4 = {
@@ -455,10 +454,22 @@ var UrbaniaArticle = function UrbaniaArticle(_ref) {
455
454
  UrbaniaArticle.propTypes = propTypes$2;
456
455
  UrbaniaArticle.defaultProps = defaultProps$2;
457
456
 
458
- var _excluded = ["component", "theme", "url", "article"];
457
+ var _excluded = ["component", "title", "articleType", "overTitle", "sponsorLabel", "author", "image", "header", "footer", "url", "article"];
459
458
  var propTypes$1 = {
460
459
  component: PropTypes.elementType,
461
- theme: PropTypes.string,
460
+ // theme: PropTypes.string,
461
+ title: PropTypes$1.headingElement,
462
+ articleType: PropTypes.string,
463
+ overTitle: PropTypes.shape({
464
+ body: PropTypes.string
465
+ }),
466
+ sponsorLabel: PropTypes.shape({
467
+ body: PropTypes.string
468
+ }),
469
+ author: PropTypes$1.authorElement,
470
+ image: PropTypes$1.image,
471
+ header: PropTypes$1.header,
472
+ footer: PropTypes$1.footer,
462
473
  url: PropTypes.string,
463
474
  article: PropTypes.shape({
464
475
  type: PropTypes.string
@@ -466,110 +477,112 @@ var propTypes$1 = {
466
477
  };
467
478
  var defaultProps$1 = {
468
479
  component: UrbaniaArticle,
469
- theme: null,
480
+ // theme: null,
481
+ title: null,
482
+ articleType: null,
483
+ overTitle: null,
484
+ sponsorLabel: null,
485
+ author: null,
486
+ image: null,
487
+ header: null,
488
+ footer: null,
470
489
  url: null,
471
490
  article: null
472
491
  };
473
492
  var UrbaniaLoader = function UrbaniaLoader(_ref) {
474
- var Component = _ref.component;
475
- _ref.theme;
476
- var url = _ref.url,
493
+ var Component = _ref.component,
494
+ _ref$title = _ref.title,
495
+ title = _ref$title === void 0 ? null : _ref$title,
496
+ _ref$articleType = _ref.articleType,
497
+ articleType = _ref$articleType === void 0 ? null : _ref$articleType,
498
+ _ref$overTitle = _ref.overTitle,
499
+ overTitle = _ref$overTitle === void 0 ? null : _ref$overTitle,
500
+ _ref$sponsorLabel = _ref.sponsorLabel,
501
+ sponsorLabel = _ref$sponsorLabel === void 0 ? null : _ref$sponsorLabel,
502
+ _ref$author = _ref.author,
503
+ author = _ref$author === void 0 ? null : _ref$author,
504
+ _ref$image = _ref.image,
505
+ image = _ref$image === void 0 ? null : _ref$image,
506
+ _ref$header = _ref.header,
507
+ header = _ref$header === void 0 ? null : _ref$header,
508
+ _ref$footer = _ref.footer,
509
+ footer = _ref$footer === void 0 ? null : _ref$footer,
510
+ _ref$url = _ref.url,
511
+ url = _ref$url === void 0 ? null : _ref$url,
477
512
  initialArticle = _ref.article,
478
513
  props = _objectWithoutProperties(_ref, _excluded);
479
514
  var _useState = useState(initialArticle),
480
515
  _useState2 = _slicedToArray(_useState, 2),
481
516
  article = _useState2[0],
482
517
  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;
518
+ var finalUrl = url !== null && isValidUrl(url) ? url.replace(/^https?:\/\/([^.]+\.)?urbania\.(ca|ƒr)\//, 'https://urbania.$2/') : null;
492
519
  useEffect(function () {
493
- if (finalUrl !== null && isValidUrl(finalUrl)) {
520
+ if (finalUrl !== null) {
494
521
  getJSON("https://api.urbania.ca/documents?uri=".concat(finalUrl), {
495
522
  mode: 'cors'
496
523
  }).then(function (art) {
524
+ console.log('art loaded', art);
497
525
  setArticle(art || null);
498
- })["catch"](function () {
499
- return setArticle(null);
526
+ })["catch"](function (e) {
527
+ console.log('art error', e);
528
+ setArticle(null);
500
529
  });
501
530
  }
502
- }, [finalUrl, setArticle]);
531
+ }, [url, finalUrl, setArticle]);
503
532
  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;
533
+ var _ref2 = image || {},
534
+ _ref2$url = _ref2.url,
535
+ imageUrl = _ref2$url === void 0 ? null : _ref2$url;
536
+ var _ref3 = footer || {},
537
+ _ref3$callToAction = _ref3.callToAction,
538
+ callToAction = _ref3$callToAction === void 0 ? null : _ref3$callToAction;
539
+ var _ref4 = callToAction || {},
540
+ _ref4$url = _ref4.url,
541
+ ctaUrl = _ref4$url === void 0 ? null : _ref4$url;
530
542
 
531
543
  // 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;
544
+ var _ref5 = article || {},
545
+ _ref5$type = _ref5.type,
546
+ type = _ref5$type === void 0 ? null : _ref5$type,
547
+ _ref5$title = _ref5.title,
548
+ articleTitle = _ref5$title === void 0 ? null : _ref5$title,
549
+ _ref5$image = _ref5.image,
550
+ articleImage = _ref5$image === void 0 ? null : _ref5$image,
551
+ _ref5$metadata = _ref5.metadata,
552
+ metadata = _ref5$metadata === void 0 ? {} : _ref5$metadata;
541
553
  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;
572
- var finalArticleAuthor = _objectSpread(_objectSpread({}, authorName !== null ? {
554
+ var _ref6 = metadata || {},
555
+ _ref6$authors = _ref6.authors,
556
+ authors = _ref6$authors === void 0 ? [] : _ref6$authors,
557
+ _ref6$sponsors = _ref6.sponsors,
558
+ sponsors = _ref6$sponsors === void 0 ? [] : _ref6$sponsors,
559
+ _ref6$brands = _ref6.brands,
560
+ brands = _ref6$brands === void 0 ? [] : _ref6$brands;
561
+ var _ref7 = authors || [],
562
+ _ref8 = _slicedToArray(_ref7, 1),
563
+ _ref8$ = _ref8[0],
564
+ creditAuthor = _ref8$ === void 0 ? null : _ref8$;
565
+ var _ref9 = brands || [],
566
+ _ref0 = _slicedToArray(_ref9, 1),
567
+ _ref0$ = _ref0[0],
568
+ _ref0$2 = _ref0$ === void 0 ? {} : _ref0$,
569
+ _ref0$2$handle = _ref0$2.handle,
570
+ site = _ref0$2$handle === void 0 ? null : _ref0$2$handle;
571
+ var _ref1 = articleImage || {},
572
+ _ref1$sizes = _ref1.sizes,
573
+ sizes = _ref1$sizes === void 0 ? {} : _ref1$sizes;
574
+ var _ref10 = sizes || {},
575
+ _ref10$medium = _ref10.medium,
576
+ medium = _ref10$medium === void 0 ? {} : _ref10$medium,
577
+ _ref10$large = _ref10.large,
578
+ large = _ref10$large === void 0 ? {} : _ref10$large;
579
+ var _ref11 = creditAuthor || {},
580
+ _ref11$name = _ref11.name,
581
+ authorName = _ref11$name === void 0 ? null : _ref11$name,
582
+ _ref11$image = _ref11.image,
583
+ authorImage = _ref11$image === void 0 ? null : _ref11$image;
584
+ var hasCreditAuthorName = authorName !== null && authorName !== '';
585
+ var finalArticleAuthor = _objectSpread(_objectSpread({}, hasCreditAuthorName ? {
573
586
  name: {
574
587
  body: "<p>".concat(authorName, "</p>")
575
588
  }
@@ -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;
@@ -595,6 +608,7 @@ var UrbaniaLoader = function UrbaniaLoader(_ref) {
595
608
  var hasTitle = isTextFilled(title);
596
609
  var hasOverTitle = isTextFilled(overTitle);
597
610
  var hasSponsorProps = isTextFilled(sponsorLabel);
611
+ var hasAuthorProps = author !== null && author.name !== null && isTextFilled(author.name);
598
612
  var sponsorPrefix = !hasSponsorProps && defaultSponsor !== null ? /*#__PURE__*/React.createElement(FormattedMessage, {
599
613
  id: "+TPjd4",
600
614
  defaultMessage: [{
@@ -611,7 +625,7 @@ var UrbaniaLoader = function UrbaniaLoader(_ref) {
611
625
  overTitle: hasOverTitle ? overTitle : _objectSpread(_objectSpread({}, overTitle), {}, {
612
626
  body: 'En vedette'
613
627
  }),
614
- author: _objectSpread(_objectSpread({}, finalArticleAuthor), author),
628
+ author: _objectSpread(_objectSpread({}, finalArticleAuthor), hasAuthorProps ? author : null),
615
629
  sponsors: defaultSponsor !== null && !hasSponsorProps ? [_objectSpread(_objectSpread({}, sponsorLabel), {}, {
616
630
  body: "<strong>".concat(defaultSponsor, "</strong>")
617
631
  })] : [sponsorLabel],
@@ -643,9 +657,15 @@ var UrbaniaLoader = function UrbaniaLoader(_ref) {
643
657
  })
644
658
  })
645
659
  };
646
- }, [article, finalUrl, props]);
660
+ }, [article, url, title, finalUrl, props, articleType, overTitle, sponsorLabel, author, image, header, footer]);
661
+ var _ref13 = values || {},
662
+ _ref13$title = _ref13.title,
663
+ articleTitle = _ref13$title === void 0 ? null : _ref13$title;
664
+ var _ref14 = articleTitle || {},
665
+ _ref14$body = _ref14.body,
666
+ titleBody = _ref14$body === void 0 ? null : _ref14$body;
647
667
  return /*#__PURE__*/React.createElement(Component, Object.assign({}, props, values, {
648
- hasArticle: finalUrl !== null && article !== null
668
+ hasArticle: titleBody !== null
649
669
  }));
650
670
  };
651
671
  UrbaniaLoader.propTypes = propTypes$1;
@@ -836,7 +856,7 @@ var definition = {
836
856
  }]
837
857
  };
838
858
 
839
- var styles = {"container":"micromag-screen-urbania-article-urbania-base-article-card-container","close":"micromag-screen-urbania-article-urbania-base-article-card-close","dragHandle":"micromag-screen-urbania-article-urbania-base-article-card-dragHandle","empty":"micromag-screen-urbania-article-urbania-base-article-card-empty","cardContainer":"micromag-screen-urbania-article-urbania-base-article-card-cardContainer","content":"micromag-screen-urbania-article-urbania-base-article-card-content","placeholder":"micromag-screen-urbania-article-urbania-base-article-card-placeholder","background":"micromag-screen-urbania-article-urbania-base-article-card-background","layout":"micromag-screen-urbania-article-urbania-base-article-card-layout","text":"micromag-screen-urbania-article-urbania-base-article-card-text","isPlaceholder":"micromag-screen-urbania-article-urbania-base-article-card-isPlaceholder","card":"micromag-screen-urbania-article-urbania-base-article-card-card","callToAction":"micromag-screen-urbania-article-urbania-base-article-card-callToAction","arrow":"micromag-screen-urbania-article-urbania-base-article-card-arrow","ctaText":"micromag-screen-urbania-article-urbania-base-article-card-ctaText","cardInner":"micromag-screen-urbania-article-urbania-base-article-card-cardInner","pulse":"micromag-screen-urbania-article-urbania-base-article-card-pulse","closeIcon":"micromag-screen-urbania-article-urbania-base-article-card-closeIcon","articlePreview":"micromag-screen-urbania-article-urbania-base-article-card-articlePreview","articlePreviewInner":"micromag-screen-urbania-article-urbania-base-article-card-articlePreviewInner","articleTitle":"micromag-screen-urbania-article-urbania-base-article-card-articleTitle","spinnerContainer":"micromag-screen-urbania-article-urbania-base-article-card-spinnerContainer","spinner":"micromag-screen-urbania-article-urbania-base-article-card-spinner","header":"micromag-screen-urbania-article-urbania-base-article-card-header","iframeBlocker":"micromag-screen-urbania-article-urbania-base-article-card-iframeBlocker","articleOpened":"micromag-screen-urbania-article-urbania-base-article-card-articleOpened"};
859
+ var styles = {"container":"micromag-screen-urbania-article-urbania-base-article-card-container","dragHandle":"micromag-screen-urbania-article-urbania-base-article-card-dragHandle","empty":"micromag-screen-urbania-article-urbania-base-article-card-empty","cardContainer":"micromag-screen-urbania-article-urbania-base-article-card-cardContainer","content":"micromag-screen-urbania-article-urbania-base-article-card-content","placeholder":"micromag-screen-urbania-article-urbania-base-article-card-placeholder","background":"micromag-screen-urbania-article-urbania-base-article-card-background","layout":"micromag-screen-urbania-article-urbania-base-article-card-layout","text":"micromag-screen-urbania-article-urbania-base-article-card-text","isPlaceholder":"micromag-screen-urbania-article-urbania-base-article-card-isPlaceholder","card":"micromag-screen-urbania-article-urbania-base-article-card-card","callToAction":"micromag-screen-urbania-article-urbania-base-article-card-callToAction","arrow":"micromag-screen-urbania-article-urbania-base-article-card-arrow","ctaText":"micromag-screen-urbania-article-urbania-base-article-card-ctaText","cardInner":"micromag-screen-urbania-article-urbania-base-article-card-cardInner","pulse":"micromag-screen-urbania-article-urbania-base-article-card-pulse","articlePreview":"micromag-screen-urbania-article-urbania-base-article-card-articlePreview","articlePreviewInner":"micromag-screen-urbania-article-urbania-base-article-card-articlePreviewInner","articleTitle":"micromag-screen-urbania-article-urbania-base-article-card-articleTitle","header":"micromag-screen-urbania-article-urbania-base-article-card-header"};
840
860
 
841
861
  var propTypes = {
842
862
  hasArticle: PropTypes.bool,
@@ -904,7 +924,9 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
904
924
  var _useViewerWebView = useViewerWebView(),
905
925
  openWebView = _useViewerWebView.open,
906
926
  _useViewerWebView$ope = _useViewerWebView.opened,
907
- webviewOpened = _useViewerWebView$ope === void 0 ? false : _useViewerWebView$ope;
927
+ webviewOpened = _useViewerWebView$ope === void 0 ? false : _useViewerWebView$ope,
928
+ _useViewerWebView$clo = _useViewerWebView.close,
929
+ closeWebView = _useViewerWebView$clo === void 0 ? null : _useViewerWebView$clo;
908
930
  var _useViewerContext = useViewerContext(),
909
931
  viewerTopHeight = _useViewerContext.topHeight,
910
932
  viewerBottomHeight = _useViewerContext.bottomHeight;
@@ -937,42 +959,14 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
937
959
  _ref: 'micromag'
938
960
  }, currentQueryString))) : url;
939
961
  }, [hasUrl, url]);
940
- var _useState = useState(false),
941
- _useState2 = _slicedToArray(_useState, 2),
942
- articleOpened = _useState2[0],
943
- setArticleOpened = _useState2[1];
944
- var _useState3 = useState(false),
945
- _useState4 = _slicedToArray(_useState3, 2),
946
- iframeEnabled = _useState4[0],
947
- setIframeEnabled = _useState4[1];
948
- var _useState5 = useState(false),
949
- _useState6 = _slicedToArray(_useState5, 2),
950
- iframeMounted = _useState6[0],
951
- setIframeMounted = _useState6[1];
952
- var _useState7 = useState(false),
953
- _useState8 = _slicedToArray(_useState7, 2),
954
- iframeLoaded = _useState8[0],
955
- setIframeLoaded = _useState8[1];
956
962
  var mediaShouldLoad = current || preload;
957
- var backgroundPlaying = current && (isView || isEdit) && !articleOpened;
958
- var mediaRef = usePlaybackMediaRef(current && !articleOpened);
959
-
960
- // @TODO: collapsed card the height of articlePreview
961
- // const articlePreviewRef = useRef();
962
- // const previewCurrent = articlePreviewRef.current || null;
963
-
964
- // const articlePreviewHeight = useMemo(() => {
965
- // if (previewCurrent !== null) {
966
- // const { height: previewHeight = 0 } = previewCurrent.getBoundingClientRect();
967
- // return previewHeight !== 0 ? previewHeight : 0;
968
- // }
969
- // return 0;
970
- // }, [previewCurrent, height]);
963
+ var backgroundPlaying = current && (isView || isEdit);
964
+ var mediaRef = usePlaybackMediaRef(current && !webviewOpened);
971
965
 
972
966
  // card animations
973
- var withCardAnimation = !isPlaceholder && !isPreview && !isStatic && !iframeMounted;
967
+ var withCardAnimation = !isPlaceholder && !isPreview && !isStatic;
974
968
  var slideInDelay = withCardAnimation && isBackgroundVideo && backgroundPlaying;
975
- var withCardBounce = withCardAnimation && current && !articleOpened;
969
+ var withCardBounce = withCardAnimation && current && !webviewOpened;
976
970
  useEffect(function () {
977
971
  if (!current) {
978
972
  return function () {};
@@ -980,54 +974,38 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
980
974
  setControlsTheme({
981
975
  seekBarOnly: true
982
976
  });
983
- if (isBackgroundVideo && !articleOpened) {
977
+ if (isBackgroundVideo && !webviewOpened) {
984
978
  setControls(true);
985
979
  } else {
986
980
  setControls(false);
987
981
  }
988
982
  return function () {
989
- if (isBackgroundVideo && !articleOpened) {
983
+ if (isBackgroundVideo && !webviewOpened) {
990
984
  setControls(false);
991
985
  }
992
986
  };
993
- }, [current, setControls, isBackgroundVideo, articleOpened, setControls, setControlsTheme]);
987
+ }, [current, setControls, isBackgroundVideo, webviewOpened, setControls, setControlsTheme]);
994
988
  var toggleCard = useCallback(function () {
995
- var newOpened = !articleOpened;
989
+ var newOpened = !webviewOpened;
996
990
  if (newOpened) {
997
991
  openWebView(finalUrl);
992
+ disableInteraction();
993
+ } else {
994
+ enableInteraction();
998
995
  }
999
-
1000
- // if (newOpened) {
1001
- // disableInteraction();
1002
- // } else {
1003
- // enableInteraction();
1004
- // }
1005
-
1006
- // setIframeMounted(true);
1007
- }, [articleOpened, setIframeMounted, disableInteraction, enableInteraction, openWebView, finalUrl]);
1008
- useEffect(function () {
1009
- if (!iframeMounted || iframeLoaded) {
1010
- return function () {};
1011
- }
1012
- var timeout = setTimeout(function () {
1013
- setIframeLoaded(true);
1014
- }, 2000);
1015
- return function () {
1016
- clearTimeout(timeout);
1017
- };
1018
- }, [iframeMounted, iframeLoaded]);
996
+ }, [webviewOpened, disableInteraction, enableInteraction, openWebView, finalUrl]);
1019
997
  var bindGesture = useGesture({
1020
998
  onDrag: function onDrag(_ref4) {
1021
999
  var _ref4$movement = _slicedToArray(_ref4.movement, 2),
1022
1000
  my = _ref4$movement[1];
1023
- if (!articleOpened && my < 0 || articleOpened && my > 0) {
1001
+ if (!webviewOpened && my < 0 || webviewOpened && my > 0) {
1024
1002
  toggleCard();
1025
1003
  }
1026
1004
  },
1027
1005
  onWheel: function onWheel(_ref5) {
1028
1006
  var _ref5$movement = _slicedToArray(_ref5.movement, 2),
1029
1007
  my = _ref5$movement[1];
1030
- if (!articleOpened && my > 0 || articleOpened && my < 0) {
1008
+ if (!webviewOpened && my > 0 || webviewOpened && my < 0) {
1031
1009
  toggleCard();
1032
1010
  }
1033
1011
  }
@@ -1042,7 +1020,7 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
1042
1020
  }
1043
1021
  });
1044
1022
  var _useResizeObserver = useResizeObserver({
1045
- disabled: !articleOpened
1023
+ disabled: !webviewOpened
1046
1024
  }),
1047
1025
  articlePreviewRef = _useResizeObserver.ref,
1048
1026
  _useResizeObserver$en = _useResizeObserver.entry.contentRect,
@@ -1050,11 +1028,11 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
1050
1028
  var _ref6 = articlePreviewContentRect || {},
1051
1029
  _ref6$height = _ref6.height,
1052
1030
  articlePreviewHeight = _ref6$height === void 0 ? 0 : _ref6$height;
1031
+
1032
+ // Think about this
1053
1033
  var minimumVisibility = 20;
1054
1034
  var y = 100;
1055
- if (current && articleOpened) {
1056
- y = 0;
1057
- } else if (current || isPreview) {
1035
+ if (current) {
1058
1036
  y = 100 - Math.max(articlePreviewHeight / height * 100, minimumVisibility);
1059
1037
  }
1060
1038
  var springStyle = useSpring({
@@ -1064,14 +1042,6 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
1064
1042
  to: {
1065
1043
  y: y
1066
1044
  },
1067
- onStart: function onStart() {
1068
- setIframeEnabled(false);
1069
- },
1070
- onResolve: function onResolve() {
1071
- if (articleOpened) {
1072
- setIframeEnabled(true);
1073
- }
1074
- },
1075
1045
  delay: slideInDelay ? 1500 : 0,
1076
1046
  config: {
1077
1047
  easing: easings.easeInOutSine,
@@ -1079,21 +1049,18 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
1079
1049
  }
1080
1050
  });
1081
1051
  useEffect(function () {
1082
- if (!current) {
1083
- setArticleOpened(false);
1084
- setIframeMounted(false);
1085
- setIframeLoaded(false);
1052
+ if (!current && closeWebView !== null) {
1053
+ closeWebView();
1086
1054
  }
1087
- }, [current]);
1055
+ }, [current, closeWebView]);
1088
1056
  var onPlayError = useCallback(function () {
1089
1057
  if (isView && playing && current && isBackgroundVideo) {
1090
1058
  setPlaying(false);
1091
1059
  setControlsSuggestPlay(true);
1092
1060
  }
1093
1061
  }, [isView, current, playing, isBackgroundVideo, setPlaying, setControlsSuggestPlay]);
1094
- console.log('hasUrl, hasArticle', hasUrl, hasArticle);
1095
1062
  return /*#__PURE__*/React.createElement("div", {
1096
- className: classNames([styles.container, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, className, className !== null), styles.articleOpened, articleOpened), styles.isCurrent, current), styles.isPlaceholder, isPlaceholder)]),
1063
+ className: classNames([styles.container, _defineProperty(_defineProperty(_defineProperty({}, className, className !== null), styles.isCurrent, current), styles.isPlaceholder, isPlaceholder)]),
1097
1064
  "data-screen-ready": isStatic || isCapture
1098
1065
  }, /*#__PURE__*/React.createElement(Background, {
1099
1066
  className: styles.background,
@@ -1167,7 +1134,7 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
1167
1134
  type: "button",
1168
1135
  onClick: toggleCard,
1169
1136
  className: styles.dragHandle,
1170
- tabIndex: !current || articleOpened ? -1 : 0,
1137
+ tabIndex: !current ? -1 : 0,
1171
1138
  "aria-label": intl.formatMessage({
1172
1139
  id: "IoMJgw",
1173
1140
  defaultMessage: [{
@@ -1175,7 +1142,7 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
1175
1142
  "value": "Toggle article"
1176
1143
  }]
1177
1144
  }),
1178
- "aria-pressed": articleOpened
1145
+ "aria-pressed": webviewOpened
1179
1146
  }, current ? bindGesture() : null)), /*#__PURE__*/React.createElement("div", {
1180
1147
  className: classNames([styles.cardInner, _defineProperty({}, styles.pulse, withCardBounce)])
1181
1148
  }, hasCta ? /*#__PURE__*/React.createElement("div", {
@@ -1185,14 +1152,7 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
1185
1152
  className: styles.arrow
1186
1153
  }), /*#__PURE__*/React.createElement(Text, Object.assign({
1187
1154
  className: styles.ctaText
1188
- }, callToAction))) : null, /*#__PURE__*/React.createElement(Button, {
1189
- className: styles.close,
1190
- disabled: !current || !articleOpened,
1191
- onClick: toggleCard
1192
- }, /*#__PURE__*/React.createElement(Close, {
1193
- color: "#000",
1194
- className: styles.closeIcon
1195
- })), /*#__PURE__*/React.createElement("div", {
1155
+ }, callToAction))) : null, /*#__PURE__*/React.createElement("div", {
1196
1156
  className: styles.articlePreview,
1197
1157
  ref: articlePreviewRef
1198
1158
  }, /*#__PURE__*/React.createElement("div", {
@@ -1207,13 +1167,7 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
1207
1167
  withoutBackground: true,
1208
1168
  author: author,
1209
1169
  shouldLoad: mediaShouldLoad
1210
- }) : null)), iframeMounted && !iframeLoaded ? /*#__PURE__*/React.createElement("div", {
1211
- className: styles.spinnerContainer
1212
- }, /*#__PURE__*/React.createElement(Spinner, {
1213
- className: styles.spinner
1214
- })) : null, !iframeEnabled && iframeMounted ? /*#__PURE__*/React.createElement("div", {
1215
- className: styles.iframeBlocker
1216
- }) : null)) : null))));
1170
+ }) : null)))) : null))));
1217
1171
  };
1218
1172
  UrbaniaArticleCard.defaultProps = defaultProps;
1219
1173
  UrbaniaArticleCard.propTypes = propTypes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/screen-urbania-article",
3
- "version": "0.3.743",
3
+ "version": "0.3.745",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -90,5 +90,5 @@
90
90
  "access": "public",
91
91
  "registry": "https://registry.npmjs.org/"
92
92
  },
93
- "gitHead": "d6e73828c6a6218357c64a49b56ff7a0e6be885b"
93
+ "gitHead": "6b12b65d4e32b0e3ab33586373176589a6d7d27e"
94
94
  }