Skip to content

Commit c2d0afe

Browse files
committed
Add handle component docs
1 parent 1e2d11b commit c2d0afe

4 files changed

Lines changed: 80 additions & 49 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# TODO
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
sidebar_position: 1
3+
description: 'Component that allows to drag an item by a specific area'
4+
---
5+
6+
# Handle
7+
8+
## Overview
9+
10+
The **Handle** component allows you to drag an item by a specific area (part of the item) instead of the whole item.
11+
12+
## Usage
13+
14+
:::info
15+
16+
For the complete usage example, refer to the [Handle](/grid/examples/handle) example.
17+
18+
:::
19+
20+
Use this component within a sortable component's child (item) component.
21+
22+
```tsx
23+
import Sortable from 'react-native-sortables';
24+
25+
// ... other components
26+
<Sortable.Handle>
27+
{/* ... other components */}
28+
<HandleComponent />
29+
{/* ... other components */}
30+
</Sortable.Handle>;
31+
// ... other components
32+
```
33+
34+
## Props
35+
36+
### mode
37+
38+
Determines the reordering behavior of the item.
39+
40+
| type | default | required |
41+
| ------------------------------------------- | ------------- | -------- |
42+
| `'draggable' \| 'fixed' \| 'non-draggable'` | `'draggable'` | NO |
43+
44+
- `'draggable'` - the item **can be dragged** and **moves** when other items are reordered.
45+
- `'non-draggable'` - the item **cannot be dragged** but **moves** when other items are reordered.
46+
- `'fixed'` - the item **cannot be dragged** and **does not move** when other items are reordered.
47+
48+
### children
49+
50+
The handle component (can be anything, e.g. an icon, image, etc.).
51+
52+
| type | default | required |
53+
| ----------- | ------- | -------- |
54+
| `ReactNode` | NO | NO |

packages/docs/docs/helper-components/layer.mdx

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
sidebar_position: 1
3-
description: ''
2+
sidebar_position: 3
3+
description: 'Component managing zIndex when an item is being dragged'
44
---
55

66
# Layer
@@ -31,19 +31,15 @@ The **Sortable Layer** component should be used only when necessary, i.e. if you
3131
```tsx
3232
import Sortable from 'react-native-sortables';
3333

34-
function MyComponent() {
35-
return (
36-
// ... other components
37-
<Sortable.Layer>
38-
{/* ... other components */}
39-
<Sortable.Grid // or Sortable.Flex
40-
// ... sortable grid props
41-
/>
42-
{/* ... other components */}
43-
</Sortable.Layer>
44-
// ... other components
45-
);
46-
}
34+
// ... other components
35+
<Sortable.Layer>
36+
{/* ... other components */}
37+
<Sortable.Grid // or Sortable.Flex
38+
// ... sortable grid props
39+
/>
40+
{/* ... other components */}
41+
</Sortable.Layer>;
42+
// ... other components
4743
```
4844

4945
## Props

packages/docs/docs/helper-components/touchables.mdx

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
sidebar_position: 2
3-
description: ''
3+
description: 'Components that work well with sortable component gesture detectors'
44
---
55

66
# Touchables
@@ -24,45 +24,25 @@ Use these components when you need to add **interactive elements** (buttons, lin
2424

2525
## Usage
2626

27-
Use these components withing a sortable component's child (item) component.
27+
:::info
2828

29-
```tsx
30-
import Sortable from 'react-native-sortables';
29+
For the complete usage example, refer to the [Touchables](/grid/examples/touchables) example.
3130

32-
function Item({ item }: { item: string }) {
33-
return (
34-
// ... other components
35-
<Sortable.Pressable
36-
onPress={() => {
37-
console.log('pressed');
38-
}}>
39-
{/* ... other components */}
40-
</Sortable.Pressable>
41-
// ... other components
42-
);
43-
}
44-
```
31+
:::
4532

46-
And, for example, if you use the **Sortable Grid** component:
33+
Use these components withing a sortable component's child (item) component.
4734

4835
```tsx
49-
import { useCallback } from 'react';
5036
import Sortable from 'react-native-sortables';
51-
import type { SortableGridRenderItem } from 'react-native-sortables';
52-
53-
export default function Grid() {
54-
const renderItem = useCallback<SortableGridRenderItem<string>>(
55-
({ item }) => <Item item={item} />,
56-
[]
57-
);
58-
59-
return (
60-
<Sortable.Grid
61-
renderItem={renderItem}
62-
// ... other props
63-
/>
64-
);
65-
}
37+
38+
// ... other components
39+
<Sortable.Pressable
40+
onPress={() => {
41+
console.log('pressed');
42+
}}>
43+
{/* ... other components */}
44+
</Sortable.Pressable>;
45+
// ... other components
6646
```
6747

6848
## Props

0 commit comments

Comments
 (0)