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

39 lines
931 B
Plaintext

```ts
// Button.stories.ts
import Button from './Button.vue';
import type { Meta, StoryObj } from '@storybook/vue3';
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: () => ({
components: { Button },
setup() {
return {
onClick: action('clicked'),
};
},
template: '<Button label="Hello" @click="onClick" />',
}),
};
```