Skip to content

Commit

Permalink
test(storybook): adds simple and multidrag examples
Browse files Browse the repository at this point in the history
  • Loading branch information
waynevanson committed Sep 26, 2020
1 parent 473b45e commit 1664026
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 0 deletions.
21 changes: 21 additions & 0 deletions stories/classic.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.list {
background-color: #ddd;
padding: 1rem;
}

.item {
list-style: none;
padding: 2rem;
border: #0005 solid black;
margin-top: -1px;
margin-bottom: -1px;
background-color: #7cf;
}

.item:first-child {
border-radius: 0.5rem 0.5rem 0 0;
}

.item:last-child {
border-radius: 0 0 0.5rem 0.5rem;
}
32 changes: 32 additions & 0 deletions stories/multi-drag/multi-drag.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// also exported from '@storybook/react' if you can deal with breaking changes in 6.1
import { Meta } from "@storybook/react";
import { ReactSortable, ReactSortableProps } from "../../src";
import { ULLITemplate, ULLITemplateProps } from "../templates/ul-li";

export default {
title: "Example/MultiDrag",
component: ReactSortable,
args: {
animation: 200,
multiDrag: true,
list: [
{
id: "1",
text: "Hello, World!",
},
{
id: "2",
text: "Hello, Earth!",
},
{
id: "3",
text: "Goodbye, World!",
},
],
},
} as Meta<ReactSortableProps<ULLITemplateProps>>;

export const Primary = ULLITemplate.bind({});
Primary.args = {
tag: "ul",
};
26 changes: 26 additions & 0 deletions stories/templates/ul-li.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from "react";
// also exported from '@storybook/react' if you can deal with breaking changes in 6.1
import { Story } from "@storybook/react";
import { ReactSortable, ReactSortableProps } from "../../dist";
import "../classic.css";

export interface ULLITemplateProps {
id: string;
text: string;
}

export const ULLITemplate: Story<ReactSortableProps<ULLITemplateProps>> = (
args
) => {
const [list, setList] = React.useState<ULLITemplateProps[]>(args.list);

return (
<ReactSortable className="list" {...args} list={list} setList={setList}>
{list.map(({ id, text }) => (
<li className="item" key={id}>
{text}
</li>
))}
</ReactSortable>
);
};
31 changes: 31 additions & 0 deletions stories/unary-lists/simple-list.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// also exported from '@storybook/react' if you can deal with breaking changes in 6.1
import { Meta } from "@storybook/react";
import { ReactSortableProps, ReactSortable } from "../../src";
import { ULLITemplate, ULLITemplateProps } from "../templates/ul-li";

export default {
title: "Example/Simple List",
component: ReactSortable,
args: {
animation: 200,
list: [
{
id: "1",
text: "Hello, World!",
},
{
id: "2",
text: "Hello, Earth!",
},
{
id: "3",
text: "Goodbye, World!",
},
],
},
} as Meta<ReactSortableProps<ULLITemplateProps>>;

export const Primary = ULLITemplate.bind({});
Primary.args = {
tag: "ul",
};

0 comments on commit 1664026

Please sign in to comment.