@micromag/screen-urbania-article 0.3.744 → 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.
- package/es/index.js +35 -99
- package/package.json +2 -2
package/es/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { PropTypes as PropTypes$1 } from '@micromag/core';
|
|
|
9
9
|
import { isTextFilled, isHeaderFilled, isFooterFilled, getFooterProps, getStyleFromColor, isValidUrl } from '@micromag/core/utils';
|
|
10
10
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
11
11
|
import classNames from 'classnames';
|
|
12
|
-
import { ScreenElement, Empty, PlaceholderSubtitle, PlaceholderTitle, PlaceholderImage, PlaceholderText
|
|
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 = {
|
|
@@ -582,7 +581,8 @@ var UrbaniaLoader = function UrbaniaLoader(_ref) {
|
|
|
582
581
|
authorName = _ref11$name === void 0 ? null : _ref11$name,
|
|
583
582
|
_ref11$image = _ref11.image,
|
|
584
583
|
authorImage = _ref11$image === void 0 ? null : _ref11$image;
|
|
585
|
-
var
|
|
584
|
+
var hasCreditAuthorName = authorName !== null && authorName !== '';
|
|
585
|
+
var finalArticleAuthor = _objectSpread(_objectSpread({}, hasCreditAuthorName ? {
|
|
586
586
|
name: {
|
|
587
587
|
body: "<p>".concat(authorName, "</p>")
|
|
588
588
|
}
|
|
@@ -608,6 +608,7 @@ var UrbaniaLoader = function UrbaniaLoader(_ref) {
|
|
|
608
608
|
var hasTitle = isTextFilled(title);
|
|
609
609
|
var hasOverTitle = isTextFilled(overTitle);
|
|
610
610
|
var hasSponsorProps = isTextFilled(sponsorLabel);
|
|
611
|
+
var hasAuthorProps = author !== null && author.name !== null && isTextFilled(author.name);
|
|
611
612
|
var sponsorPrefix = !hasSponsorProps && defaultSponsor !== null ? /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
612
613
|
id: "+TPjd4",
|
|
613
614
|
defaultMessage: [{
|
|
@@ -624,7 +625,7 @@ var UrbaniaLoader = function UrbaniaLoader(_ref) {
|
|
|
624
625
|
overTitle: hasOverTitle ? overTitle : _objectSpread(_objectSpread({}, overTitle), {}, {
|
|
625
626
|
body: 'En vedette'
|
|
626
627
|
}),
|
|
627
|
-
author: _objectSpread(_objectSpread({}, finalArticleAuthor), author),
|
|
628
|
+
author: _objectSpread(_objectSpread({}, finalArticleAuthor), hasAuthorProps ? author : null),
|
|
628
629
|
sponsors: defaultSponsor !== null && !hasSponsorProps ? [_objectSpread(_objectSpread({}, sponsorLabel), {}, {
|
|
629
630
|
body: "<strong>".concat(defaultSponsor, "</strong>")
|
|
630
631
|
})] : [sponsorLabel],
|
|
@@ -855,7 +856,7 @@ var definition = {
|
|
|
855
856
|
}]
|
|
856
857
|
};
|
|
857
858
|
|
|
858
|
-
var styles = {"container":"micromag-screen-urbania-article-urbania-base-article-card-container","
|
|
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"};
|
|
859
860
|
|
|
860
861
|
var propTypes = {
|
|
861
862
|
hasArticle: PropTypes.bool,
|
|
@@ -923,7 +924,9 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
|
|
|
923
924
|
var _useViewerWebView = useViewerWebView(),
|
|
924
925
|
openWebView = _useViewerWebView.open,
|
|
925
926
|
_useViewerWebView$ope = _useViewerWebView.opened,
|
|
926
|
-
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;
|
|
927
930
|
var _useViewerContext = useViewerContext(),
|
|
928
931
|
viewerTopHeight = _useViewerContext.topHeight,
|
|
929
932
|
viewerBottomHeight = _useViewerContext.bottomHeight;
|
|
@@ -956,42 +959,14 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
|
|
|
956
959
|
_ref: 'micromag'
|
|
957
960
|
}, currentQueryString))) : url;
|
|
958
961
|
}, [hasUrl, url]);
|
|
959
|
-
var _useState = useState(false),
|
|
960
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
961
|
-
articleOpened = _useState2[0],
|
|
962
|
-
setArticleOpened = _useState2[1];
|
|
963
|
-
var _useState3 = useState(false),
|
|
964
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
965
|
-
iframeEnabled = _useState4[0],
|
|
966
|
-
setIframeEnabled = _useState4[1];
|
|
967
|
-
var _useState5 = useState(false),
|
|
968
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
969
|
-
iframeMounted = _useState6[0],
|
|
970
|
-
setIframeMounted = _useState6[1];
|
|
971
|
-
var _useState7 = useState(false),
|
|
972
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
973
|
-
iframeLoaded = _useState8[0],
|
|
974
|
-
setIframeLoaded = _useState8[1];
|
|
975
962
|
var mediaShouldLoad = current || preload;
|
|
976
|
-
var backgroundPlaying = current && (isView || isEdit)
|
|
977
|
-
var mediaRef = usePlaybackMediaRef(current && !
|
|
978
|
-
|
|
979
|
-
// @TODO: collapsed card the height of articlePreview
|
|
980
|
-
// const articlePreviewRef = useRef();
|
|
981
|
-
// const previewCurrent = articlePreviewRef.current || null;
|
|
982
|
-
|
|
983
|
-
// const articlePreviewHeight = useMemo(() => {
|
|
984
|
-
// if (previewCurrent !== null) {
|
|
985
|
-
// const { height: previewHeight = 0 } = previewCurrent.getBoundingClientRect();
|
|
986
|
-
// return previewHeight !== 0 ? previewHeight : 0;
|
|
987
|
-
// }
|
|
988
|
-
// return 0;
|
|
989
|
-
// }, [previewCurrent, height]);
|
|
963
|
+
var backgroundPlaying = current && (isView || isEdit);
|
|
964
|
+
var mediaRef = usePlaybackMediaRef(current && !webviewOpened);
|
|
990
965
|
|
|
991
966
|
// card animations
|
|
992
|
-
var withCardAnimation = !isPlaceholder && !isPreview && !isStatic
|
|
967
|
+
var withCardAnimation = !isPlaceholder && !isPreview && !isStatic;
|
|
993
968
|
var slideInDelay = withCardAnimation && isBackgroundVideo && backgroundPlaying;
|
|
994
|
-
var withCardBounce = withCardAnimation && current && !
|
|
969
|
+
var withCardBounce = withCardAnimation && current && !webviewOpened;
|
|
995
970
|
useEffect(function () {
|
|
996
971
|
if (!current) {
|
|
997
972
|
return function () {};
|
|
@@ -999,54 +974,38 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
|
|
|
999
974
|
setControlsTheme({
|
|
1000
975
|
seekBarOnly: true
|
|
1001
976
|
});
|
|
1002
|
-
if (isBackgroundVideo && !
|
|
977
|
+
if (isBackgroundVideo && !webviewOpened) {
|
|
1003
978
|
setControls(true);
|
|
1004
979
|
} else {
|
|
1005
980
|
setControls(false);
|
|
1006
981
|
}
|
|
1007
982
|
return function () {
|
|
1008
|
-
if (isBackgroundVideo && !
|
|
983
|
+
if (isBackgroundVideo && !webviewOpened) {
|
|
1009
984
|
setControls(false);
|
|
1010
985
|
}
|
|
1011
986
|
};
|
|
1012
|
-
}, [current, setControls, isBackgroundVideo,
|
|
987
|
+
}, [current, setControls, isBackgroundVideo, webviewOpened, setControls, setControlsTheme]);
|
|
1013
988
|
var toggleCard = useCallback(function () {
|
|
1014
|
-
var newOpened = !
|
|
989
|
+
var newOpened = !webviewOpened;
|
|
1015
990
|
if (newOpened) {
|
|
1016
991
|
openWebView(finalUrl);
|
|
992
|
+
disableInteraction();
|
|
993
|
+
} else {
|
|
994
|
+
enableInteraction();
|
|
1017
995
|
}
|
|
1018
|
-
|
|
1019
|
-
// if (newOpened) {
|
|
1020
|
-
// disableInteraction();
|
|
1021
|
-
// } else {
|
|
1022
|
-
// enableInteraction();
|
|
1023
|
-
// }
|
|
1024
|
-
|
|
1025
|
-
// setIframeMounted(true);
|
|
1026
|
-
}, [articleOpened, setIframeMounted, disableInteraction, enableInteraction, openWebView, finalUrl]);
|
|
1027
|
-
useEffect(function () {
|
|
1028
|
-
if (!iframeMounted || iframeLoaded) {
|
|
1029
|
-
return function () {};
|
|
1030
|
-
}
|
|
1031
|
-
var timeout = setTimeout(function () {
|
|
1032
|
-
setIframeLoaded(true);
|
|
1033
|
-
}, 2000);
|
|
1034
|
-
return function () {
|
|
1035
|
-
clearTimeout(timeout);
|
|
1036
|
-
};
|
|
1037
|
-
}, [iframeMounted, iframeLoaded]);
|
|
996
|
+
}, [webviewOpened, disableInteraction, enableInteraction, openWebView, finalUrl]);
|
|
1038
997
|
var bindGesture = useGesture({
|
|
1039
998
|
onDrag: function onDrag(_ref4) {
|
|
1040
999
|
var _ref4$movement = _slicedToArray(_ref4.movement, 2),
|
|
1041
1000
|
my = _ref4$movement[1];
|
|
1042
|
-
if (!
|
|
1001
|
+
if (!webviewOpened && my < 0 || webviewOpened && my > 0) {
|
|
1043
1002
|
toggleCard();
|
|
1044
1003
|
}
|
|
1045
1004
|
},
|
|
1046
1005
|
onWheel: function onWheel(_ref5) {
|
|
1047
1006
|
var _ref5$movement = _slicedToArray(_ref5.movement, 2),
|
|
1048
1007
|
my = _ref5$movement[1];
|
|
1049
|
-
if (!
|
|
1008
|
+
if (!webviewOpened && my > 0 || webviewOpened && my < 0) {
|
|
1050
1009
|
toggleCard();
|
|
1051
1010
|
}
|
|
1052
1011
|
}
|
|
@@ -1061,7 +1020,7 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
|
|
|
1061
1020
|
}
|
|
1062
1021
|
});
|
|
1063
1022
|
var _useResizeObserver = useResizeObserver({
|
|
1064
|
-
disabled: !
|
|
1023
|
+
disabled: !webviewOpened
|
|
1065
1024
|
}),
|
|
1066
1025
|
articlePreviewRef = _useResizeObserver.ref,
|
|
1067
1026
|
_useResizeObserver$en = _useResizeObserver.entry.contentRect,
|
|
@@ -1069,11 +1028,11 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
|
|
|
1069
1028
|
var _ref6 = articlePreviewContentRect || {},
|
|
1070
1029
|
_ref6$height = _ref6.height,
|
|
1071
1030
|
articlePreviewHeight = _ref6$height === void 0 ? 0 : _ref6$height;
|
|
1031
|
+
|
|
1032
|
+
// Think about this
|
|
1072
1033
|
var minimumVisibility = 20;
|
|
1073
1034
|
var y = 100;
|
|
1074
|
-
if (current
|
|
1075
|
-
y = 0;
|
|
1076
|
-
} else if (current || isPreview) {
|
|
1035
|
+
if (current) {
|
|
1077
1036
|
y = 100 - Math.max(articlePreviewHeight / height * 100, minimumVisibility);
|
|
1078
1037
|
}
|
|
1079
1038
|
var springStyle = useSpring({
|
|
@@ -1083,14 +1042,6 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
|
|
|
1083
1042
|
to: {
|
|
1084
1043
|
y: y
|
|
1085
1044
|
},
|
|
1086
|
-
onStart: function onStart() {
|
|
1087
|
-
setIframeEnabled(false);
|
|
1088
|
-
},
|
|
1089
|
-
onResolve: function onResolve() {
|
|
1090
|
-
if (articleOpened) {
|
|
1091
|
-
setIframeEnabled(true);
|
|
1092
|
-
}
|
|
1093
|
-
},
|
|
1094
1045
|
delay: slideInDelay ? 1500 : 0,
|
|
1095
1046
|
config: {
|
|
1096
1047
|
easing: easings.easeInOutSine,
|
|
@@ -1098,12 +1049,10 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
|
|
|
1098
1049
|
}
|
|
1099
1050
|
});
|
|
1100
1051
|
useEffect(function () {
|
|
1101
|
-
if (!current) {
|
|
1102
|
-
|
|
1103
|
-
setIframeMounted(false);
|
|
1104
|
-
setIframeLoaded(false);
|
|
1052
|
+
if (!current && closeWebView !== null) {
|
|
1053
|
+
closeWebView();
|
|
1105
1054
|
}
|
|
1106
|
-
}, [current]);
|
|
1055
|
+
}, [current, closeWebView]);
|
|
1107
1056
|
var onPlayError = useCallback(function () {
|
|
1108
1057
|
if (isView && playing && current && isBackgroundVideo) {
|
|
1109
1058
|
setPlaying(false);
|
|
@@ -1111,7 +1060,7 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
|
|
|
1111
1060
|
}
|
|
1112
1061
|
}, [isView, current, playing, isBackgroundVideo, setPlaying, setControlsSuggestPlay]);
|
|
1113
1062
|
return /*#__PURE__*/React.createElement("div", {
|
|
1114
|
-
className: classNames([styles.container, _defineProperty(_defineProperty(_defineProperty(
|
|
1063
|
+
className: classNames([styles.container, _defineProperty(_defineProperty(_defineProperty({}, className, className !== null), styles.isCurrent, current), styles.isPlaceholder, isPlaceholder)]),
|
|
1115
1064
|
"data-screen-ready": isStatic || isCapture
|
|
1116
1065
|
}, /*#__PURE__*/React.createElement(Background, {
|
|
1117
1066
|
className: styles.background,
|
|
@@ -1185,7 +1134,7 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
|
|
|
1185
1134
|
type: "button",
|
|
1186
1135
|
onClick: toggleCard,
|
|
1187
1136
|
className: styles.dragHandle,
|
|
1188
|
-
tabIndex: !current
|
|
1137
|
+
tabIndex: !current ? -1 : 0,
|
|
1189
1138
|
"aria-label": intl.formatMessage({
|
|
1190
1139
|
id: "IoMJgw",
|
|
1191
1140
|
defaultMessage: [{
|
|
@@ -1193,7 +1142,7 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
|
|
|
1193
1142
|
"value": "Toggle article"
|
|
1194
1143
|
}]
|
|
1195
1144
|
}),
|
|
1196
|
-
"aria-pressed":
|
|
1145
|
+
"aria-pressed": webviewOpened
|
|
1197
1146
|
}, current ? bindGesture() : null)), /*#__PURE__*/React.createElement("div", {
|
|
1198
1147
|
className: classNames([styles.cardInner, _defineProperty({}, styles.pulse, withCardBounce)])
|
|
1199
1148
|
}, hasCta ? /*#__PURE__*/React.createElement("div", {
|
|
@@ -1203,14 +1152,7 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
|
|
|
1203
1152
|
className: styles.arrow
|
|
1204
1153
|
}), /*#__PURE__*/React.createElement(Text, Object.assign({
|
|
1205
1154
|
className: styles.ctaText
|
|
1206
|
-
}, callToAction))) : null, /*#__PURE__*/React.createElement(
|
|
1207
|
-
className: styles.close,
|
|
1208
|
-
disabled: !current || !articleOpened,
|
|
1209
|
-
onClick: toggleCard
|
|
1210
|
-
}, /*#__PURE__*/React.createElement(Close, {
|
|
1211
|
-
color: "#000",
|
|
1212
|
-
className: styles.closeIcon
|
|
1213
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
1155
|
+
}, callToAction))) : null, /*#__PURE__*/React.createElement("div", {
|
|
1214
1156
|
className: styles.articlePreview,
|
|
1215
1157
|
ref: articlePreviewRef
|
|
1216
1158
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -1225,13 +1167,7 @@ var UrbaniaArticleCard = function UrbaniaArticleCard(_ref) {
|
|
|
1225
1167
|
withoutBackground: true,
|
|
1226
1168
|
author: author,
|
|
1227
1169
|
shouldLoad: mediaShouldLoad
|
|
1228
|
-
}) : null))
|
|
1229
|
-
className: styles.spinnerContainer
|
|
1230
|
-
}, /*#__PURE__*/React.createElement(Spinner, {
|
|
1231
|
-
className: styles.spinner
|
|
1232
|
-
})) : null, !iframeEnabled && iframeMounted ? /*#__PURE__*/React.createElement("div", {
|
|
1233
|
-
className: styles.iframeBlocker
|
|
1234
|
-
}) : null)) : null))));
|
|
1170
|
+
}) : null)))) : null))));
|
|
1235
1171
|
};
|
|
1236
1172
|
UrbaniaArticleCard.defaultProps = defaultProps;
|
|
1237
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.
|
|
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": "
|
|
93
|
+
"gitHead": "6b12b65d4e32b0e3ab33586373176589a6d7d27e"
|
|
94
94
|
}
|