mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-06 07:21:16 +08:00
30 lines
802 B
Plaintext
30 lines
802 B
Plaintext
```js
|
|
// Button.stories.js
|
|
|
|
import Button from './Button.svelte';
|
|
|
|
export default {
|
|
/* 👇 The title prop is optional.
|
|
* See https://storybook.js.org/docs/svelte/configure/overview#configure-story-loading
|
|
* to learn how to generate automatic titles
|
|
*/
|
|
title: 'Button',
|
|
component: Button,
|
|
};
|
|
|
|
//👇 We create a “template” of how args map to rendering
|
|
const Template = (args) => ({
|
|
Component: Button,
|
|
props: 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: '📚📕📈🤓' };
|
|
``` |