2020-10-16 13:16:01 +00:00
|
|
|
import React from "react";
|
|
|
|
import { storiesOf } from "@storybook/react";
|
|
|
|
import { text, boolean, withKnobs, select } from "@storybook/addon-knobs/react";
|
|
|
|
import withReadme from "storybook-readme/with-readme";
|
|
|
|
import Readme from "./README.md";
|
|
|
|
import FileInput from ".";
|
|
|
|
import Section from "../../../.storybook/decorators/section";
|
|
|
|
import { action } from "@storybook/addon-actions";
|
2020-07-16 08:42:10 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
const sizeInput = ["base", "middle", "big", "huge", "large"];
|
2020-07-16 08:42:10 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
storiesOf("Components|Input", module)
|
2020-07-16 08:42:10 +00:00
|
|
|
.addDecorator(withKnobs)
|
|
|
|
.addDecorator(withReadme(Readme))
|
2020-10-16 13:16:01 +00:00
|
|
|
.add("file input", () => {
|
|
|
|
const placeholder = text("placeholder", "Input file");
|
|
|
|
const size = select("size", sizeInput, "base");
|
|
|
|
const scale = boolean("scale", false);
|
|
|
|
const isDisabled = boolean("isDisabled", false);
|
|
|
|
const id = text("id", "fileInputId");
|
|
|
|
const name = text("name", "demoFileInputName");
|
|
|
|
const hasError = boolean("hasError", false);
|
|
|
|
const hasWarning = boolean("hasWarning", false);
|
|
|
|
const accept = text("accept", ".doc, .docx");
|
2020-07-16 08:42:10 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Section>
|
|
|
|
<FileInput
|
2020-07-16 14:40:45 +00:00
|
|
|
id={id}
|
|
|
|
name={name}
|
2020-07-16 08:42:10 +00:00
|
|
|
placeholder={placeholder}
|
|
|
|
size={size}
|
|
|
|
scale={scale}
|
2020-07-16 13:38:34 +00:00
|
|
|
isDisabled={isDisabled}
|
2020-07-16 14:40:45 +00:00
|
|
|
hasError={hasError}
|
|
|
|
hasWarning={hasWarning}
|
2020-07-17 08:34:52 +00:00
|
|
|
accept={accept}
|
2020-07-17 08:49:54 +00:00
|
|
|
onInput={(file) => {
|
2020-10-16 13:16:01 +00:00
|
|
|
action("onInput")(file);
|
|
|
|
console.log(
|
|
|
|
`name: ${file.name}`,
|
|
|
|
`lastModified: ${file.lastModifiedDate}`,
|
|
|
|
`size: ${file.size}`
|
|
|
|
);
|
2020-07-17 08:31:23 +00:00
|
|
|
}}
|
2020-07-16 08:42:10 +00:00
|
|
|
/>
|
|
|
|
</Section>
|
|
|
|
);
|
2020-10-16 13:16:01 +00:00
|
|
|
});
|