import * as React from 'react'; import { storiesOf } from '@storybook/react'; import { DONATION } from 'utils/constants'; import 'components/AddressInput.less'; import AddressInput, { Props as AddressInputProps } from 'components/AddressInput'; const cases: ExampleProps[] = [ { disp: 'Default Input', props: {}, defaultValue: '', }, { disp: 'Input w/ Identicon', props: { showIdenticon: true, }, }, { disp: 'Input w/ Identicon (large)', props: { showIdenticon: true, inputProps: { size: 'large', }, }, }, { disp: 'Input w/ Identicon (small)', props: { showIdenticon: true, inputProps: { size: 'small', }, }, }, { disp: 'Invalid Input', props: {}, defaultValue: '0x0what', }, ]; storiesOf('AddressInput', module).add('all', () => (
{cases.map(c => ( ))}
)); interface ExampleProps { disp: string; defaultValue?: string; props: Partial; } interface ExampleState { value: string; } class Example extends React.Component { constructor(props: ExampleProps) { super(props); this.state = { value: props.defaultValue !== undefined ? props.defaultValue : DONATION.ZCASH_SPROUT, }; } render() { const props = { ...this.props.props, value: this.state.value, onChange: this.handleChange, }; return (
{this.props.disp}
); } private handleChange = (ev: React.ChangeEvent) => { this.setState({ value: ev.currentTarget.value }); }; }