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 SingleSelectField from "@saleor/components/SingleSelectField";
|
|
|
|
import CardDecorator from "../../CardDecorator";
|
|
|
|
import Decorator from "../../Decorator";
|
|
|
|
|
|
|
|
const choices = [
|
|
|
|
{ value: "1", label: "Apparel" },
|
|
|
|
{ value: "2", label: "Groceries" },
|
|
|
|
{ value: "3", label: "Books" },
|
|
|
|
{ value: "4", label: "Accessories" }
|
|
|
|
];
|
|
|
|
|
|
|
|
storiesOf("Generics / SingleSelectField", module)
|
|
|
|
.addDecorator(CardDecorator)
|
|
|
|
.addDecorator(Decorator)
|
|
|
|
.add("with no value", () => (
|
|
|
|
<SingleSelectField choices={choices} onChange={undefined} />
|
|
|
|
))
|
|
|
|
.add("with value", () => (
|
|
|
|
<SingleSelectField
|
|
|
|
choices={choices}
|
|
|
|
onChange={undefined}
|
|
|
|
value={choices[0].value}
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
.add("with label", () => (
|
|
|
|
<SingleSelectField
|
|
|
|
choices={choices}
|
|
|
|
onChange={undefined}
|
|
|
|
label="Lorem ipsum"
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
.add("with hint", () => (
|
|
|
|
<SingleSelectField
|
|
|
|
choices={choices}
|
|
|
|
onChange={undefined}
|
|
|
|
hint="Lorem ipsum"
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
.add("with label and hint", () => (
|
|
|
|
<SingleSelectField
|
|
|
|
choices={choices}
|
|
|
|
onChange={undefined}
|
|
|
|
label="Lorem"
|
|
|
|
hint="Ipsum"
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
.add("with value, label and hint", () => (
|
|
|
|
<SingleSelectField
|
|
|
|
choices={choices}
|
|
|
|
onChange={undefined}
|
|
|
|
value={choices[0].value}
|
|
|
|
label="Lorem"
|
|
|
|
hint="Ipsum"
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
.add("with error hint", () => (
|
|
|
|
<SingleSelectField
|
|
|
|
choices={choices}
|
|
|
|
onChange={undefined}
|
|
|
|
hint="Lorem error"
|
|
|
|
error={true}
|
|
|
|
/>
|
|
|
|
));
|