Skip to content

Commit

Permalink
Add Svelte code snippet for decorators contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
rChaoz committed Apr 20, 2024
1 parent 479b8e9 commit 00774b9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
@@ -0,0 +1,14 @@
```js
// .storybook/preview.js

import { setContext } from 'svelte';

export default {
decorators: [
(Story) => {
setContext("theme", "default");
return Story();
},
],
};
```
@@ -0,0 +1,18 @@
```ts
// .storybook/preview.ts

import { setContext } from 'svelte';

import type { Preview } from '@storybook/svelte';

const preview: Preview = {
decorators: [
(Story) => {
setContext("theme", "default");
return Story();
},
],
};

export default preview;
```
2 changes: 2 additions & 0 deletions docs/writing-stories/decorators.md
Expand Up @@ -58,6 +58,8 @@ For example, if you're working with React's Styled Components and your component
'angular/storybook-preview-with-angular-polyfills.js.mdx',
'solid/storybook-preview-with-styled-components-decorator.js.mdx',
'solid/storybook-preview-with-styled-components-decorator.ts.mdx',
'svelte/storybook-preview-with-styled-components-decorator.js.mdx',
'svelte/storybook-preview-with-styled-components-decorator.ts.mdx',
]}
/>

Expand Down

0 comments on commit 00774b9

Please sign in to comment.