Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
122 changes: 104 additions & 18 deletions src-docs/src/views/drag_and_drop/drag_and_drop_custom_handle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import {
EuiDragDropContext,
EuiDraggable,
EuiDroppable,
EuiFlexGroup,
EuiFlexItem,
EuiIcon,
EuiPanel,
euiDragDropReorder,
EuiAccordion,
EuiButtonIcon,
} from '../../../../src/components';
import { htmlIdGenerator } from '../../../../src/services';

Expand All @@ -21,7 +20,7 @@ const makeList = (number, start = 1) =>
};
});

export default () => {
export const Demo = () => {
const [list, setList] = useState(makeList(3));
const onDragEnd = ({ source, destination }) => {
if (source && destination) {
Expand All @@ -37,30 +36,56 @@ export default () => {
spacing="m"
withPanel
>
{list.map(({ content, id }, idx) => (
{list.map(({ id }, idx) => (
<EuiDraggable
spacing="m"
key={id}
index={idx}
draggableId={id}
customDragHandle={true}
hasInteractiveChildren={true}
disableInteractiveElementBlocking
>
{(provided) => (
<EuiPanel paddingSize="s">
<EuiFlexGroup alignItems="center" gutterSize="s">
<EuiFlexItem grow={false}>
<EuiPanel
color="transparent"
paddingSize="s"
<EuiAccordion
id={id}
initialIsOpen={false}
buttonContent={<>Button</>}
extraAction={[
<EuiButtonIcon
key={1}
iconType="grab"
color={'text'}
{...provided.dragHandleProps}
aria-label="Drag Handle"
>
<EuiIcon type="grab" />
</EuiPanel>
</EuiFlexItem>
<EuiFlexItem>{content}</EuiFlexItem>
</EuiFlexGroup>
aria-label="fsdfsdfsd"
/>,
]}
>
dsfds fsd
<br />
dsfds fsd
<br />
dsfds fsd
<br />
dsfds fsd
<br />
dsfds fsd
<br />
dsfds fsd
<br />
dsfds fsd
<br />
dsfds fsd
<br />
dsfds fsd
<br />
dsfds fsd
<br />
dsfds fsd
<br />
dsfds fsd
<br />
</EuiAccordion>
</EuiPanel>
)}
</EuiDraggable>
Expand All @@ -69,3 +94,64 @@ export default () => {
</EuiDragDropContext>
);
};

export default Demo;

// const makeId = htmlIdGenerator();
//
// const makeList = (number, start = 1) =>
// Array.from({ length: number }, (v, k) => k + start).map((el) => {
// return {
// content: `Item ${el}`,
// id: makeId(),
// };
// });
//
// export default () => {
// const [list, setList] = useState(makeList(3));
// const onDragEnd = ({ source, destination }) => {
// if (source && destination) {
// const items = euiDragDropReorder(list, source.index, destination.index);
//
// setList(items);
// }
// };
// return (
// <EuiDragDropContext onDragEnd={onDragEnd}>
// <EuiDroppable
// droppableId="CUSTOM_HANDLE_DROPPABLE_AREA"
// spacing="m"
// withPanel
// >
// {list.map(({ content, id }, idx) => (
// <EuiDraggable
// spacing="m"
// key={id}
// index={idx}
// draggableId={id}
// customDragHandle={true}
// hasInteractiveChildren={true}
// >
// {(provided) => (
// <EuiPanel paddingSize="s">
// <EuiFlexGroup alignItems="center" gutterSize="s">
// <EuiFlexItem grow={false}>
// <EuiPanel
// color="transparent"
// paddingSize="s"
// {...provided.dragHandleProps}
// aria-label="Drag Handle"
// >
// <EuiIcon type="grab" />
// </EuiPanel>
// </EuiFlexItem>
// <EuiFlexItem>{content}</EuiFlexItem>
// </EuiFlexGroup>
// </EuiPanel>
// )}
// </EuiDraggable>
// ))}
// </EuiDroppable>
// </EuiDragDropContext>
// );
// };
Loading