mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 11:11:53 +08:00
94 lines
2.3 KiB
Markdown
94 lines
2.3 KiB
Markdown
```ts filename="Button.stories.ts" renderer="angular" language="ts"
|
|
import type { Meta } from '@storybook/angular';
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
import Button from './button.component';
|
|
|
|
const meta: Meta<Button> {
|
|
component: Button,
|
|
args: {
|
|
// 👇 Create an action that appears when the onClick event is fired
|
|
onClick: action('on-click'),
|
|
},
|
|
};
|
|
|
|
export default meta;
|
|
```
|
|
|
|
```js filename="Button.stories.js" renderer="common" language="js"
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
import Button from './Button';
|
|
|
|
export default {
|
|
component: Button,
|
|
args: {
|
|
// 👇 Create an action that appears when the onClick event is fired
|
|
onClick: action('on-click'),
|
|
},
|
|
};
|
|
```
|
|
|
|
```ts filename="Button.stories.ts" renderer="common" language="ts-4-9"
|
|
// Replace your-framework with the name of your framework
|
|
import type { Meta } from '@storybook/your-framework';
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
import Button from './Button';
|
|
|
|
const meta {
|
|
component: Button,
|
|
args: {
|
|
// 👇 Create an action that appears when the onClick event is fired
|
|
onClick: action('on-click'),
|
|
},
|
|
} satisfies Meta<typeof Button>;
|
|
|
|
export default meta;
|
|
```
|
|
|
|
```ts filename="Button.stories.ts" renderer="common" language="ts"
|
|
// Replace your-framework with the name of your framework
|
|
import type { Meta } from '@storybook/your-framework';
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
import Button from './Button';
|
|
|
|
const meta: Meta<typeof Button> {
|
|
component: Button,
|
|
args: {
|
|
// 👇 Create an action that appears when the onClick event is fired
|
|
onClick: action('on-click'),
|
|
},
|
|
};
|
|
|
|
export default meta;
|
|
```
|
|
|
|
```ts filename="Button.stories.js" renderer="web-components" language="js"
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
export default {
|
|
component: 'demo-button',
|
|
args: {
|
|
// 👇 Create an action that appears when the onClick event is fired
|
|
onClick: action('on-click'),
|
|
},
|
|
};
|
|
```
|
|
|
|
```ts filename="Button.stories.ts" renderer="web-components" language="ts"
|
|
import type { Meta } from '@storybook/angular';
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
const meta: Meta {
|
|
component: 'demo-button',
|
|
args: {
|
|
// 👇 Create an action that appears when the onClick event is fired
|
|
onClick: action('on-click'),
|
|
},
|
|
};
|
|
|
|
export default meta;
|
|
```
|