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

chore: add DpDraggable to Storybook. #497

Merged
merged 12 commits into from
Sep 5, 2023
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Since v0.0.10, this Changelog is formatted according to the [Common Changelog][c

- ([#504](https://github.com/demos-europe/demosplan-ui/pull/504)) Add DpSlidingPagination documentation to Storybook ([@ahmad-demos](https://github.com/@ahmad-demos))
- ([#503](https://github.com/demos-europe/demosplan-ui/pull/503)) Add DpFormRow documentation to Storybook ([@ahmad-demos](https://github.com/@ahmad-demos))
- ([#497](https://github.com/demos-europe/demosplan-ui/pull/497)) Add DpDraggable documentation to Storybook ([@ahmad-demos](https://github.com/@ahmad-demos))
- ([#491](https://github.com/demos-europe/demosplan-ui/pull/491)) Add DpStickyElement documentation to Storybook ([@ahmad-demos](https://github.com/@ahmad-demos))

## v0.1.13 - 2023-08-30
Expand Down
27 changes: 27 additions & 0 deletions src/components/DpDraggable/DpDraggable.stories.mdx
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
spiess-demos marked this conversation as resolved.
Show resolved Hide resolved
v-model="currentList"
:opts="draggableOptions">
<div
v-for="item in currentList"
:key="item.id">
{{ item.name }}
</div>
</dp-draggable>
```

44 changes: 44 additions & 0 deletions src/components/DpDraggable/DpDraggable.stories.tsx
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' }
}
}