Skip to content

Commit

Permalink
docs: usage
Browse files Browse the repository at this point in the history
  • Loading branch information
lodev09 committed Apr 25, 2024
1 parent 0406112 commit 8f2edde
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 48 deletions.
51 changes: 29 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# React Native True Sheet

[![CI](https://github.com/lodev09/react-native-true-sheet/actions/workflows/ci.yml/badge.svg)](https://github.com/lodev09/react-native-true-sheet/actions/workflows/ci.yml)
![GitHub Release](https://img.shields.io/github/v/release/lodev09/react-native-true-sheet)
![NPM Downloads](https://img.shields.io/npm/dw/%40lodev09%2Freact-native-true-sheet)
[![NPM Version](https://img.shields.io/npm/v/%40lodev09%2Freact-native-true-sheet)](https://www.npmjs.com/package/@lodev09/react-native-true-sheet)
[![NPM Downloads](https://img.shields.io/npm/d18m/%40lodev09%2Freact-native-true-sheet)](https://www.npmjs.com/package/@lodev09/react-native-true-sheet)

The true native bottom sheet experience for your React Native Apps. πŸ’©

Expand Down Expand Up @@ -39,27 +39,34 @@ npm i @lodev09/react-native-true-sheet
```tsx
import { TrueSheet } from "@lodev09/react-native-true-sheet"

// ...

const sheet = useRef<TrueSheet>(null)

const openSheet = async () => {
await sheet.current?.present()
console.log('horray! sheet has been presented πŸ’©')
export const App = () => {
const sheet = useRef<TrueSheet>(null)

// Present the sheet βœ…
const present = async () => {
await sheet.current?.present()
console.log('horray! sheet has been presented πŸ’©')
}

// Dismiss the sheet βœ…
const dismiss = async () => {
await sheet.current?.dismiss()
console.log('Bye bye πŸ‘‹')
}

return (
<View>
<Button onPress={present} title="Present" />
<TrueSheet
ref={sheet}
sizes={['auto', 'large']}
cornerRadius={24}
>
<Button onPress={dismiss} title="Dismiss" />
</TrueSheet>
</View>
)
}

return (
<View>
<Button onPress={openSheet} title="Open Sheet" />
<TrueSheet
ref={sheet}
sizes={['auto', 'large']}
cornerRadius={24}
>
<View />
</TrueSheet>
</View>
)
```

## v1 Roadmap
Expand Down
48 changes: 23 additions & 25 deletions docs/docs/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,44 @@ sidebar_position: 3

# Usage

Import `TrueSheet`.
1. Import `TrueSheet`.

```tsx
import { TrueSheet } from "@lodev09/react-native-true-sheet"
```

Define `TrueSheet` inside any component and attach a `ref` to it.
2. Define `TrueSheet` inside any component and attach a `ref` to it.
3. Control the sheet by invoking the available `ref` [methods](/reference/methods).

```tsx {2-2,10-12}
const App = () => {
```tsx {2-2,5-8,11-14,18-25}
export const App = () => {
const sheet = useRef<TrueSheet>(null)

// add present here
// add dismiss here
// Present the sheet βœ…
const present = async () => {
await sheet.current?.present()
console.log('horray! sheet has been presented πŸ’©')
}

// Dismiss the sheet βœ…
const dismiss = async () => {
await sheet.current?.dismiss()
console.log('Bye bye πŸ‘‹')
}

return (
<View>
<Button onPress={present} title="Open Sheet" />
<TrueSheet ref={sheet} sizes={['auto', '80%', 'large']}>
<Button onPress={present} title="Present" />
<TrueSheet
ref={sheet}
sizes={['auto', 'large']}
cornerRadius={24}
>
<Button onPress={dismiss} title="Dismiss" />
</TrueSheet>
</View>
)
}
```

Use the `ref` instance in presenting the sheet.

```tsx {2}
const present = async () => {
await sheet.current?.present()
console.log('horray! sheet has been presented πŸ’©')
}
```

The same goes for dismissing it.

```tsx {2}
const dismiss = async () => {
await sheet.current?.dismiss()
console.log('Bye bye πŸ‘‹')
}
```
Simple, right? Head over to [`props`](/reference/props) to learn more about configuring your sheet.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"bugs": {
"url": "https://github.com/lodev09/react-native-true-sheet/issues"
},
"homepage": "https://github.com/lodev09/react-native-true-sheet#readme",
"homepage": "https://sheet.lodev09.com",
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
Expand Down

0 comments on commit 8f2edde

Please sign in to comment.