Skip to content

Commit 17235f4

Browse files
committed
docs : how to use this library
1 parent 2608cba commit 17235f4

File tree

1 file changed

+107
-4
lines changed

1 file changed

+107
-4
lines changed

README.md

Lines changed: 107 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,126 @@
22

33
A React Native library that provides an elegant way to create interactive focus guides and tooltips. It allows you to highlight specific components and display tooltips with smooth animations, perfect for creating onboarding experiences, feature walkthroughs, and interactive tutorials in your React Native applications.
44

5+
## Features
6+
7+
- 🔍 Highlight specific components with customizable overlay
8+
- 💬 Display tooltips with flexible positioning
9+
- 🎯 Multiple tooltip position options (top, bottom, left, right, center, and more)
10+
- 📱 Responsive design that adapts to screen boundaries
11+
- 🎨 Customizable styling and positioning
12+
- ⚡️ Smooth animations and transitions
13+
514
## Installation
615

716
```sh
817
npm install react-native-focus-guide
18+
# or
19+
yarn add react-native-focus-guide
920
```
1021

1122
## Usage
1223

24+
Here's a basic example of how to use the library:
1325

14-
```js
15-
import { multiply } from 'react-native-focus-guide';
26+
```jsx
27+
import React, { useRef, useState } from 'react';
28+
import { View, Text, TouchableOpacity } from 'react-native';
29+
import { HighlightToolTip } from 'react-native-focus-guide';
1630

17-
// ...
31+
const App = () => {
32+
const targetRef = useRef(null);
33+
const [showTooltip, setShowTooltip] = useState(false);
1834

19-
const result = await multiply(3, 7);
35+
return (
36+
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
37+
<TouchableOpacity
38+
ref={targetRef}
39+
onPress={() => setShowTooltip(true)}
40+
style={{
41+
padding: 20,
42+
backgroundColor: '#007AFF',
43+
borderRadius: 8,
44+
}}
45+
>
46+
<Text style={{ color: 'white' }}>Click me!</Text>
47+
</TouchableOpacity>
48+
49+
{showTooltip && (
50+
<HighlightToolTip
51+
targetRef={targetRef}
52+
tooltipPosition="bottom"
53+
onRequestClose={() => setShowTooltip(false)}
54+
>
55+
<View
56+
style={{ padding: 16, backgroundColor: 'white', borderRadius: 8 }}
57+
>
58+
<Text>This is a tooltip!</Text>
59+
</View>
60+
</HighlightToolTip>
61+
)}
62+
</View>
63+
);
64+
};
2065
```
2166

67+
## Props
68+
69+
The `HighlightToolTip` component accepts the following props:
70+
71+
| Prop | Type | Required | Default | Description |
72+
| ----------------- | ---------------------------- | -------- | ---------------- | --------------------------------------------------- |
73+
| `targetRef` | `React.RefObject` | Yes | - | Reference to the component you want to highlight |
74+
| `children` | `React.ReactNode` | Yes | - | Content to display in the tooltip |
75+
| `onRequestClose` | `() => void` | Yes | - | Function called when the tooltip should be closed |
76+
| `tooltipPosition` | `TooltipPosition` | No | 'bottom' | Position of the tooltip relative to the target |
77+
| `offset` | `{ x?: number; y?: number }` | No | `{ x: 0, y: 0 }` | Offset for tooltip positioning |
78+
| `allowOverlap` | `boolean` | No | `false` | Whether to allow tooltip to overlap with the target |
79+
80+
### TooltipPosition Types
81+
82+
```typescript
83+
type TooltipPosition =
84+
| 'top'
85+
| 'bottom'
86+
| 'left'
87+
| 'right'
88+
| 'center'
89+
| 'topLeft'
90+
| 'topCenter'
91+
| 'topRight'
92+
| 'bottomLeft'
93+
| 'bottomCenter'
94+
| 'bottomRight';
95+
```
96+
97+
## Advanced Usage
98+
99+
### Custom Styling
100+
101+
You can customize the tooltip's appearance by wrapping your content in a styled View:
102+
103+
```jsx
104+
<HighlightToolTip
105+
targetRef={targetRef}
106+
tooltipPosition="bottom"
107+
onRequestClose={() => setShowTooltip(false)}
108+
>
109+
<View
110+
style={{
111+
padding: 16,
112+
backgroundColor: 'white',
113+
borderRadius: 8,
114+
shadowColor: '#000',
115+
shadowOffset: { width: 0, height: 2 },
116+
shadowOpacity: 0.25,
117+
shadowRadius: 3.84,
118+
elevation: 5,
119+
}}
120+
>
121+
<Text style={{ fontSize: 16, color: '#333' }}>Custom styled tooltip!</Text>
122+
</View>
123+
</HighlightToolTip>
124+
```
22125

23126
## Contributing
24127

0 commit comments

Comments
 (0)