2020-07-16 08:42:10 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { storiesOf } from '@storybook/react';
|
2020-09-01 13:55:28 +00:00
|
|
|
import { text, boolean, withKnobs, select } from '@storybook/addon-knobs/react';
|
2020-07-16 08:42:10 +00:00
|
|
|
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 13:38:34 +00:00
|
|
|
const sizeInput = ['base', 'middle', 'big', 'huge', 'large'];
|
2020-07-16 08:42:10 +00:00
|
|
|
|
|
|
|
storiesOf('Components|Input', module)
|
|
|
|
.addDecorator(withKnobs)
|
|
|
|
.addDecorator(withReadme(Readme))
|
2020-07-16 10:08:09 +00:00
|
|
|
.add('file input', () => {
|
2020-07-16 08:42:10 +00:00
|
|
|
|
2020-07-16 10:08:09 +00:00
|
|
|
const placeholder = text('placeholder', 'Input file');
|
2020-07-16 08:42:10 +00:00
|
|
|
const size = select('size', sizeInput, 'base');
|
|
|
|
const scale = boolean('scale', false);
|
|
|
|
const isDisabled = boolean('isDisabled', false);
|
2020-07-16 13:38:34 +00:00
|
|
|
const id = text('id', 'fileInputId');
|
2020-07-17 07:15:58 +00:00
|
|
|
const name = text('name', 'demoFileInputName');
|
2020-07-16 14:40:45 +00:00
|
|
|
const hasError = boolean('hasError', false);
|
|
|
|
const hasWarning = boolean('hasWarning', false);
|
2020-07-17 08:34:52 +00:00
|
|
|
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) => {
|
|
|
|
action('onInput')(file);
|
2020-07-17 11:33:59 +00:00
|
|
|
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>
|
|
|
|
);
|
|
|
|
});
|