docs: button-story-with-args

This commit is contained in:
andrekisi 2020-09-15 23:25:07 +02:00
parent 1dbe1127b6
commit 7d1651911e
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,21 @@
```js
// Button.stories.js
import Button from './Button';
export default { title: 'Components/Button' };
// We create a “template” of how args map to rendering
const Template = (args, { argTypes }) => ({
components: { Button },
props: Object.keys(argTypes),
template: '<Button :primary="primary" :label="label" />',
});
// Each story then reuses that template
export const Primary = Template.bind({});
Primary.args = {
primary: true,
label: 'Primary',
};
```

View File

@ -22,6 +22,7 @@ To define the args of a single story, use the `args` CSF story key:
paths={[
'react/button-story-with-args.js.mdx',
'react/button-story-with-args.ts.mdx',
'vue/button-story-with-args.js.mdx',
'angular/button-story-with-args.ts.mdx',
]}
/>