storybook/docs/snippets/vue/button-story-click-handler-args.ts-2.ts.mdx
2023-01-06 19:15:31 +00:00

39 lines
971 B
Plaintext

```ts
// Button.stories.ts
import Button from './Button.vue';
import type { Meta, StoryObj } from '@storybook/vue';
import { action } from '@storybook/addon-actions';
const meta: Meta<typeof Button> = {
/* 👇 The title prop is optional.
* See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
component: Button,
};
export default meta;
type Story = StoryObj<typeof Button>;
/*
*👇 Render functions are a framework specific feature to allow you control on how the component renders.
* See https://storybook.js.org/docs/7.0/vue/api/csf
* to learn how to use render functions.
*/
export const Text: Story = {
render: (args, { argTypes }) => ({
props: Object.keys(argTypes),
components: { Button },
template: '<Button @onClick="onClick" :label="label" />',
}),
args: {
label: 'Hello',
onClick: action('clicked'),
},
};
```