2019-07-15 12:53:12 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { storiesOf } from '@storybook/react';
|
|
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
import { StringValue } from 'react-values';
|
2019-12-03 14:17:53 +00:00
|
|
|
import { withKnobs, boolean, text, select } from '@storybook/addon-knobs/react';
|
2019-07-15 12:53:12 +00:00
|
|
|
import withReadme from 'storybook-readme/with-readme';
|
|
|
|
import Readme from './README.md';
|
2019-09-08 15:45:59 +00:00
|
|
|
import SearchInput from '.';
|
|
|
|
import Button from '../button';
|
2019-07-15 12:53:12 +00:00
|
|
|
import Section from '../../../.storybook/decorators/section';
|
|
|
|
|
|
|
|
const sizeOptions = ['base', 'middle', 'big', 'huge'];
|
2019-08-08 09:45:00 +00:00
|
|
|
|
|
|
|
class SearchStory extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
2019-12-25 06:47:42 +00:00
|
|
|
value: "test1"
|
2019-08-08 09:45:00 +00:00
|
|
|
};
|
|
|
|
this.buttonClick = this.buttonClick.bind(this);
|
2019-07-15 12:53:12 +00:00
|
|
|
}
|
2019-08-08 09:45:00 +00:00
|
|
|
buttonClick(){
|
2019-12-25 06:47:42 +00:00
|
|
|
this.setState({ value: "test"});
|
2019-08-08 09:45:00 +00:00
|
|
|
}
|
|
|
|
render(){
|
|
|
|
return(
|
|
|
|
<Section>
|
2019-07-15 12:53:12 +00:00
|
|
|
<StringValue
|
2019-08-27 08:54:38 +00:00
|
|
|
onChange={value => {
|
|
|
|
action('onChange')(value);
|
2019-07-15 12:53:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
>
|
|
|
|
{({ value, set }) => (
|
|
|
|
<Section>
|
2019-08-08 09:45:00 +00:00
|
|
|
<div style={{marginBottom: '20px'}}>
|
|
|
|
<Button
|
|
|
|
label="Change props"
|
|
|
|
onClick={this.buttonClick}
|
|
|
|
/>
|
|
|
|
</div>
|
2019-07-15 12:53:12 +00:00
|
|
|
<SearchInput
|
|
|
|
id={text('id', '')}
|
|
|
|
isDisabled={boolean('isDisabled', false)}
|
|
|
|
size={select('size', sizeOptions, 'base')}
|
|
|
|
scale={boolean('scale', false)}
|
|
|
|
placeholder={text('placeholder', 'Search')}
|
|
|
|
value={value}
|
2019-08-27 08:54:38 +00:00
|
|
|
onChange={value => {
|
|
|
|
set(value);
|
2019-07-15 12:53:12 +00:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Section>
|
|
|
|
)}
|
|
|
|
</StringValue>
|
2019-08-08 09:45:00 +00:00
|
|
|
</Section>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
storiesOf('Components|Input', module)
|
|
|
|
.addDecorator(withKnobs)
|
|
|
|
.addDecorator(withReadme(Readme))
|
|
|
|
.add('search', () => (
|
|
|
|
<SearchStory />
|
2019-07-15 12:53:12 +00:00
|
|
|
));
|