-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add DpDraggable to Storybook. (#497)
* chore: add DpDraggable to Storybook. * chore: add CHANGELOG * Update src/components/DpDraggable/DpDraggable.stories.mdx Co-authored-by: spiess-demos <40452344+spiess-demos@users.noreply.github.com> * chore: adjust Docu. * chore: adjust Docu. * chore: adjust Docu. * chore: rebuild DpDraggable template. --------- Co-authored-by: spiess-demos <40452344+spiess-demos@users.noreply.github.com>
- Loading branch information
1 parent
573a372
commit c55eaa2
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
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
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,27 @@ | ||
import { Meta } from '@storybook/addon-docs' | ||
import DpDraggable from './DpDraggable' | ||
|
||
<Meta | ||
title="Components/Draggable" | ||
component={DpDraggable} | ||
/> | ||
|
||
# Draggable | ||
|
||
Use the Draggable component to change the order of items within a list. | ||
|
||
|
||
## Default usage | ||
|
||
```html | ||
<dp-draggable | ||
v-model="currentList" | ||
:opts="draggableOptions"> | ||
<div | ||
v-for="item in currentList" | ||
:key="item.id"> | ||
{{ item.name }} | ||
</div> | ||
</dp-draggable> | ||
``` | ||
|
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,44 @@ | ||
import type { Meta, StoryObj } from '@storybook/vue' | ||
import DpDraggable from './DpDraggable.vue' | ||
|
||
interface IDpDraggable { | ||
contentData: object[] | ||
'data:change': object | ||
} | ||
|
||
const meta: Meta<typeof DpDraggable> = { | ||
component: DpDraggable, | ||
title: "Components/Draggable", | ||
render: (args) => ({ | ||
components: { | ||
DpDraggable, | ||
}, | ||
setup() { | ||
return { args } | ||
}, | ||
template: `<dp-draggable v-model="args.contentData" v-bind="args"> | ||
<div | ||
class="o-sortablelist__item u-pv-0_5 u-pl-0_5 border--top" | ||
v-for="item in args.contentData" | ||
:key="item.id"> | ||
{{ item.label }} | ||
</div> | ||
</dp-draggable>`, | ||
}) | ||
} | ||
|
||
type Story = StoryObj<IDpDraggable> | ||
|
||
export default meta | ||
|
||
export const Default: Story = { | ||
args: { | ||
contentData: [ | ||
{ label: 'Content 1', id: '1' }, | ||
{ label: 'Content 2', id: '2' } | ||
] | ||
}, | ||
argTypes: { | ||
'data:change': { action: 'data:change' } | ||
} | ||
} |