Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit 48b87f7

Browse files
committed
1.0.4 and readme
1 parent d50a4ed commit 48b87f7

File tree

6 files changed

+58
-25
lines changed

6 files changed

+58
-25
lines changed

Doc/android.gif

16.9 MB
Loading
File renamed without changes.

README.md

+33-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,46 @@
11
# react-native-tooltip-menu
22

3-
Currently works only with `iOS`. `Android` coming soon.
3+
Currently works only with `iOS` and `Android`.
44

5-
This component is a clickable button which will show you a tooltip menu with clickable menu.
6-
You can very easily customize how the component will look like.
5+
Component for specfied case. Left bottom button with nice looking menu tooltip with animation after click.
76

8-
![alt text](https://github.com/alimek/react-native-tooltip-menu/raw/master/Doc/screenshoot.gif "React Native ToolTip Menu")
7+
![alt text](https://github.com/alimek/react-native-tooltip-menu/raw/master/Doc/ios.gif "React Native ToolTip Menu")
8+
![alt text](https://github.com/alimek/react-native-tooltip-menu/raw/master/Doc/andorid.gif "React Native ToolTip Menu")
99

1010

1111
# How to install
12+
13+
Via NPM
1214

1315
```bash
1416
npm install react-native-tooltip-menu --save
1517
```
18+
19+
or via Yarn
20+
```bash
21+
yarn add react-native-tooltip-menu --save
22+
```
23+
24+
then
25+
26+
```js
27+
import ReactNativeMenuTooltip from 'react-native-tooltip-menu';
28+
```
29+
30+
# Configuration
31+
32+
## ReactNativeTooltipMenu:
33+
34+
| Property | Type | Default | Description |
35+
|----------------|---------------|-----------|--------------------------------------|
36+
| buttonComponent | |||
37+
| items | `Array` | | Items to be rendered in menu. Each of item requires `label` as `string` or `function` if you want to render your own component and `onClick` as `function` to be called when you click item. |
38+
| componentWrapperStyle | Object | Optional | Style `Object` if you want to overwrite wrapper for your `buttonComponent`
39+
| overlayStyle | Object | Optional | Style `Object` if you want to overwrite overlay style's.
40+
| widthType | `auto`, `half` or `full` | `half` | Menu items width. `Auto` = automatically set width to your longest test, `half` = always 50% your screen width, `full` = 100% screen width.
41+
| onRequestClose | `function` | Optional, default `() => {}` | Modal onRequestClose required function on Android
42+
| labelContainerStyle | `Object` | Optional | Style `Object` if you want to change default `TooltipMenuItem` View's style.
43+
| labelStyle | `Object` | Optional | Style `Object` if you want to change default `TooltipMenuItem` Text's style.
1644
# Example
1745

1846
```js
@@ -60,7 +88,4 @@ class Example extends Component {
6088

6189
AppRegistry.registerComponent('Example', () => Example);
6290

63-
```
64-
65-
# License
66-
91+
```

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-tooltip-menu",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "ReactNative component showing tooltip with menu items.",
55
"main": "src/index.js",
66
"scripts": {

src/TooltipMenuItem.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import ReactNative from 'react-native';
33

44
const {
55
Text,
6+
View,
67
StyleSheet,
78
TouchableOpacity,
89
} = ReactNative;
@@ -13,14 +14,15 @@ const StylePropType = React.PropTypes.oneOfType([
1314
]);
1415

1516
const TooltipMenuItem = ({ onPress, containerStyle, label, labelStyle }) => (
16-
<TouchableOpacity style={[styles.container, containerStyle]} onPress={onPress}>
17-
{
18-
typeof label === 'string' ?
19-
<Text style={[labelStyle]}>{label}</Text> :
20-
label()
21-
}
22-
23-
</TouchableOpacity>
17+
<View style={[styles.container, containerStyle]}>
18+
<TouchableOpacity onPress={onPress}>
19+
{
20+
typeof label === 'string' ?
21+
<Text style={[labelStyle]}>{label}</Text> :
22+
label()
23+
}
24+
</TouchableOpacity>
25+
</View>
2426
);
2527

2628
TooltipMenuItem.propTypes = {

src/index.js

+14-8
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ class Tooltip extends React.Component {
9191
labelContainerStyle,
9292
labelStyle,
9393
} = this.props;
94-
const { isModalOpen, onRequestClose } = this.state;
94+
const { isModalOpen } = this.state;
95+
const { onRequestClose } = this.props;
9596
const widthStyle = mapWight(widthType);
9697

9798
return (
@@ -110,7 +111,11 @@ class Tooltip extends React.Component {
110111
onRequestClose={onRequestClose}
111112
>
112113
<View style={[styles.overlay, overlayStyle]}>
113-
<TouchableOpacity activeOpacity={1} focusedOpacity={1} style={{ flex: 1 }} onPress={isModalOpen ? this.hideModal : this.openModal}>
114+
<TouchableOpacity
115+
activeOpacity={1}
116+
focusedOpacity={1} style={{ flex: 1 }}
117+
onPress={isModalOpen ? this.hideModal : this.openModal}
118+
>
114119
<View style={[styles.component]}>
115120
<Animated.View
116121
style={[
@@ -139,8 +144,8 @@ class Tooltip extends React.Component {
139144
/>
140145
);
141146
})}
142-
<View style={styles.triangle}/>
143147
</Animated.View>
148+
<Animated.View style={[styles.triangle, { opacity: this.state.opacity }]} />
144149
<TouchableOpacity onPress={isModalOpen ? this.hideModal : this.openModal}>
145150
{buttonComponent}
146151
</TouchableOpacity>
@@ -166,6 +171,8 @@ Tooltip.propTypes = {
166171
).isRequired,
167172
componentWrapperStyle: React.PropTypes.object,
168173
overlayStyle: React.PropTypes.object,
174+
labelContainerStyle: React.PropTypes.object,
175+
labelStyle: React.PropTypes.object,
169176
widthType: React.PropTypes.oneOf([
170177
'auto',
171178
'half',
@@ -198,15 +205,14 @@ const styles = StyleSheet.create({
198205
tooltipContainer: {
199206
backgroundColor: 'white',
200207
borderRadius: 10,
201-
marginBottom: 10,
202208
position: 'absolute',
203209
},
204210
triangle: {
205211
position: 'absolute',
206-
bottom: -10,
207-
marginLeft: 22,
208-
width: 0,
209-
height: 0,
212+
top: -10,
213+
left: 22,
214+
width: 10,
215+
height: 10,
210216
backgroundColor: 'transparent',
211217
borderStyle: 'solid',
212218
borderTopWidth: 10,

0 commit comments

Comments
 (0)