Skip to content

Commit

Permalink
MINOR Improve checkbox field story in pattern lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Rainville authored and bergice committed Oct 25, 2018
1 parent 85e3049 commit 06a4c42
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions client/src/components/CheckboxField/CheckboxField.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import fieldHolder from 'components/FieldHolder/FieldHolder';
import OptionField from 'components/OptionsetField/OptionField';

// Build inner field
const CheckboxField = (props) => (
const Checkbox = (props) => (
<OptionField {...props} type="checkbox" />
);

// Build holder
const CheckboxWithHolder = (props) => {
const FieldHolder = fieldHolder(CheckboxField);
const CheckboxField = (props) => {
const FieldHolder = fieldHolder(Checkbox);
// set to not show field holder labels, as checkbox already generates a label
return <FieldHolder {...props} hideLabels />;
};

export { CheckboxField as Component };
export { Checkbox as Component };

export default CheckboxWithHolder;
export default CheckboxField;
30 changes: 15 additions & 15 deletions client/src/components/CheckboxField/tests/CheckboxField-story.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import React from 'react';
// eslint-disable-next-line import/no-extraneous-dependencies
import { storiesOf } from '@storybook/react';
import { storiesOf, setAddon } from '@storybook/react';
import { withKnobs, text, select } from '@storybook/addon-knobs/react';
import JSXAddon from 'storybook-addon-jsx';

import CheckboxField from 'components/CheckboxField/CheckboxField';
import ValueTracker from 'stories/ValueTracker';

const props = {
title: 'one',
value: '1',
};
setAddon(JSXAddon);

storiesOf('Admin/CheckboxField', module)
storiesOf('Admin/FormFields', module)
.addDecorator((storyFn) => (
<ValueTracker>{storyFn()}</ValueTracker>
))
.add('Checkbox', () => (
<CheckboxField
{...props}
/>
))
.add('All titles', () => (
.addDecorator(withKnobs)
.addWithJSX('CheckboxField', () => (
<CheckboxField
{...props}
message={{ type: 'error', value: 'My error message' }}
description="This is a description"
title={text('title', 'a checkbox field')}
value={text('value', '1')}
message={{
type: select('message type', ['', 'error'], 'error'),
value: text('message', 'A message about the field.') }
}
description={text('description', 'A description of the field.')}
/>
));

0 comments on commit 06a4c42

Please sign in to comment.