-
Notifications
You must be signed in to change notification settings - Fork 840
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Storybook] Add stories for more components (letter D) - Part 2 (#7779)
- Loading branch information
Showing
12 changed files
with
455 additions
and
2 deletions.
There are no files selected for viewing
Binary file added
BIN
+2.97 KB
packages/eui/.loki/reference/chrome_desktop_Display_EuiDraggable_Interactive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.83 KB
packages/eui/.loki/reference/chrome_desktop_Display_EuiDraggable_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.14 KB
...es/eui/.loki/reference/chrome_desktop_Display_EuiDroppable_Clone_Draggables.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.91 KB
packages/eui/.loki/reference/chrome_desktop_Display_EuiDroppable_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.71 KB
packages/eui/.loki/reference/chrome_mobile_Display_EuiDraggable_Interactive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.17 KB
packages/eui/.loki/reference/chrome_mobile_Display_EuiDraggable_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.6 KB
...ges/eui/.loki/reference/chrome_mobile_Display_EuiDroppable_Clone_Draggables.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12.8 KB
packages/eui/.loki/reference/chrome_mobile_Display_EuiDroppable_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions
62
packages/eui/src/components/drag_and_drop/drag_drop_context.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React from 'react'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import type { DragDropContextProps } from '@hello-pangea/dnd'; | ||
|
||
import { enableFunctionToggleControls } from '../../../.storybook/utils'; | ||
import { EuiPanel } from '../panel'; | ||
|
||
import { EuiDroppable } from './droppable'; | ||
import { EuiDraggable } from './draggable'; | ||
import { EuiDragDropContext } from './drag_drop_context'; | ||
|
||
const meta: Meta<DragDropContextProps> = { | ||
title: 'Display/EuiDragDropContext', | ||
component: EuiDragDropContext, | ||
parameters: { | ||
loki: { | ||
// EuiDragDropContext doesn't do anything visual, we're testing the | ||
// visual parts with the Drag and Drop components separately | ||
skip: true, | ||
}, | ||
}, | ||
}; | ||
enableFunctionToggleControls(meta, [ | ||
'onBeforeDragStart', | ||
'onDragStart', | ||
'onDragUpdate', | ||
'onDragEnd', | ||
]); | ||
|
||
export default meta; | ||
type Story = StoryObj<DragDropContextProps>; | ||
|
||
export const Playground: Story = { | ||
args: { | ||
children: ( | ||
<EuiDroppable droppableId="droppableArea"> | ||
<EuiDraggable spacing="m" index={0} draggableId="draggable-item-1"> | ||
{(_, state) => ( | ||
<EuiPanel hasShadow={state.isDragging}> | ||
Draggable item 1 {state.isDragging && '✨'} | ||
</EuiPanel> | ||
)} | ||
</EuiDraggable> | ||
<EuiDraggable spacing="m" index={1} draggableId="draggable-item-2"> | ||
{(_, state) => ( | ||
<EuiPanel hasShadow={state.isDragging}> | ||
Draggable item 2 {state.isDragging && '✨'} | ||
</EuiPanel> | ||
)} | ||
</EuiDraggable> | ||
</EuiDroppable> | ||
), | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
packages/eui/src/components/drag_and_drop/draggable.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React from 'react'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { action } from '@storybook/addon-actions'; | ||
|
||
import { hideStorybookControls } from '../../../.storybook/utils'; | ||
import { EuiPanel } from '../panel'; | ||
import { EuiFlexGroup, EuiFlexItem } from '../flex'; | ||
import { EuiIcon } from '../icon'; | ||
import { EuiButton } from '../button'; | ||
|
||
import { EuiDragDropContext } from './drag_drop_context'; | ||
import { EuiDroppable } from './droppable'; | ||
import { EuiDraggable, EuiDraggableProps } from './draggable'; | ||
|
||
const meta: Meta<EuiDraggableProps> = { | ||
title: 'Display/EuiDraggable', | ||
component: EuiDraggable, | ||
decorators: [ | ||
(Story, { args }) => ( | ||
<EuiDragDropContext onDragEnd={action('onDragEnd')}> | ||
<EuiDroppable droppableId="droppableArea"> | ||
<Story {...args} /> | ||
</EuiDroppable> | ||
</EuiDragDropContext> | ||
), | ||
], | ||
argTypes: { | ||
index: { | ||
type: { | ||
name: 'number', | ||
required: true, | ||
}, | ||
}, | ||
draggableId: { | ||
type: { | ||
name: 'string', | ||
required: true, | ||
}, | ||
}, | ||
}, | ||
args: { | ||
customDragHandle: false, | ||
isDragDisabled: false, | ||
hasInteractiveChildren: false, | ||
isRemovable: false, | ||
spacing: 'none', | ||
}, | ||
}; | ||
hideStorybookControls(meta, ['style']); | ||
|
||
export default meta; | ||
type Story = StoryObj<EuiDraggableProps>; | ||
|
||
export const Playground: Story = { | ||
args: { | ||
draggableId: 'draggable-item', | ||
index: 0, | ||
children: <EuiPanel>Draggable item</EuiPanel>, | ||
}, | ||
}; | ||
|
||
export const Interactive: Story = { | ||
parameters: { | ||
controls: { | ||
include: [ | ||
'hasInteractiveChildren', | ||
'isDragDisabled', | ||
'spacing', | ||
'customDragHandle', | ||
], | ||
}, | ||
}, | ||
args: { | ||
draggableId: 'draggable-item', | ||
index: 0, | ||
hasInteractiveChildren: true, | ||
customDragHandle: true, | ||
}, | ||
render: (args) => ( | ||
<EuiDraggable {...args}> | ||
{(provided) => ( | ||
<EuiPanel paddingSize="s"> | ||
<EuiFlexGroup alignItems="center" gutterSize="s" responsive={false}> | ||
<EuiFlexItem grow={false}> | ||
<EuiPanel | ||
color="transparent" | ||
paddingSize="s" | ||
{...provided.dragHandleProps} | ||
aria-label="Drag Handle" | ||
> | ||
<EuiIcon type="grab" /> | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={true}> | ||
<EuiButton fullWidth onClick={action('onButtonClick')}> | ||
Draggable item | ||
</EuiButton> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiPanel> | ||
)} | ||
</EuiDraggable> | ||
), | ||
}; |
Oops, something went wrong.