Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(DragDropSort): update drag button usage #10356

Merged
merged 2 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ export interface DragDropSortProps extends DndContextProps {
/** Callback when use begins dragging a draggable object */
onDrag?: (event: DragDropSortDragStartEvent, oldIndex: number) => void;
/** The variant determines which component wraps the draggable object.
* Default and defaultWithHandle varaints wrap the draggable object in a div.
* Default variant wraps the draggable object in a div.
* DataList vairant wraps the draggable object in a DataListItem
* DualListSelectorList variant wraps the draggable objects in a DualListSelectorListItem and a div.pf-c-dual-list-selector__item-text element
* TableComposable variant wraps the draggable objects in TODO
* */
variant?: 'default' | 'defaultWithHandle' | 'DataList' | 'DualListSelectorList' | 'TableComposable';
variant?: 'default' | 'DataList' | 'DualListSelectorList' | 'TableComposable';
}

export const DragDropSort: React.FunctionComponent<DragDropSortProps> = ({
Expand Down Expand Up @@ -115,7 +115,7 @@ export const DragDropSort: React.FunctionComponent<DragDropSortProps> = ({
break;
default:
content = (
<Draggable useDragButton={variant === 'defaultWithHandle'} key={item.id} id={item.id} {...item.props}>
<Draggable useDragButton={variant === 'default'} key={item.id} id={item.id} {...item.props}>
{item.content}
</Draggable>
);
Expand Down Expand Up @@ -153,7 +153,7 @@ export const DragDropSort: React.FunctionComponent<DragDropSortProps> = ({
);
default:
return (
<Draggable useDragButton={variant === 'defaultWithHandle'} key={item.id} id={item.id} {...item.props}>
<Draggable useDragButton={variant === 'default'} key={item.id} id={item.id} {...item.props}>
{item.content}
</Draggable>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,99 @@ exports[`renders some divs 1`] = `
>
<div>
<div
aria-describedby="DndDescribedBy-0"
aria-disabled="false"
aria-roledescription="sortable"
class=""
role="button"
tabindex="0"
>
<button
aria-describedby="DndDescribedBy-0"
aria-disabled="false"
aria-label="Drag button"
aria-roledescription="sortable"
class="pf-v6-c-button pf-m-plain"
role="button"
tabindex="0"
>
<span
class="pf-v6-c-data-list__item-draggable-icon"
>
<svg
aria-hidden="true"
class="pf-v6-svg"
fill="currentColor"
height="1em"
role="img"
viewBox="0 0 320 512"
width="1em"
>
<path
d="M96 32H32C14.33 32 0 46.33 0 64v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32V64c0-17.67-14.33-32-32-32zm0 160H32c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zm0 160H32c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zM288 32h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32V64c0-17.67-14.33-32-32-32zm0 160h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zm0 160h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32z"
/>
</svg>
</span>
</button>
one
</div>
<div
aria-describedby="DndDescribedBy-0"
aria-disabled="false"
aria-roledescription="sortable"
class=""
role="button"
tabindex="0"
>
<button
aria-describedby="DndDescribedBy-0"
aria-disabled="false"
aria-label="Drag button"
aria-roledescription="sortable"
class="pf-v6-c-button pf-m-plain"
role="button"
tabindex="0"
>
<span
class="pf-v6-c-data-list__item-draggable-icon"
>
<svg
aria-hidden="true"
class="pf-v6-svg"
fill="currentColor"
height="1em"
role="img"
viewBox="0 0 320 512"
width="1em"
>
<path
d="M96 32H32C14.33 32 0 46.33 0 64v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32V64c0-17.67-14.33-32-32-32zm0 160H32c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zm0 160H32c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zM288 32h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32V64c0-17.67-14.33-32-32-32zm0 160h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zm0 160h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32z"
/>
</svg>
</span>
</button>
two
</div>
<div
aria-describedby="DndDescribedBy-0"
aria-disabled="false"
aria-roledescription="sortable"
class=""
role="button"
tabindex="0"
>
<button
aria-describedby="DndDescribedBy-0"
aria-disabled="false"
aria-label="Drag button"
aria-roledescription="sortable"
class="pf-v6-c-button pf-m-plain"
role="button"
tabindex="0"
>
<span
class="pf-v6-c-data-list__item-draggable-icon"
>
<svg
aria-hidden="true"
class="pf-v6-svg"
fill="currentColor"
height="1em"
role="img"
viewBox="0 0 320 512"
width="1em"
>
<path
d="M96 32H32C14.33 32 0 46.33 0 64v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32V64c0-17.67-14.33-32-32-32zm0 160H32c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zm0 160H32c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zM288 32h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32V64c0-17.67-14.33-32-32-32zm0 160h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zm0 160h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32z"
/>
</svg>
</span>
</button>
three
</div>
</div>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const BasicSortingWithDragButton: React.FunctionComponent = () => {
return (
<DragDropSort
items={items}
variant="defaultWithHandle"
onDrop={(_, newItems) => {
setItems(newItems);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ import { DragDropSort } from '@patternfly/react-drag-drop';

### Basic drag and drop sorting

```ts file="./BasicSorting.tsx"

```

### Basic drag and drop sorting with drag button

```ts file="./BasicSortingWithDragButton.tsx"

```
Loading