mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-19 05:02:40 +08:00
docs: button-story-with-args
This commit is contained in:
parent
1dbe1127b6
commit
7d1651911e
21
docs/snippets/vue/button-story-with-args.js.mdx
Normal file
21
docs/snippets/vue/button-story-with-args.js.mdx
Normal 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',
|
||||
};
|
||||
```
|
@ -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',
|
||||
]}
|
||||
/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user