mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 05:31:05 +08:00
39 lines
790 B
Plaintext
39 lines
790 B
Plaintext
```ts
|
|
// Button.stories.ts
|
|
|
|
import { Story, Meta } from '@storybook/angular/types-6-0';
|
|
|
|
import Button from './button.component';
|
|
|
|
export default {
|
|
title: 'Button',
|
|
component: Button,
|
|
argTypes: {
|
|
backgroundColor: { control: 'color' }
|
|
}
|
|
} as Meta;
|
|
|
|
// some function to demonstrate the behavior
|
|
const someFunction = (someValue: string) => {
|
|
return `i am a ${someValue}`;
|
|
};
|
|
|
|
export const ExampleStory: Story<Button> = (args) => {
|
|
const { label } = args;
|
|
// assigns the function result to a variable and pass it as a prop into the component
|
|
const functionResult = someFunction(label);
|
|
return {
|
|
component: Button,
|
|
props: {
|
|
...args,
|
|
label: functionResult,
|
|
},
|
|
};
|
|
};
|
|
ExampleStory.args = {
|
|
primary: true,
|
|
size: 'small',
|
|
label: 'button',
|
|
};
|
|
```
|