Skip to content

Commit dee6247

Browse files
authored
feat(docs): add draggable demos to component pages (#11112)
1 parent 849b347 commit dee6247

File tree

2 files changed

+32
-18
lines changed

2 files changed

+32
-18
lines changed

packages/react-core/src/components/DataList/examples/DataList.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import AngleDownIcon from '@patternfly/react-icons/dist/esm/icons/angle-down-ico
2323
import AngleRightIcon from '@patternfly/react-icons/dist/esm/icons/angle-right-icon';
2424
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
2525
import { css } from '@patternfly/react-styles';
26-
import { DragDrop, Draggable, Droppable } from '@patternfly/react-core/deprecated';
26+
import { DragDropSort, DragDropContainer, Droppable as NewDroppable } from '@patternfly/react-drag-drop';
2727

2828
## Examples
2929

@@ -83,11 +83,23 @@ import { DragDrop, Draggable, Droppable } from '@patternfly/react-core/deprecate
8383

8484
### Draggable
8585

86-
Note: There is a new recommended drag and drop implementation with full keyboard functionality, which replaces this implementation. To adhere to our new recommendations, refer to the [drag and drop demos](/components/drag-and-drop/react-demos).
86+
To enable drag and drop, wrap the `<DataList>` component with `<DragDropSort>`, define the `variant` property as "DataList", and pass both the sortable items and `onDrop` callback to `<DragDropSort>`. `<DragDropSort>` will create the component's usual children internally based on the items property, so children should not be passed to the wrapped component.
8787

88-
Previously, draggable data lists had their own API for the [drag and drop component](/components/drag-and-drop), which wasn't flexible enough to allow custom styling for items as they are dragged. To address this disparity, `<DragDrop>`, `<Draggable>`, and `<Droppable>` components were added to replace our now deprecated HTML5-based API. Keyboard and screen reader accessibility for the `<DragDrop>` component is still in development.
88+
Full drag and drop details can be found on the [drag and drop](/components/drag-and-drop) component page.
8989

90-
```ts isDeprecated file="./DataListDraggable.tsx"
90+
```ts file="../../../../../react-drag-drop/src/components/DragDrop/examples/DataListDraggable.tsx"
91+
92+
```
93+
94+
### Draggable with multiple drop zones
95+
96+
To enable multiple drop zones, and create the desired amount of `<Droppable>` components within a `<DragDropContainer>`.
97+
98+
Each `<Droppable>` should define the `wrapper` property as the component that acts as the drop zone, `<DataList>`, and the `items` property of their respective draggable items as an array of `<DraggableObject>` data. `<DragDropContainer>` should be passed the `onDrop`, `onContainerMove`, and `onCancel` callbacks to handle items being dropped, items moving between droppable containers, and what happens if the drag is cancelled respectively. `<DragDropContainer>` should also be given a `Record` representing all sortable drop zones' items. Both components should define the `variant` property as "DataList".
99+
100+
Full drag and drop details can be found on the [drag and drop](/components/drag-and-drop) component page.
101+
102+
```ts file="../../../../../react-drag-drop/src/components/DragDrop/examples/DragDropContainerDataList.tsx"
91103

92104
```
93105

packages/react-core/src/components/DualListSelector/examples/DualListSelector.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import AngleRightIcon from '@patternfly/react-icons/dist/esm/icons/angle-right-i
2222
import PficonSortCommonAscIcon from '@patternfly/react-icons/dist/esm/icons/pficon-sort-common-asc-icon';
2323
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
2424
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
25-
import { DragDrop, Draggable, Droppable } from '@patternfly/react-core/deprecated';
25+
import { DragDropSort, DragDropContainer, Droppable as NewDroppable } from '@patternfly/react-drag-drop';
2626

2727
## Examples
2828

@@ -78,22 +78,24 @@ The dual list selector is built in a composable manner to make customization eas
7878

7979
```
8080

81-
### Drag and drop
81+
### Draggable
8282

83-
This example only allows reordering the contents of the "chosen" pane with drag and drop. To make a pane able to be reordered:
83+
To enable drag and drop, wrap the `<DualListSelectorList>` component with `<DragDropSort>`, define the `variant` property as "DualListSelectorList", and pass both the sortable items and `onDrop` callback to `<DragDropSort>`. `<DragDropSort>` will create the component's usual children internally based on the items property, so children inside the `<DualListSelectorList>` should not be passed to the wrapped component.
8484

85-
- wrap the `DualListSelectorPane` in a `DragDrop` component
86-
- wrap the `DualListSelectorList` in a `Droppable` component
87-
- wrap the `DualListSelectorListItem` components in a `Draggable` component
88-
- define an `onDrop` callback which reorders the sortable options.
89-
- The `onDrop` function provides the starting location and destination location for a dragged item. It should return
90-
true to enable the 'drop' animation in the new location and false to enable the 'drop' animation back to the item's
91-
old position.
92-
- define an `onDrag` callback which ensures that the drag event will not cross hairs with the `onOptionSelect` click
93-
event set on the option. Note: the `ignoreNextOptionSelect` state value is used to prevent selection while dragging.
85+
Full drag and drop details can be found on the [drag and drop](/components/drag-and-drop) component page.
9486

95-
Note: Keyboard accessibility and screen reader accessibility for the `DragDrop` component are still in development.
87+
```ts file="../../../../../react-drag-drop/src/components/DragDrop/examples/DualListSelectorDraggable.tsx"
9688

97-
```ts file="DualListSelectorDragDrop.tsx"
89+
```
90+
91+
### Draggable with multiple drop zones
92+
93+
To enable multiple drop zones, wrap the `<DualListSelector>` component with `<DragDropContainer>`, and create the desired amount of `<Droppable>` components within `<DragDropContainer>`. `<Droppable>` components should be located where `<DualListSelectorList>` usually would go for each pane to be made draggable.
94+
95+
Each `<Droppable>` should define the `wrapper` property as the component that acts as the drop zone, `<DualListSelectorList>`, and the `items` property of their respective draggable items as an array of `<DraggableObject>` data. `<DragDropContainer>` should be passed the `onDrop`, `onContainerMove`, and `onCancel` callbacks to handle items being dropped, items moving between droppable containers, and what happens if the drag is cancelled respectively. `<DragDropContainer>` should also be given a `Record` representing all sortable drop zones' items. Both components should define the `variant` property as "DualListSelectorList".
96+
97+
Full drag and drop details can be found on the [drag and drop](/components/drag-and-drop) component page.
98+
99+
```ts file="../../../../../react-drag-drop/src/components/DragDrop/examples/DragDropContainerDualListSelector.tsx"
98100

99101
```

0 commit comments

Comments
 (0)