Skip to content

Commit

Permalink
BUG Minor improvement to SingleSelectField story
Browse files Browse the repository at this point in the history
  • Loading branch information
maxime-rainville authored and Garion Herman committed Jul 23, 2020
1 parent b57dcfb commit da65083
Showing 1 changed file with 21 additions and 17 deletions.
@@ -1,46 +1,50 @@
import React from 'react';
// eslint-disable-next-line import/no-extraneous-dependencies
import { storiesOf } from '@storybook/react';
import { withKnobs, text } from '@storybook/addon-knobs';
import { withKnobs, text, boolean, object } from '@storybook/addon-knobs/react';
import SingleSelectField from 'components/SingleSelectField/SingleSelectField';

const props = {
name: 'options',
source: [
{
value: 1,
title: 'One'
title: 'One',
description: 'One is the first number'
},
{
value: 2,
title: 'Two'
title: 'Two',
description: 'Two is the second number'
},
{
value: 3,
title: 'Three'
title: 'Three',
description: 'Three is the third number'
},
{
value: 4,
title: 'Four (Disabled)',
disabled: true
disabled: true,
description: 'Four is the fourth number'
},
],
};

storiesOf('Admin/SingleSelectField', module)
.addDecorator(withKnobs)
.add('Default', () => {
const description = text('Option description');
let newSource = props.source;

if (description && description.length) {
newSource = props.source.map(item => ({ ...item, description }));
}

const newProps = { ...props, source: newSource };

return <SingleSelectField {...newProps} />;
})
.addWithJSX('Default', () => (
<SingleSelectField
{...props}
data={{
hasEmptyDefault: boolean('hasEmptyDefault', false),
emptyString: text('emptyString', 'Choose an option')
}}
value={text('value', 2)}
readOnly={boolean('readOnly', false)}
source={object('source', props.source)}
/>
))
.add('Empty default', () => (
<SingleSelectField
{...props}
Expand Down

0 comments on commit da65083

Please sign in to comment.