fbredius/storybook

View on GitHub
docs/snippets/angular/storybook-preview-with-styled-components-decorator.ts.mdx

Summary

Maintainability
Test Coverage
```js
// .storybook/preview.js

import { componentWrapperDecorator } from '@storybook/angular';
import { ThemeProvider } from './theme-provider.component';

export const decorators = [
  moduleMetadata({ declarations: [ThemeProvider] }),
  componentWrapperDecorator((story) => `<theme-provider class="default">${story}</theme-provider>`),
];

// or with globals of story context
export const decorators = [
  moduleMetadata({ declarations: [ThemeProvider] }),
  componentWrapperDecorator(
    (story) => `<theme-provider [class]="theme">${story}</theme-provider>`,
    ({ globals }) => ({ theme: globals.theme })
  ),
];
```