@micromag/element-call-to-action 0.3.88 → 0.3.94
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/assets/css/styles.css +1 -1
- package/es/index.js +24 -9
- package/lib/index.js +24 -9
- package/package.json +6 -6
package/assets/css/styles.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@-webkit-keyframes micromag-element-call-to-action-appear{0%{-webkit-transform:scale(0);transform:scale(0);opacity:
|
|
1
|
+
@-webkit-keyframes micromag-element-call-to-action-appear{0%{-webkit-transform:scale(0);transform:scale(0);opacity:1}to{-webkit-transform:scale(1);transform:scale(1);opacity:1}}@keyframes micromag-element-call-to-action-appear{0%{-webkit-transform:scale(0);transform:scale(0);opacity:1}to{-webkit-transform:scale(1);transform:scale(1);opacity:1}}.micromag-element-call-to-action-container{position:relative;padding-bottom:5px;-webkit-transition:opacity .3s ease;-o-transition:opacity .3s ease;transition:opacity .3s ease;opacity:1;text-align:center}.micromag-element-call-to-action-container .micromag-element-call-to-action-arrow{display:block;margin:0 auto 3px;-webkit-animation:micromag-element-call-to-action-upAndDown .5s ease-in-out infinite alternate;animation:micromag-element-call-to-action-upAndDown .5s ease-in-out infinite alternate}.micromag-element-call-to-action-container .micromag-element-call-to-action-icon,.micromag-element-call-to-action-container .micromag-element-call-to-action-label{display:inline-block}.micromag-element-call-to-action-container .micromag-element-call-to-action-label{line-height:1}.micromag-element-call-to-action-container .micromag-element-call-to-action-button{display:block;margin:0 auto;padding:5px 10px;background-color:rgba(0,0,0,0);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-ms-touch-action:none;touch-action:none;-webkit-user-drag:none}.micromag-element-call-to-action-container .micromag-element-call-to-action-button:hover{text-decoration:none}.micromag-element-call-to-action-container .micromag-element-call-to-action-selfTargetLink{display:none}.micromag-element-call-to-action-container .micromag-element-call-to-action-leavingFrame{position:fixed;top:0;left:0;width:100vw;height:100vh;-webkit-transform:scale(0);-ms-transform:scale(0);transform:scale(0);-webkit-animation:micromag-element-call-to-action-appear .5s ease both;animation:micromag-element-call-to-action-appear .5s ease both;opacity:0;background-color:#fff}.micromag-element-call-to-action-container.micromag-element-call-to-action-animationDisabled .micromag-element-call-to-action-arrow{-webkit-animation:none;animation:none}.micromag-element-call-to-action-container.micromag-element-call-to-action-invalidUrl{opacity:.5;pointer-events:none}.micromag-element-call-to-action-container.micromag-element-call-to-action-invalidUrl .micromag-element-call-to-action-arrow{-webkit-animation:none;animation:none}.micromag-element-call-to-action-container.micromag-element-call-to-action-disabled{opacity:0;pointer-events:none}.micromag-element-call-to-action-container.micromag-element-call-to-action-inWebView{width:100%}.micromag-element-call-to-action-container.micromag-element-call-to-action-withMargin{margin-bottom:5px}.micromag-element-call-to-action-webView{position:absolute;z-index:9999;top:100%;width:100%;height:100%;-webkit-transition:-webkit-transform .3s ease;transition:-webkit-transform .3s ease;-o-transition:transform .3s ease;transition:transform .3s ease;transition:transform .3s ease, -webkit-transform .3s ease}.micromag-element-call-to-action-webView.micromag-element-call-to-action-visible{-webkit-transform:translateY(-100%);-ms-transform:translateY(-100%);transform:translateY(-100%)}@-webkit-keyframes micromag-element-call-to-action-upAndDown{0%{-webkit-transform:translateY(0);transform:translateY(0)}to{-webkit-transform:translateY(-20%);transform:translateY(-20%)}}@keyframes micromag-element-call-to-action-upAndDown{0%{-webkit-transform:translateY(0);transform:translateY(0)}to{-webkit-transform:translateY(-20%);transform:translateY(-20%)}}
|
package/es/index.js
CHANGED
|
@@ -72,7 +72,9 @@ var propTypes = {
|
|
|
72
72
|
buttonBorderClassName: PropTypes.string,
|
|
73
73
|
labelClassName: PropTypes.string,
|
|
74
74
|
arrowClassName: PropTypes.string,
|
|
75
|
-
focusable: PropTypes.bool
|
|
75
|
+
focusable: PropTypes.bool,
|
|
76
|
+
enableInteraction: PropTypes.func,
|
|
77
|
+
disableInteraction: PropTypes.func
|
|
76
78
|
};
|
|
77
79
|
var defaultProps = {
|
|
78
80
|
elRef: null,
|
|
@@ -88,7 +90,9 @@ var defaultProps = {
|
|
|
88
90
|
buttonBorderClassName: null,
|
|
89
91
|
labelClassName: null,
|
|
90
92
|
arrowClassName: null,
|
|
91
|
-
focusable: true
|
|
93
|
+
focusable: true,
|
|
94
|
+
enableInteraction: null,
|
|
95
|
+
disableInteraction: null
|
|
92
96
|
};
|
|
93
97
|
|
|
94
98
|
function CallToAction(_ref) {
|
|
@@ -107,7 +111,9 @@ function CallToAction(_ref) {
|
|
|
107
111
|
buttonBorderClassName = _ref.buttonBorderClassName,
|
|
108
112
|
labelClassName = _ref.labelClassName,
|
|
109
113
|
arrowClassName = _ref.arrowClassName,
|
|
110
|
-
focusable = _ref.focusable
|
|
114
|
+
focusable = _ref.focusable,
|
|
115
|
+
enableInteraction = _ref.enableInteraction,
|
|
116
|
+
disableInteraction = _ref.disableInteraction;
|
|
111
117
|
|
|
112
118
|
var _ref2 = callToAction || {},
|
|
113
119
|
_ref2$active = _ref2.active,
|
|
@@ -135,7 +141,7 @@ function CallToAction(_ref) {
|
|
|
135
141
|
|
|
136
142
|
var swipeUpEnabled = type === null || type === 'swipe-up';
|
|
137
143
|
var validUrl = useMemo(function () {
|
|
138
|
-
return isValidUrl(url);
|
|
144
|
+
return isValidUrl(url) || true;
|
|
139
145
|
}, [url]);
|
|
140
146
|
var buttonRef = useRef(null);
|
|
141
147
|
|
|
@@ -182,7 +188,7 @@ function CallToAction(_ref) {
|
|
|
182
188
|
if (inWebView) {
|
|
183
189
|
setShowWebView(true);
|
|
184
190
|
setDisabledWebView(false);
|
|
185
|
-
} else if (isIos()) {
|
|
191
|
+
} else if (isIos() && selfTargetLinkRef.current !== null) {
|
|
186
192
|
selfTargetLinkRef.current.click();
|
|
187
193
|
setLeaving(true);
|
|
188
194
|
} else if (buttonRef.current) {
|
|
@@ -221,10 +227,18 @@ function CallToAction(_ref) {
|
|
|
221
227
|
var onOpenWebView = useCallback(function () {
|
|
222
228
|
setShowWebView(true);
|
|
223
229
|
setDisabledWebView(false);
|
|
224
|
-
|
|
230
|
+
|
|
231
|
+
if (disableInteraction !== null) {
|
|
232
|
+
disableInteraction();
|
|
233
|
+
}
|
|
234
|
+
}, [setShowWebView, setDisabledWebView, disableInteraction]);
|
|
225
235
|
var onCloseWebView = useCallback(function () {
|
|
226
236
|
setShowWebView(false);
|
|
227
|
-
|
|
237
|
+
|
|
238
|
+
if (enableInteraction !== null) {
|
|
239
|
+
enableInteraction();
|
|
240
|
+
}
|
|
241
|
+
}, [setShowWebView, enableInteraction]);
|
|
228
242
|
var ArrowElement = arrow !== null ? /*#__PURE__*/React.createElement("div", {
|
|
229
243
|
className: classNames([styles.arrow, _defineProperty({}, arrowClassName, arrowClassName !== null)]),
|
|
230
244
|
style: arrowStyle
|
|
@@ -232,17 +246,18 @@ function CallToAction(_ref) {
|
|
|
232
246
|
className: classNames([styles.arrow, _defineProperty({}, arrowClassName, arrowClassName !== null)]),
|
|
233
247
|
style: arrowStyle
|
|
234
248
|
}, /*#__PURE__*/React.createElement(Arrow, null));
|
|
249
|
+
console.log('disabled', disabled, validUrl, inWebView);
|
|
235
250
|
return active ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
236
251
|
className: classNames([styles.container, (_ref10 = {}, _defineProperty(_ref10, className, className !== null), _defineProperty(_ref10, styles.disabled, disabled), _defineProperty(_ref10, styles.animationDisabled, animationDisabled), _defineProperty(_ref10, styles.invalidUrl, !validUrl), _defineProperty(_ref10, styles.inWebView, inWebView), _ref10)]),
|
|
237
252
|
ref: elRef
|
|
238
253
|
}, leaving ? /*#__PURE__*/React.createElement("div", {
|
|
239
254
|
className: styles.leavingFrame
|
|
240
|
-
}) : null, /*#__PURE__*/React.createElement("a", {
|
|
255
|
+
}) : null, !inWebView && swipeUpEnabled ? /*#__PURE__*/React.createElement("a", {
|
|
241
256
|
className: styles.selfTargetLink,
|
|
242
257
|
href: url,
|
|
243
258
|
ref: selfTargetLinkRef,
|
|
244
259
|
tabIndex: focusable ? '0' : '-1'
|
|
245
|
-
}), swipeUpEnabled ? ArrowElement : null, /*#__PURE__*/React.createElement("div", {
|
|
260
|
+
}) : null, swipeUpEnabled ? ArrowElement : null, /*#__PURE__*/React.createElement("div", {
|
|
246
261
|
className: classNames([styles.buttonBorder, _defineProperty({}, buttonBorderClassName, buttonBorderClassName !== null)])
|
|
247
262
|
}, /*#__PURE__*/React.createElement(Button, Object.assign({
|
|
248
263
|
className: classNames([styles.button, _defineProperty({}, buttonClassName, buttonClassName !== null)]),
|
package/lib/index.js
CHANGED
|
@@ -86,7 +86,9 @@ var propTypes = {
|
|
|
86
86
|
buttonBorderClassName: PropTypes__default["default"].string,
|
|
87
87
|
labelClassName: PropTypes__default["default"].string,
|
|
88
88
|
arrowClassName: PropTypes__default["default"].string,
|
|
89
|
-
focusable: PropTypes__default["default"].bool
|
|
89
|
+
focusable: PropTypes__default["default"].bool,
|
|
90
|
+
enableInteraction: PropTypes__default["default"].func,
|
|
91
|
+
disableInteraction: PropTypes__default["default"].func
|
|
90
92
|
};
|
|
91
93
|
var defaultProps = {
|
|
92
94
|
elRef: null,
|
|
@@ -102,7 +104,9 @@ var defaultProps = {
|
|
|
102
104
|
buttonBorderClassName: null,
|
|
103
105
|
labelClassName: null,
|
|
104
106
|
arrowClassName: null,
|
|
105
|
-
focusable: true
|
|
107
|
+
focusable: true,
|
|
108
|
+
enableInteraction: null,
|
|
109
|
+
disableInteraction: null
|
|
106
110
|
};
|
|
107
111
|
|
|
108
112
|
function CallToAction(_ref) {
|
|
@@ -121,7 +125,9 @@ function CallToAction(_ref) {
|
|
|
121
125
|
buttonBorderClassName = _ref.buttonBorderClassName,
|
|
122
126
|
labelClassName = _ref.labelClassName,
|
|
123
127
|
arrowClassName = _ref.arrowClassName,
|
|
124
|
-
focusable = _ref.focusable
|
|
128
|
+
focusable = _ref.focusable,
|
|
129
|
+
enableInteraction = _ref.enableInteraction,
|
|
130
|
+
disableInteraction = _ref.disableInteraction;
|
|
125
131
|
|
|
126
132
|
var _ref2 = callToAction || {},
|
|
127
133
|
_ref2$active = _ref2.active,
|
|
@@ -149,7 +155,7 @@ function CallToAction(_ref) {
|
|
|
149
155
|
|
|
150
156
|
var swipeUpEnabled = type === null || type === 'swipe-up';
|
|
151
157
|
var validUrl = React.useMemo(function () {
|
|
152
|
-
return utils.isValidUrl(url);
|
|
158
|
+
return utils.isValidUrl(url) || true;
|
|
153
159
|
}, [url]);
|
|
154
160
|
var buttonRef = React.useRef(null);
|
|
155
161
|
|
|
@@ -196,7 +202,7 @@ function CallToAction(_ref) {
|
|
|
196
202
|
if (inWebView) {
|
|
197
203
|
setShowWebView(true);
|
|
198
204
|
setDisabledWebView(false);
|
|
199
|
-
} else if (utils.isIos()) {
|
|
205
|
+
} else if (utils.isIos() && selfTargetLinkRef.current !== null) {
|
|
200
206
|
selfTargetLinkRef.current.click();
|
|
201
207
|
setLeaving(true);
|
|
202
208
|
} else if (buttonRef.current) {
|
|
@@ -235,10 +241,18 @@ function CallToAction(_ref) {
|
|
|
235
241
|
var onOpenWebView = React.useCallback(function () {
|
|
236
242
|
setShowWebView(true);
|
|
237
243
|
setDisabledWebView(false);
|
|
238
|
-
|
|
244
|
+
|
|
245
|
+
if (disableInteraction !== null) {
|
|
246
|
+
disableInteraction();
|
|
247
|
+
}
|
|
248
|
+
}, [setShowWebView, setDisabledWebView, disableInteraction]);
|
|
239
249
|
var onCloseWebView = React.useCallback(function () {
|
|
240
250
|
setShowWebView(false);
|
|
241
|
-
|
|
251
|
+
|
|
252
|
+
if (enableInteraction !== null) {
|
|
253
|
+
enableInteraction();
|
|
254
|
+
}
|
|
255
|
+
}, [setShowWebView, enableInteraction]);
|
|
242
256
|
var ArrowElement = arrow !== null ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
243
257
|
className: classNames__default["default"]([styles.arrow, _defineProperty__default["default"]({}, arrowClassName, arrowClassName !== null)]),
|
|
244
258
|
style: arrowStyle
|
|
@@ -246,17 +260,18 @@ function CallToAction(_ref) {
|
|
|
246
260
|
className: classNames__default["default"]([styles.arrow, _defineProperty__default["default"]({}, arrowClassName, arrowClassName !== null)]),
|
|
247
261
|
style: arrowStyle
|
|
248
262
|
}, /*#__PURE__*/React__default["default"].createElement(Arrow, null));
|
|
263
|
+
console.log('disabled', disabled, validUrl, inWebView);
|
|
249
264
|
return active ? /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
250
265
|
className: classNames__default["default"]([styles.container, (_ref10 = {}, _defineProperty__default["default"](_ref10, className, className !== null), _defineProperty__default["default"](_ref10, styles.disabled, disabled), _defineProperty__default["default"](_ref10, styles.animationDisabled, animationDisabled), _defineProperty__default["default"](_ref10, styles.invalidUrl, !validUrl), _defineProperty__default["default"](_ref10, styles.inWebView, inWebView), _ref10)]),
|
|
251
266
|
ref: elRef
|
|
252
267
|
}, leaving ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
253
268
|
className: styles.leavingFrame
|
|
254
|
-
}) : null, /*#__PURE__*/React__default["default"].createElement("a", {
|
|
269
|
+
}) : null, !inWebView && swipeUpEnabled ? /*#__PURE__*/React__default["default"].createElement("a", {
|
|
255
270
|
className: styles.selfTargetLink,
|
|
256
271
|
href: url,
|
|
257
272
|
ref: selfTargetLinkRef,
|
|
258
273
|
tabIndex: focusable ? '0' : '-1'
|
|
259
|
-
}), swipeUpEnabled ? ArrowElement : null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
274
|
+
}) : null, swipeUpEnabled ? ArrowElement : null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
260
275
|
className: classNames__default["default"]([styles.buttonBorder, _defineProperty__default["default"]({}, buttonBorderClassName, buttonBorderClassName !== null)])
|
|
261
276
|
}, /*#__PURE__*/React__default["default"].createElement(Button__default["default"], Object.assign({
|
|
262
277
|
className: classNames__default["default"]([styles.button, _defineProperty__default["default"]({}, buttonClassName, buttonClassName !== null)]),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/element-call-to-action",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.94",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"@fortawesome/fontawesome-svg-core": "^1.2.32",
|
|
53
53
|
"@fortawesome/free-solid-svg-icons": "^5.15.1",
|
|
54
54
|
"@fortawesome/react-fontawesome": "^0.1.13",
|
|
55
|
-
"@micromag/core": "^0.3.
|
|
56
|
-
"@micromag/element-button": "^0.3.
|
|
57
|
-
"@micromag/element-text": "^0.3.
|
|
58
|
-
"@micromag/element-webview": "^0.3.
|
|
55
|
+
"@micromag/core": "^0.3.91",
|
|
56
|
+
"@micromag/element-button": "^0.3.91",
|
|
57
|
+
"@micromag/element-text": "^0.3.91",
|
|
58
|
+
"@micromag/element-webview": "^0.3.94",
|
|
59
59
|
"@react-spring/core": "^9.1.1",
|
|
60
60
|
"@react-spring/web": "^9.1.1",
|
|
61
61
|
"@use-gesture/react": "^10.2.4",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"publishConfig": {
|
|
69
69
|
"access": "public"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "a52ac2b4e1b68403bafc9ed067b10e834b82f825"
|
|
72
72
|
}
|