@momo-kits/animated-tooltip 0.154.1-beta.14 → 0.154.1-beta.16

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 (4) hide show
  1. package/index.tsx +20 -5
  2. package/package.json +15 -15
  3. package/styles.ts +4 -8
  4. 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 { Animated, Easing, TouchableOpacity, View, ViewStyle } from 'react-native';
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,11 @@ const Tooltip = forwardRef<TooltipRef, TooltipProps>(function Tooltip(
275
283
  return (
276
284
  <View style={styles.content}>
277
285
  <View style={styles.contentHeader}>
278
- <View style={styles.contentTextContainer}>
286
+ <View
287
+ style={{
288
+ maxWidth: SCREEN_WIDTH - Spacing.M * 2 - 48,
289
+ }}
290
+ >
279
291
  {title ? (
280
292
  <Text
281
293
  typography={'header_s_semibold'}
@@ -319,7 +331,7 @@ const Tooltip = forwardRef<TooltipRef, TooltipProps>(function Tooltip(
319
331
  {
320
332
  width: size * 2,
321
333
  height: size * 2,
322
- backgroundColor: resolvedBackground,
334
+ backgroundColor: Colors.black_17,
323
335
  transform: [{ rotate: '45deg' }],
324
336
  borderRadius: size / 2,
325
337
  },
@@ -382,13 +394,16 @@ const Tooltip = forwardRef<TooltipRef, TooltipProps>(function Tooltip(
382
394
  <Animated.View
383
395
  pointerEvents="auto"
384
396
  style={[
397
+ {
398
+ maxWidth: SCREEN_WIDTH - Spacing.M * 2,
399
+ },
400
+ containerStyle,
385
401
  styles.tooltip,
386
402
  placementStyle,
387
403
  alignStyle,
388
404
  {
389
405
  opacity: animatedValue,
390
406
  transform: [translate],
391
- backgroundColor: resolvedBackground,
392
407
  },
393
408
  ]}
394
409
  onLayout={event => setTooltipSize(event.nativeEvent.layout)}
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
- "name": "@momo-kits/animated-tooltip",
3
- "version": "0.154.1-beta.14",
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
- }
2
+ "name": "@momo-kits/animated-tooltip",
3
+ "version": "0.154.1-beta.16",
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,10 +24,10 @@ export default StyleSheet.create({
25
24
  flexDirection: 'column',
26
25
  },
27
26
  title: {
28
- marginBottom: Spacing.XS / 2,
27
+ marginBottom: Spacing.XL,
29
28
  },
30
29
  description: {
31
- marginBottom: Spacing.XS / 2,
30
+ marginBottom: Spacing.XXS,
32
31
  },
33
32
  buttonsRow: {
34
33
  flexDirection: 'row',
@@ -37,8 +36,8 @@ export default StyleSheet.create({
37
36
  marginTop: Spacing.M,
38
37
  },
39
38
  button: {
40
- marginRight: Spacing.XS / 2,
41
- marginBottom: Spacing.XS / 2,
39
+ marginRight: Spacing.XXS,
40
+ marginBottom: Spacing.XXS,
42
41
  },
43
42
  textButton: {},
44
43
  iconButton: {},
@@ -53,9 +52,6 @@ export default StyleSheet.create({
53
52
  contentHeader: {
54
53
  flexDirection: 'row',
55
54
  },
56
- contentTextContainer: {
57
- flex: 1,
58
- },
59
55
  closeIconSpacing: {
60
56
  marginLeft: Spacing.S,
61
57
  },
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
+ };