mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 07:21:17 +08:00
Adds AutoDocs webcomponent snippet (js/ts)
This commit is contained in:
parent
accab669d2
commit
befbe50cbe
29
docs/snippets/web-components/button-story-auto-docs.js.mdx
Normal file
29
docs/snippets/web-components/button-story-auto-docs.js.mdx
Normal file
@ -0,0 +1,29 @@
|
||||
```js
|
||||
// Button.stories.js
|
||||
|
||||
import { Button } from './Button';
|
||||
|
||||
export default {
|
||||
title: 'Button',
|
||||
render: (args) => Button(args),
|
||||
//👇 Enables auto-generated documentation for the component story
|
||||
tags: ['docsPage'],
|
||||
argTypes: {
|
||||
backgroundColor: { control: 'color' },
|
||||
},
|
||||
};
|
||||
|
||||
export const Primary = {
|
||||
args: {
|
||||
primary: true,
|
||||
label: 'Button',
|
||||
},
|
||||
};
|
||||
|
||||
export const Secondary = {
|
||||
args: {
|
||||
...Primary.args,
|
||||
primary: false,
|
||||
},
|
||||
};
|
||||
```
|
34
docs/snippets/web-components/button-story-auto-docs.ts.mdx
Normal file
34
docs/snippets/web-components/button-story-auto-docs.ts.mdx
Normal file
@ -0,0 +1,34 @@
|
||||
```ts
|
||||
// Button.stories.ts
|
||||
|
||||
import type { Meta, StoryObj } from '@storybook/web-components';
|
||||
import type { ButtonProps } from './Button';
|
||||
import { Button } from './Button';
|
||||
|
||||
const Meta: Meta<ButtonProps> = {
|
||||
title: 'Button',
|
||||
render: (args) => Button(args),
|
||||
//👇 Enables auto-generated documentation for the component story
|
||||
tags: ['docsPage'],
|
||||
argTypes: {
|
||||
backgroundColor: { control: 'color' },
|
||||
},
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<ButtonProps>;
|
||||
|
||||
export const Primary: Story = {
|
||||
args: {
|
||||
primary: true,
|
||||
label: 'Button',
|
||||
},
|
||||
};
|
||||
|
||||
export const Secondary: Story = {
|
||||
args: {
|
||||
...Primary.args,
|
||||
primary: false,
|
||||
},
|
||||
};
|
||||
```
|
@ -24,6 +24,8 @@ To enable auto-generated documentation for your stories, you'll need to add the
|
||||
'vue/button-story-auto-docs.ts.mdx',
|
||||
'angular/button-story-auto-docs.ts.mdx',
|
||||
'svelte/button-story-auto-docs.js.mdx',
|
||||
'web-components/button-story-auto-docs.js.mdx',
|
||||
'web-components/button-story-auto-docs.ts.mdx',
|
||||
]}
|
||||
/>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user