@momo-kits/animated-tooltip 0.154.1-beta.17 → 0.154.1-beta.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/index.tsx +21 -5
- package/package.json +15 -15
- package/styles.ts +4 -9
- package/types.ts +7 -2
package/index.tsx
CHANGED
|
@@ -7,7 +7,14 @@ import React, {
|
|
|
7
7
|
useRef,
|
|
8
8
|
useState,
|
|
9
9
|
} from 'react';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
Animated,
|
|
12
|
+
Easing,
|
|
13
|
+
TouchableOpacity,
|
|
14
|
+
useWindowDimensions,
|
|
15
|
+
View,
|
|
16
|
+
ViewStyle,
|
|
17
|
+
} from 'react-native';
|
|
11
18
|
import {
|
|
12
19
|
Colors,
|
|
13
20
|
Icon,
|
|
@@ -36,11 +43,13 @@ const Tooltip = forwardRef<TooltipRef, TooltipProps>(function Tooltip(
|
|
|
36
43
|
accessibilityLabel,
|
|
37
44
|
onVisibleChange,
|
|
38
45
|
onPressClose,
|
|
46
|
+
containerStyle,
|
|
39
47
|
},
|
|
40
48
|
ref,
|
|
41
49
|
) {
|
|
42
50
|
const app = useContext<any>(MiniAppContext);
|
|
43
51
|
const screen = useContext<any>(ScreenContext);
|
|
52
|
+
const SCREEN_WIDTH = useWindowDimensions().width;
|
|
44
53
|
const arrowSize = 6;
|
|
45
54
|
const [tooltipSize, setTooltipSize] = useState({ width: 0, height: 0 });
|
|
46
55
|
|
|
@@ -184,7 +193,6 @@ const Tooltip = forwardRef<TooltipRef, TooltipProps>(function Tooltip(
|
|
|
184
193
|
? { bottom: 0 }
|
|
185
194
|
: { top: centerVerticalOffset };
|
|
186
195
|
|
|
187
|
-
const resolvedBackground = Colors.black_17;
|
|
188
196
|
const resolvedTextColor = Colors.black_01;
|
|
189
197
|
|
|
190
198
|
const renderButtons = () => {
|
|
@@ -275,7 +283,12 @@ const Tooltip = forwardRef<TooltipRef, TooltipProps>(function Tooltip(
|
|
|
275
283
|
return (
|
|
276
284
|
<View style={styles.content}>
|
|
277
285
|
<View style={styles.contentHeader}>
|
|
278
|
-
<View
|
|
286
|
+
<View
|
|
287
|
+
style={{
|
|
288
|
+
minWidth: 100,
|
|
289
|
+
maxWidth: SCREEN_WIDTH - Spacing.M * 2 - 48,
|
|
290
|
+
}}
|
|
291
|
+
>
|
|
279
292
|
{title ? (
|
|
280
293
|
<Text
|
|
281
294
|
typography={'header_s_semibold'}
|
|
@@ -319,7 +332,7 @@ const Tooltip = forwardRef<TooltipRef, TooltipProps>(function Tooltip(
|
|
|
319
332
|
{
|
|
320
333
|
width: size * 2,
|
|
321
334
|
height: size * 2,
|
|
322
|
-
backgroundColor:
|
|
335
|
+
backgroundColor: Colors.black_17,
|
|
323
336
|
transform: [{ rotate: '45deg' }],
|
|
324
337
|
borderRadius: size / 2,
|
|
325
338
|
},
|
|
@@ -382,13 +395,16 @@ const Tooltip = forwardRef<TooltipRef, TooltipProps>(function Tooltip(
|
|
|
382
395
|
<Animated.View
|
|
383
396
|
pointerEvents="auto"
|
|
384
397
|
style={[
|
|
398
|
+
{
|
|
399
|
+
maxWidth: SCREEN_WIDTH - Spacing.M * 2,
|
|
400
|
+
},
|
|
401
|
+
containerStyle,
|
|
385
402
|
styles.tooltip,
|
|
386
403
|
placementStyle,
|
|
387
404
|
alignStyle,
|
|
388
405
|
{
|
|
389
406
|
opacity: animatedValue,
|
|
390
407
|
transform: [translate],
|
|
391
|
-
backgroundColor: resolvedBackground,
|
|
392
408
|
},
|
|
393
409
|
]}
|
|
394
410
|
onLayout={event => setTooltipSize(event.nativeEvent.layout)}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
2
|
+
"name": "@momo-kits/animated-tooltip",
|
|
3
|
+
"version": "0.154.1-beta.18",
|
|
4
|
+
"private": false,
|
|
5
|
+
"main": "index.tsx",
|
|
6
|
+
"dependencies": {},
|
|
7
|
+
"peerDependencies": {
|
|
8
|
+
"@momo-kits/foundation": "latest",
|
|
9
|
+
"react": "*",
|
|
10
|
+
"react-native": "*"
|
|
11
|
+
},
|
|
12
|
+
"license": "MoMo",
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"registry": "https://registry.npmjs.org/"
|
|
15
|
+
}
|
|
16
|
+
}
|
package/styles.ts
CHANGED
|
@@ -11,7 +11,6 @@ export default StyleSheet.create({
|
|
|
11
11
|
padding: Spacing.M,
|
|
12
12
|
backgroundColor: Colors.black_17,
|
|
13
13
|
borderRadius: Radius.S,
|
|
14
|
-
width: 256,
|
|
15
14
|
},
|
|
16
15
|
text: {
|
|
17
16
|
color: Colors.black_01,
|
|
@@ -25,20 +24,19 @@ export default StyleSheet.create({
|
|
|
25
24
|
flexDirection: 'column',
|
|
26
25
|
},
|
|
27
26
|
title: {
|
|
28
|
-
marginBottom: Spacing.XS
|
|
27
|
+
marginBottom: Spacing.XS,
|
|
29
28
|
},
|
|
30
29
|
description: {
|
|
31
|
-
marginBottom: Spacing.
|
|
30
|
+
marginBottom: Spacing.M,
|
|
32
31
|
},
|
|
33
32
|
buttonsRow: {
|
|
34
33
|
flexDirection: 'row',
|
|
35
34
|
flexWrap: 'wrap',
|
|
36
35
|
justifyContent: 'flex-end',
|
|
37
|
-
marginTop: Spacing.M,
|
|
38
36
|
},
|
|
39
37
|
button: {
|
|
40
|
-
marginRight: Spacing.
|
|
41
|
-
marginBottom: Spacing.
|
|
38
|
+
marginRight: Spacing.XXS,
|
|
39
|
+
marginBottom: Spacing.XXS,
|
|
42
40
|
},
|
|
43
41
|
textButton: {},
|
|
44
42
|
iconButton: {},
|
|
@@ -53,9 +51,6 @@ export default StyleSheet.create({
|
|
|
53
51
|
contentHeader: {
|
|
54
52
|
flexDirection: 'row',
|
|
55
53
|
},
|
|
56
|
-
contentTextContainer: {
|
|
57
|
-
flex: 1,
|
|
58
|
-
},
|
|
59
54
|
closeIconSpacing: {
|
|
60
55
|
marginLeft: Spacing.S,
|
|
61
56
|
},
|
package/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {ReactNode} from 'react';
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ViewStyle } from 'react-native';
|
|
2
3
|
|
|
3
4
|
export type TooltipPlacement = 'top' | 'bottom' | 'left' | 'right';
|
|
4
5
|
|
|
@@ -77,5 +78,9 @@ export type TooltipProps = {
|
|
|
77
78
|
* Triggered when the close button (X) is pressed.
|
|
78
79
|
*/
|
|
79
80
|
onPressClose?: () => void;
|
|
80
|
-
};
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Tooltip container style.
|
|
84
|
+
*/
|
|
85
|
+
containerStyle?: ViewStyle;
|
|
86
|
+
};
|