From da7ad8b53ce3f12bc62162e469798a4f57400014 Mon Sep 17 00:00:00 2001 From: Mo Gorhom Date: Wed, 12 Aug 2020 09:40:06 +0200 Subject: [PATCH] docs: added methods & hook to readme file --- README.md | 32 +++++++++++++++++++--- src/components/bottomSheet/BottomSheet.tsx | 8 ++++++ src/context.ts | 8 ++++++ 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ec96ea48..e3534c8c 100644 --- a/README.md +++ b/README.md @@ -22,14 +22,16 @@ A performant interactive bottom sheet with fully configurable options 🚀 - [React Navigation Integration](./docs/react-navigation.md) - [Touchables](./docs/touchables.md) 4. [Props](#props) -5. [Scrollables](#scrollables) +5. [Methods](#methods) +6. [Hooks](#hooks) +7. [Scrollables](#scrollables) - [BottomSheetFlatList](./docs/flatlist.md) - [BottomSheetSectionList](./docs/sectionlist.md) - [BottomSheetScrollView](./docs/scrollview.md) - [BottomSheetView](./docs/flatlist.md) -6. [To Do](#to-do) -7. [Credits](#built-with) -8. [License](#license) +8. [To Do](#to-do) +9. [Credits](#built-with) +10. [License](#license) ## Features @@ -160,6 +162,28 @@ A scrollable node or normal view. > `required:` YES | `type:` React.ReactNode[] | React.ReactNode +## Methods + +#### `snapTo` + +Snap to one of the provided points from `snapPoints`. + +> `type:` (index: number) => void + +#### `close` + +Close the bottom sheet. + +> `type:` () => void + +## Hooks + +#### `useBottomSheet` + +The library provide `useBottomSheet` hook to provide the bottom sheet methods, anywhere inside the sheet content. + +> `type:` { snapTo: () => void, close: () => void } + ## Scrollables This library provides a pre-integrated views that utilise an internal functionalities with the bottom sheet to allow smooth interactions. These views i called them `Scrollables` and they are: diff --git a/src/components/bottomSheet/BottomSheet.tsx b/src/components/bottomSheet/BottomSheet.tsx index 835b85d7..747aa378 100644 --- a/src/components/bottomSheet/BottomSheet.tsx +++ b/src/components/bottomSheet/BottomSheet.tsx @@ -57,7 +57,15 @@ import type { BottomSheetProps } from './types'; import { styles } from './styles'; interface BottomSheet { + /** + * Snap to one of the provided points from `snapPoints`. + * @type (index: number) => void + */ snapTo: (index: number) => void; + /** + * Close the bottom sheet. + * @type () => void + */ close: () => void; } diff --git a/src/context.ts b/src/context.ts index df6ed191..43ca5d7e 100644 --- a/src/context.ts +++ b/src/context.ts @@ -23,7 +23,15 @@ export const BottomSheetInternalContext = createContext< export const BottomSheetInternalProvider = BottomSheetInternalContext.Provider; export interface BottomSheetContextType { + /** + * Snap to one of the provided points from `snapPoints`. + * @type (index: number) => void + */ snapTo: (index: number) => void; + /** + * Close the bottom sheet. + * @type () => void + */ close: () => void; }