storybook-angular-wrapper
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Storybook Angular Wrapper

This decorator allows you to wrap all your stories with a template:

import { storiesOf, moduleMetadata } from '@storybook/angular';
import { angularWrapper } from 'storybook-angular-wrapper';
import { YourModule } from '../path/to/your.module';
 
storiesOf('Your component', module)
  .addDecorator(
    moduleMetadata({
      imports: [YourModule],
    }),
  )
  .addDecorator(
    angularWrapper(
      `
        <div style="margin: 3em">
        @{template}
        </div>`,
      '@{template}',
    ),
  )
  .add('with items', () => ({
    template: `
        <your-component [prop1]="prop1"></your-component>
    `,
    props: {
      prop1: [
        {
          id: 1,
          first: 'Carlos',
          last: 'Vega',
          handle: '@alterx',
          status: 'active',
        },
      ],
    },
  }))
  .add('no items', () => ({
    template: `
        <your-component [prop1]="prop1"></your-component>
    `,
    props: {
      prop1: [],
    },
  }));

This will result in a 3em margin applied to both stories.

Installation

yarn add -D storybook-angular-wrapper

or

npm i --save-dev storybook-angular-wrapper

Disclaimer

This works better with template stories, it does support component stories but this is a mode that's limited and should only be used under certain very specific circumstances.

Readme

Keywords

none

Package Sidebar

Install

npm i storybook-angular-wrapper

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

4.2 kB

Total Files

10

Last publish

Collaborators

  • alterx