@dropi/react-native-design-system 0.3.16 → 0.3.18
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/lib/molecules/Toasts/LikeInteractionToast/LikeInteractionToast.d.ts +9 -0
- package/lib/molecules/Toasts/LikeInteractionToast/LikeInteractionToast.js +93 -0
- package/lib/molecules/Toasts/LikeInteractionToast/index.d.ts +1 -0
- package/lib/molecules/Toasts/LikeInteractionToast/index.js +16 -0
- package/lib/molecules/Toasts/ToastProvider/ToastProvider.js +16 -9
- package/lib/molecules/Toasts/index.d.ts +1 -0
- package/lib/molecules/Toasts/index.js +11 -0
- package/lib/molecules/Toasts/types.d.ts +20 -3
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type LikeInteractionToastProps = {
|
|
2
|
+
productImage: string;
|
|
3
|
+
message: string;
|
|
4
|
+
submessage: string;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
fallbackImageSource?: any;
|
|
7
|
+
cloudFrontUrl?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const LikeInteractionToast: ({ productImage, message, submessage, onClose, fallbackImageSource, cloudFrontUrl, }: LikeInteractionToastProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.LikeInteractionToast = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
var _atoms = require("../../../atoms");
|
|
9
|
+
var _utils = require("../../../utils");
|
|
10
|
+
var _constants = require("../../../constants");
|
|
11
|
+
var _reactNative2 = _interopRequireDefault(require("dropi-lib-icons/react-native"));
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
const LikeInteractionToast = ({
|
|
15
|
+
productImage,
|
|
16
|
+
message,
|
|
17
|
+
submessage,
|
|
18
|
+
onClose,
|
|
19
|
+
fallbackImageSource,
|
|
20
|
+
cloudFrontUrl
|
|
21
|
+
}) => {
|
|
22
|
+
const imageSource = cloudFrontUrl ? `${cloudFrontUrl}${productImage}` : productImage;
|
|
23
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
24
|
+
style: styles.toastContainer,
|
|
25
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_atoms.CustomImage, {
|
|
26
|
+
source: imageSource,
|
|
27
|
+
style: styles.image,
|
|
28
|
+
fallbackSource: fallbackImageSource
|
|
29
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
30
|
+
style: styles.textContainer,
|
|
31
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_atoms.Heading, {
|
|
32
|
+
type: "h5",
|
|
33
|
+
style: styles.message,
|
|
34
|
+
children: message
|
|
35
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_atoms.Body, {
|
|
36
|
+
type: "s-regular",
|
|
37
|
+
style: styles.submessage,
|
|
38
|
+
ellipsizeMode: "tail",
|
|
39
|
+
numberOfLines: 1,
|
|
40
|
+
children: submessage
|
|
41
|
+
})]
|
|
42
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
43
|
+
onPress: onClose,
|
|
44
|
+
style: styles.closeButton,
|
|
45
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative2.default, {
|
|
46
|
+
name: "close-large",
|
|
47
|
+
size: 12,
|
|
48
|
+
color: _constants.colors["Gray-800"].light
|
|
49
|
+
})
|
|
50
|
+
})]
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
exports.LikeInteractionToast = LikeInteractionToast;
|
|
54
|
+
const styles = _reactNative.StyleSheet.create({
|
|
55
|
+
toastContainer: {
|
|
56
|
+
backgroundColor: '#FFF',
|
|
57
|
+
width: _utils.windowWidth - 32,
|
|
58
|
+
maxWidth: 700,
|
|
59
|
+
flexDirection: 'row',
|
|
60
|
+
justifyContent: 'space-between',
|
|
61
|
+
padding: _constants.spacing['size-4'],
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
borderRadius: _constants.radius['border-2'],
|
|
64
|
+
shadowColor: "#000",
|
|
65
|
+
shadowOffset: {
|
|
66
|
+
width: 0,
|
|
67
|
+
height: 2
|
|
68
|
+
},
|
|
69
|
+
shadowOpacity: 0.25,
|
|
70
|
+
shadowRadius: _constants.radius['border-1'],
|
|
71
|
+
elevation: 5
|
|
72
|
+
},
|
|
73
|
+
image: {
|
|
74
|
+
width: 50,
|
|
75
|
+
height: 50,
|
|
76
|
+
borderRadius: _constants.radius['border-2'],
|
|
77
|
+
overflow: 'hidden'
|
|
78
|
+
},
|
|
79
|
+
textContainer: {
|
|
80
|
+
flex: 1,
|
|
81
|
+
marginHorizontal: _constants.spacing['size-4']
|
|
82
|
+
},
|
|
83
|
+
message: {
|
|
84
|
+
color: _constants.colors['White'].dark,
|
|
85
|
+
marginBottom: _constants.spacing['size-1']
|
|
86
|
+
},
|
|
87
|
+
submessage: {
|
|
88
|
+
color: _constants.colors['Gray-600'].light
|
|
89
|
+
},
|
|
90
|
+
closeButton: {
|
|
91
|
+
padding: _constants.spacing['size-2']
|
|
92
|
+
}
|
|
93
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './LikeInteractionToast';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _LikeInteractionToast = require("./LikeInteractionToast");
|
|
7
|
+
Object.keys(_LikeInteractionToast).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _LikeInteractionToast[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _LikeInteractionToast[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -7,6 +7,7 @@ exports.ToastProvider = exports.ToastContext = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
var _FeedbackToast = require("../FeedbackToast/FeedbackToast");
|
|
10
|
+
var _LikeInteractionToast = require("../LikeInteractionToast/LikeInteractionToast");
|
|
10
11
|
var _utils = require("../../../utils");
|
|
11
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
13
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
@@ -179,9 +180,8 @@ const ToastProvider = ({
|
|
|
179
180
|
const showToast = (0, _react.useCallback)(params => {
|
|
180
181
|
const newToast = {
|
|
181
182
|
id: `toast-${toastIdCounter.current++}`,
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
message: params.message,
|
|
183
|
+
variant: params.variant,
|
|
184
|
+
data: params.data,
|
|
185
185
|
duration: params.duration ?? DEFAULT_DURATION
|
|
186
186
|
};
|
|
187
187
|
if (!currentToast && !isAnimating) {
|
|
@@ -196,19 +196,26 @@ const ToastProvider = ({
|
|
|
196
196
|
value: {
|
|
197
197
|
showToast
|
|
198
198
|
},
|
|
199
|
-
children: [children, currentToast && /*#__PURE__*/(0, _jsxRuntime.
|
|
199
|
+
children: [children, currentToast && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Animated.View, {
|
|
200
200
|
style: [styles.toastWrapper, {
|
|
201
201
|
transform: [{
|
|
202
202
|
translateY: slideAnim
|
|
203
203
|
}]
|
|
204
204
|
}],
|
|
205
205
|
pointerEvents: "box-none",
|
|
206
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_FeedbackToast.FeedbackToast, {
|
|
207
|
-
type: currentToast.type,
|
|
208
|
-
title: currentToast.title,
|
|
209
|
-
message: currentToast.message,
|
|
206
|
+
children: [currentToast.variant === 'feedback' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_FeedbackToast.FeedbackToast, {
|
|
207
|
+
type: currentToast.data.type,
|
|
208
|
+
title: currentToast.data.title,
|
|
209
|
+
message: currentToast.data.message,
|
|
210
210
|
onClose: handleClose
|
|
211
|
-
})
|
|
211
|
+
}), currentToast.variant === 'like-interaction' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_LikeInteractionToast.LikeInteractionToast, {
|
|
212
|
+
productImage: currentToast.data.productImage,
|
|
213
|
+
message: currentToast.data.message,
|
|
214
|
+
submessage: currentToast.data.submessage,
|
|
215
|
+
fallbackImageSource: currentToast.data.fallbackImageSource,
|
|
216
|
+
cloudFrontUrl: currentToast.data.cloudFrontUrl,
|
|
217
|
+
onClose: handleClose
|
|
218
|
+
})]
|
|
212
219
|
})]
|
|
213
220
|
});
|
|
214
221
|
};
|
|
@@ -25,6 +25,17 @@ Object.keys(_FeedbackToast).forEach(function (key) {
|
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
|
+
var _LikeInteractionToast = require("./LikeInteractionToast");
|
|
29
|
+
Object.keys(_LikeInteractionToast).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _LikeInteractionToast[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _LikeInteractionToast[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
28
39
|
var _ToastProvider = require("./ToastProvider");
|
|
29
40
|
Object.keys(_ToastProvider).forEach(function (key) {
|
|
30
41
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
export type ToastTypes = 'success' | 'error' | 'warning' | 'info';
|
|
2
|
-
export type
|
|
3
|
-
|
|
2
|
+
export type ToastVariant = 'feedback' | 'like-interaction';
|
|
3
|
+
export type BaseFeedbackToastData = {
|
|
4
4
|
type: ToastTypes;
|
|
5
5
|
title?: string;
|
|
6
6
|
message?: string;
|
|
7
|
-
duration?: number;
|
|
8
7
|
};
|
|
8
|
+
export type LikeInteractionToastData = {
|
|
9
|
+
productImage: string;
|
|
10
|
+
message: string;
|
|
11
|
+
submessage: string;
|
|
12
|
+
fallbackImageSource?: any;
|
|
13
|
+
cloudFrontUrl?: string;
|
|
14
|
+
};
|
|
15
|
+
export type ToastConfig = {
|
|
16
|
+
id: string;
|
|
17
|
+
variant: ToastVariant;
|
|
18
|
+
duration?: number;
|
|
19
|
+
} & ({
|
|
20
|
+
variant: 'feedback';
|
|
21
|
+
data: BaseFeedbackToastData;
|
|
22
|
+
} | {
|
|
23
|
+
variant: 'like-interaction';
|
|
24
|
+
data: LikeInteractionToastData;
|
|
25
|
+
});
|
|
9
26
|
export type ShowToastParams = Omit<ToastConfig, 'id'> & {
|
|
10
27
|
duration?: number;
|
|
11
28
|
};
|