Skip to content

Commit ef9db41

Browse files
committed
Add docs draft and change some default props
1 parent 2305180 commit ef9db41

File tree

2 files changed

+70
-3
lines changed

2 files changed

+70
-3
lines changed

README.md

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,68 @@
1-
# react-native-draggable-panel
1+
# react-native-draggable-panel
2+
3+
A react native draggable panel for Android and iOS
4+
5+
# Installation
6+
7+
This library is available on npm, install it with: `npm i react-native-draggable-panel` or `yarn add react-native-draggable-panel`.
8+
9+
# Usage
10+
11+
Import react-native-draggable-panel:
12+
13+
```javascript
14+
import DraggablePanel from 'react-native-draggable-panel';
15+
```
16+
17+
### Reactive way
18+
19+
2. Then simply show it or hide it by setting the `visible` prop to true or false:
20+
21+
```javascript
22+
render () {
23+
return (
24+
<DraggablePanel
25+
visible={this.state.panelVisible}
26+
>
27+
<Text>I am a content</Text>
28+
</DraggablePanel>
29+
)
30+
}
31+
```
32+
33+
### Declarative way
34+
35+
```javascript
36+
panelRef = React.createRef();
37+
38+
showPanel() {
39+
this.panelRef.current.show();
40+
}
41+
42+
hidePanel() {
43+
this.panelRef.current.hide();
44+
}
45+
46+
render () {
47+
return (
48+
<DraggablePanel
49+
ref={this.panelRef}
50+
>
51+
<Text>I am a content</Text>
52+
</DraggablePanel>
53+
)
54+
}
55+
```
56+
57+
# Available props
58+
59+
| Name | Type | Default | Description |
60+
| ---------------------- | ------- | ----------------- | -------------------------------------------------------------------------- |
61+
| visible | boolean | false | Controls the panel's visibility |
62+
| animationDuration | number | 500 | Controls the duration in ms to show or hide the panel |
63+
| expandable | boolean | false | Controls if the panel can be expanded or not |
64+
| hideOnPressOutside | boolean | true | Controls neither to hide the panel when user presses on the overlay or not |
65+
| overlayBackgroundColor | Color | black | Controls the backgroundColor of the overlay |
66+
| overlayOpacity | number | 0.8 | Is a value between 0 and 1 that controls the overlay opacity |
67+
| borderRadius | number | 0 | Controls the panel top border radius |
68+
| height | number | SCREEN_HEIGHT / 2 | Controls the panel initial height |

src/DraggablePanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,11 @@ export const DraggablePanel = React.forwardRef((props: Props, ref) => {
206206
DraggablePanel.defaultProps = {
207207
visible: false,
208208
animationDuration: 500,
209-
expandable: true,
209+
expandable: false,
210210
hideOnPressOutside: true,
211211
overlayBackgroundColor: 'black',
212212
overlayOpacity: 0.8,
213-
borderRadius: 32,
213+
borderRadius: 0,
214214
height: DEFAULT_PANEL_HEIGHT / 2,
215215
};
216216

0 commit comments

Comments
 (0)