mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 07:01:53 +08:00
25 lines
840 B
Plaintext
25 lines
840 B
Plaintext
```html
|
|
<!-- YourComponent.stories.svelte -->
|
|
|
|
<script>
|
|
import { Meta, Template, Story } from '@storybook/addon-svelte-csf';
|
|
|
|
import YourComponent from './YourComponent.svelte';
|
|
|
|
//👇 Some function to demonstrate the behavior
|
|
function someFunction(valuePropertyA, valuePropertyB) {
|
|
// Makes some computations and returns something
|
|
}
|
|
</script>
|
|
|
|
<!--👇 Creates specific argTypes and automatically infers them when 'options' is defined -->
|
|
|
|
<Meta title="YourComponent" component={YourComponent} argTypes={{ propertyA: { options: ['Item One',
|
|
'Item Two', 'Item Three'], control: { type: 'select' }, }, propertyB: { options: ['Another Item
|
|
One', 'Another Item Two', 'Another Item Three'], }, }} />
|
|
|
|
<template let:args>
|
|
<YourComponent {...args} someProperty="{someFunction(args.propertyA," args.propertyB)} />
|
|
</template>
|
|
```
|