|
| 1 | +```svelte filename="MyComponent.stories.svelte" renderer="svelte" language="js" tabTitle="Svelte CSF" |
| 2 | +<script module> |
| 3 | + import { defineMeta } from '@storybook/addon-svelte-csf'; |
| 4 | +
|
| 5 | + import MyComponent from './MyComponent.svelte'; |
| 6 | +
|
| 7 | + const { Story } = defineMeta({ |
| 8 | + component: MyComponent, |
| 9 | + }); |
| 10 | +</script> |
| 11 | +
|
| 12 | +<Story |
| 13 | + name="MyStory" |
| 14 | + parameters={{ |
| 15 | + sveltekit_experimental: { |
| 16 | + hrefs: { |
| 17 | + '/basic-href': (to, event) => { |
| 18 | + console.log(to, event); |
| 19 | + }, |
| 20 | + '/root.*': { |
| 21 | + callback: (to, event) => { |
| 22 | + console.log(to, event); |
| 23 | + }, |
| 24 | + asRegex: true, |
| 25 | + }, |
| 26 | + }, |
| 27 | + }, |
| 28 | + }} |
| 29 | +/> |
| 30 | +``` |
| 31 | + |
| 32 | +```js filename="MyComponent.stories.js" renderer="svelte" language="js" tabTitle="CSF" |
| 33 | +import MyComponent from './MyComponent.svelte'; |
| 34 | + |
| 35 | +export default { |
| 36 | + component: MyComponent, |
| 37 | +}; |
| 38 | + |
| 39 | +export const MyStory = { |
| 40 | + parameters: { |
| 41 | + sveltekit_experimental: { |
| 42 | + hrefs: { |
| 43 | + '/basic-href': (to, event) => { |
| 44 | + console.log(to, event); |
| 45 | + }, |
| 46 | + '/root.*': { |
| 47 | + callback: (to, event) => { |
| 48 | + console.log(to, event); |
| 49 | + }, |
| 50 | + asRegex: true, |
| 51 | + }, |
| 52 | + }, |
| 53 | + }, |
| 54 | + }, |
| 55 | +}; |
| 56 | +``` |
| 57 | + |
| 58 | +```svelte filename="MyComponent.stories.svelte" renderer="svelte" language="ts" tabTitle="Svelte CSF" |
| 59 | +<script module> |
| 60 | + import { defineMeta } from '@storybook/addon-svelte-csf'; |
| 61 | +
|
| 62 | + import MyComponent from './MyComponent.svelte'; |
| 63 | +
|
| 64 | + const { Story } = defineMeta({ |
| 65 | + component: MyComponent, |
| 66 | + }); |
| 67 | +</script> |
| 68 | +
|
| 69 | +<Story |
| 70 | + name="MyStory" |
| 71 | + parameters={{ |
| 72 | + sveltekit_experimental: { |
| 73 | + hrefs: { |
| 74 | + '/basic-href': (to, event) => { |
| 75 | + console.log(to, event); |
| 76 | + }, |
| 77 | + '/root.*': { |
| 78 | + callback: (to, event) => { |
| 79 | + console.log(to, event); |
| 80 | + }, |
| 81 | + asRegex: true, |
| 82 | + }, |
| 83 | + }, |
| 84 | + }, |
| 85 | + }} |
| 86 | +/> |
| 87 | +``` |
| 88 | + |
| 89 | +```ts filename="MyComponent.stories.ts" renderer="svelte" language="ts" tabTitle="CSF" |
| 90 | +import type { Meta, StoryObj } from '@storybook/sveltekit'; |
| 91 | + |
| 92 | +import MyComponent from './MyComponent.svelte'; |
| 93 | + |
| 94 | +const meta = { |
| 95 | + component: MyComponent, |
| 96 | +} satisfies Meta<typeof MyComponent>; |
| 97 | + |
| 98 | +export default meta; |
| 99 | +type Story = StoryObj<typeof meta>; |
| 100 | + |
| 101 | +export const MyStory: Story = { |
| 102 | + parameters: { |
| 103 | + sveltekit_experimental: { |
| 104 | + hrefs: { |
| 105 | + '/basic-href': (to, event) => { |
| 106 | + console.log(to, event); |
| 107 | + }, |
| 108 | + '/root.*': { |
| 109 | + callback: (to, event) => { |
| 110 | + console.log(to, event); |
| 111 | + }, |
| 112 | + asRegex: true, |
| 113 | + }, |
| 114 | + }, |
| 115 | + }, |
| 116 | + }, |
| 117 | +}; |
| 118 | +``` |
0 commit comments