storybook/docs/snippets/vue/button-story-using-args.ts-3.ts.mdx

35 lines
964 B
Plaintext

```ts
// Button.stories.ts
import Button from './Button.vue';
import { Meta, StoryFn } from '@storybook/vue3';
export default {
/* 👇 The title prop is optional.
* See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
component: Button,
} as Meta<typeof Button>;
//👇 We create a “template” of how args map to rendering
const Template: StoryFn<typeof Button> = (args) => ({
components: { Button },
setup() {
return { args };
},
template: '<Button v-bind="args" />',
});
//👇 Each story then reuses that template
export const Primary = Template.bind({});
Primary.args = { background: '#ff0', label: 'Button' };
export const Secondary = Template.bind({});
Secondary.args = { ...Primary.args, label: '😄👍😍💯' };
export const Tertiary = Template.bind({});
Tertiary.args = { ...Primary.args, label: '📚📕📈🤓' };
```