saleor-dashboard/src/storybook/stories/components/Checkbox.tsx

40 lines
1.1 KiB
TypeScript
Raw Normal View History

import Checkbox, { CheckboxProps } from "@saleor/components/Checkbox";
import Form from "@saleor/components/Form";
2019-06-19 14:40:52 +00:00
import { storiesOf } from "@storybook/react";
2019-08-09 10:26:22 +00:00
import React from "react";
2019-06-19 14:40:52 +00:00
import CardDecorator from "../../CardDecorator";
import Decorator from "../../Decorator";
const props: CheckboxProps = {
checked: false,
name: "data"
};
storiesOf("Generics / Checkbox", module)
.addDecorator(CardDecorator)
.addDecorator(Decorator)
.add("checked", () => <Checkbox {...props} checked={true} />)
.add("unchecked", () => <Checkbox {...props} />)
.add("undeterminate", () => <Checkbox {...props} indeterminate={true} />)
.add("disabled", () => <Checkbox {...props} disabled={true} />)
.add("interactive", () => (
<Form initial={{ data: false }}>
{({ change, data }) => (
<Checkbox
{...props}
checked={data.data}
// Omit second argument
onChange={() =>
change({
target: {
name: "data",
value: !data.data
}
} as any)
}
/>
)}
</Form>
));