Skip to content

Commit

Permalink
chore(storybook): Convert stories from storiesOf to CSF format (#6663)
Browse files Browse the repository at this point in the history
* chore(storybook): convert from storiesOf to CSF format

* chore(storybook): hoist story annotations

* chore(storybook): prep experimental pagination as well

* chore(format): run formatting
  • Loading branch information
tw15egan authored Aug 14, 2020
1 parent 70d5847 commit 5af04eb
Show file tree
Hide file tree
Showing 53 changed files with 4,255 additions and 4,065 deletions.
6 changes: 3 additions & 3 deletions packages/react/src/components/Accordion/Accordion-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ export const accordion = () => (

export const skeleton = () => <AccordionSkeleton open count={4} />;

skeleton.story = {
decorators: [(story) => <div style={{ width: '500px' }}>{story()}</div>],
};
skeleton.decorators = [
(story) => <div style={{ width: '500px' }}>{story()}</div>,
];

const props = {
onClick: action('onClick'),
Expand Down
144 changes: 75 additions & 69 deletions packages/react/src/components/Checkbox/Checkbox-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { withKnobs, boolean, text } from '@storybook/addon-knobs';
import Checkbox from '../Checkbox';
Expand All @@ -25,76 +24,83 @@ const props = () => ({
onChange: action('onChange'),
});

storiesOf('Checkbox', module)
.addParameters({
export default {
title: 'Checkbox',
decorators: [withKnobs],

parameters: {
component: Checkbox,

subcomponents: {
CheckboxSkeleton,
},
})
.addDecorator(withKnobs)
.add(
'checked',
() => {
const checkboxProps = props();
return (
<fieldset className={`${prefix}--fieldset`}>
<legend className={`${prefix}--label`}>Checkbox heading</legend>
<Checkbox defaultChecked {...checkboxProps} id="checkbox-label-1" />
<Checkbox defaultChecked {...checkboxProps} id="checkbox-label-2" />
</fieldset>
);
},
{
info: {
text: `
Checkboxes are used when there is a list of options and the user may select multiple options, including all or none.
The example below shows how the Checkbox component can be used as an uncontrolled component that is initially checked
by setting the defaultChecked property to true. To use the component in a controlled way, you should set the
checked property instead.
`,
},
}
)
.add(
'unchecked',
() => {
const checkboxProps = props();
return (
<fieldset className={`${prefix}--fieldset`}>
<legend className={`${prefix}--label`}>Checkbox heading</legend>
<Checkbox {...checkboxProps} id="checkbox-label-1" />
<Checkbox {...checkboxProps} id="checkbox-label-2" />
</fieldset>
);
},
{
info: {
text: `
Checkboxes are used when there is a list of options and the user may select multiple options, including all or none.
The example below shows how the Checkbox component can be used as an uncontrolled component that is initially
unchecked. To use the component in a controlled way, you should set the checked property instead.
`,
},
}
)
.add(
'skeleton',
() => (
<div
aria-label="loading checkbox"
aria-live="assertive"
role="status"
tabIndex="0" // eslint-disable-line jsx-a11y/no-noninteractive-tabindex
>
<CheckboxSkeleton />
</div>
),
{
info: {
text: `
Placeholder skeleton state to use when content is loading.
`,
},
}
},
};

export const Checked = () => {
const checkboxProps = props();
return (
<fieldset className={`${prefix}--fieldset`}>
<legend className={`${prefix}--label`}>Checkbox heading</legend>
<Checkbox defaultChecked {...checkboxProps} id="checkbox-label-1" />
<Checkbox defaultChecked {...checkboxProps} id="checkbox-label-2" />
</fieldset>
);
};

Checked.storyName = 'checked';

Checked.parameters = {
info: {
text: `
Checkboxes are used when there is a list of options and the user may select multiple options, including all or none.
The example below shows how the Checkbox component can be used as an uncontrolled component that is initially checked
by setting the defaultChecked property to true. To use the component in a controlled way, you should set the
checked property instead.
`,
},
};

export const Unchecked = () => {
const checkboxProps = props();
return (
<fieldset className={`${prefix}--fieldset`}>
<legend className={`${prefix}--label`}>Checkbox heading</legend>
<Checkbox {...checkboxProps} id="checkbox-label-1" />
<Checkbox {...checkboxProps} id="checkbox-label-2" />
</fieldset>
);
};

Unchecked.storyName = 'unchecked';

Unchecked.parameters = {
info: {
text: `
Checkboxes are used when there is a list of options and the user may select multiple options, including all or none.
The example below shows how the Checkbox component can be used as an uncontrolled component that is initially
unchecked. To use the component in a controlled way, you should set the checked property instead.
`,
},
};

export const Skeleton = () => (
<div
aria-label="loading checkbox"
aria-live="assertive"
role="status"
tabIndex="0" // eslint-disable-line jsx-a11y/no-noninteractive-tabindex
>
<CheckboxSkeleton />
</div>
);

Skeleton.storyName = 'skeleton';

Skeleton.parameters = {
info: {
text: `
Placeholder skeleton state to use when content is loading.
`,
},
};
Loading

0 comments on commit 5af04eb

Please sign in to comment.