You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -75,44 +54,96 @@ You can checkout the example project 🥰
75
54
76
55
Simply run
77
56
78
-
-`npm i`
57
+
-`npm i && npx pod-install`
79
58
-`react-native run-ios/android`
80
59
81
60
should work of the example project.
82
61
83
-
#Configuration - Props
62
+
### How it works
84
63
85
-
## Fundamentals
64
+
The tooltip wraps an element _in place_ in your React Native rendering. When it renders, it measures the location of the element, using React Native's
65
+
[measure](https://facebook.github.io/react-native/docs/direct-manipulation.html#measurecallback). When the tooltip is displayed, it renders a _copy_ of the wrapped element positioned absolutely on the screen at the coordinates returned after measuring ([see `TooltipChildrenContext` below](#tooltipchildrencontext) if you need to tell the difference between the _copy_ and the _original_ element). This allows you to touch the element in the tooltip modal rendered above your current screen.
| accessible | bool| true | Set this to `false` if you do not want the root touchable element to be accessible. [See docs on accessible here](https://reactnative.dev/docs/accessibility#accessibility-properties)
72
+
| allowChildInteraction | bool| true | By default, the user can touch and interact with the child element. When this prop is false, the user cannot interact with the child element while the tooltip is visible. |
73
+
| arrowSize |`Size`| { width: 16, height: 8 } | The dimensions of the arrow on the bubble pointing to the highlighted element |
74
+
| backgroundColor | string | 'rgba(0,0,0,0.5)' | Color of the fullscreen background beneath the tooltip. **_Overrides_** the `backgroundStyle` prop |
75
+
| childContentSpacing | number | 4 | The distance between the tooltip-rendered child and the arrow pointing to it |
76
+
| closeOnChildInteraction | bool | true | When child interaction is allowed, this prop determines if `onClose` should be called when the user interacts with the child element. Default is true (usually means the tooltip will dismiss once the user touches the element highlighted) |
77
+
| closeOnContentInteraction | bool | true | this prop determines if `onClose` should be called when the user interacts with the content element. Default is true (usually means the tooltip will dismiss once the user touches the content element) |
78
+
| content | function/Element |`<View />`| This is the view displayed in the tooltip popover bubble |
79
+
| displayInsets | object | { top: 24, bottom: 24, left: 24, right: 24 } | The number of pixels to inset the tooltip on the screen (think of it like padding). The tooltip bubble should never render outside of these insets, so you may need to adjust your `content` accordingly |
80
+
| disableShadow | bool | false | When true, tooltips will not appear elevated. Disabling shadows will remove the warning: `RCTView has a shadow set but cannot calculate shadow efficiently` on IOS devices. |
81
+
| isVisible | bool | false | When true, tooltip is displayed ||
82
+
| onClose | function | null | Callback fired when the user taps the tooltip background overlay |
83
+
| placement | string | "top" \| "center" | Where to position the tooltip - options: `top, bottom, left, right, center`. Default is `top` for tooltips rendered with children Default is `center` for tooltips rendered without children. <br><br>NOTE: `center` is only available with a childless placement, and the content will be centered within the bounds defined by the `displayInsets`. |
84
+
| showChildInTooltip | bool | true | Set this to `false` if you do NOT want to display the child alongside the tooltip when the tooltip is visible |
85
+
| supportedOrientations | array |["portrait", "landscape"]| This prop allows you to control the supported orientations the tooltip modal can be displayed. It correlates directly with [the prop for React Native's Modal component](https://facebook.github.io/react-native/docs/modal#supportedorientations) (has no effect if `useReactNativeModal` is false) |
86
+
| topAdjustment | number | 0 | Value which provides additional vertical offest for the child element displayed in a tooltip. Commonly set to: `Platform.OS === 'android' ? -StatusBar.currentHeight : 0` due to an issue with React Native's measure function on Android
87
+
| horizontalAdjustment | number | 0 | Value which provides additional horizontal offest for the child element displayed in a tooltip. This is useful for adjusting the horizontal positioning of a highlighted child element if needed
88
+
| useInteractionManager | bool | false | Set this to true if you want the tooltip to wait to become visible until the callback for `InteractionManager.runAfterInteractions` is executed. Can be useful if you need to wait for navigation transitions to complete, etc. [See docs on InteractionManager here](https://facebook.github.io/react-native/docs/interactionmanager)
89
+
| useReactNativeModal | bool| true | By default, this library uses a `<Modal>` component from React Native. If you need to disable this, and simply render an absolutely positioned full-screen view, set `useReactNativeModal={false}`. This is especially useful if you desire to render a Tooltip while you have a different `Modal` rendered.
| enableButton | boolean | false | let you enable the button (must use it for button) |
97
-
| onPress | function | undefined | set your own logic for the button functionality when it is pressed |
98
-
| buttonText | string | undefined | change the button's text |
99
-
| style | ViewStyle | default | set or override the style object for the main container |
100
-
| buttonStyle | ViewStyle | default | set or override the style object for the button style |
101
-
| ImageComponent | Image | default | set your own component instead of default react-native Image component |
91
+
### Style Props
92
+
93
+
The tooltip styles should work out-of-the-box for most use cases, however should you need you can customize the styles of the tooltip using these props.
| arrowStyle | Styles the triangle that points to the called out element |
98
+
| backgroundStyle | Styles the overlay view that sits behind the tooltip, but over the current view |
99
+
| childrenWrapperStyle | Styles the view that wraps cloned children |
100
+
| contentStyle | Styles the content wrapper that surrounds the `content` element |
101
+
| tooltipStyle | Styles the tooltip that wraps the arrow and content elements |
102
+
103
+
### Class definitions for props
104
+
105
+
*`Size` is an object with properties: `{ width: number, height: number }`
106
+
107
+
### TooltipChildrenContext
108
+
109
+
[React Context](https://reactjs.org/docs/context.html) that can be used to distinguish "real" children rendered inside parent's layout from their copies rendered inside tooltip's modal. The duplicate child rendered in the tooltip modal is wrapped in a Context.Provider which provides object with prop `tooltipDuplicate` set to `true`, so informed decisions may be made, if necessary, based on where the child rendered.
0 commit comments