How to use the @storybook/angular.addDecorator function in @storybook/angular

To help you get started, we’ve selected a few @storybook/angular examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBM / carbon-components-angular / .storybook / config.js View on Github external
import "./polyfills.js";

import { configure, addDecorator } from "@storybook/angular";
import { withOptions } from '@storybook/addon-options';

addDecorator(
	withOptions({
		name: "carbon components angular",
		url: "https://github.com/IBM/carbon-components-angular",
	})
);

// load global styles
require("!style-loader!css-loader!postcss-loader!sass-loader!./preview.scss");

require("../src/index.stories");
// automatically import all files ending in *.stories.ts
const req = require.context("../src", true, /.stories.ts$/);

function loadStories() {
	req.keys()
	.sort((path1, path2) => path1.split("/").slice(-1)[0] > path2.split("/").slice(-1)[0] ? 1 : -1)
github storybookjs / storybook / examples / angular-cli / .storybook / preview.ts View on Github external
import { addParameters, addDecorator } from '@storybook/angular';
import { withA11y } from '@storybook/addon-a11y';
import { setCompodocJson } from '@storybook/addon-docs/angular';
import addCssWarning from '../src/cssWarning';

// @ts-ignore
// eslint-disable-next-line import/extensions, import/no-unresolved
import docJson from '../documentation.json';

setCompodocJson(docJson);

addDecorator(withA11y);
addCssWarning();

addParameters({
  docs: {
    // inlineStories: true,
    iframeHeight: '60px',
  },
});
github sparkdesignsystem / spark-design-system / angular / .storybook / config.js View on Github external
import { configure, addDecorator, addParameters } from '@storybook/angular';
import { withA11y } from '@storybook/addon-a11y';
import sparkTheme from "../../storybook-theming/storybook-spark-theme";
import '../src/polyfills';
import '!style-loader!css-loader!sass-loader!../../storybook-theming/font-loader.scss';
import '../../storybook-theming/icon-loader';
import { setCompodocJson, extractProps } from '@storybook/addon-docs/angular';
import docJson from '../documentation.json';

setCompodocJson(docJson);
addDecorator(withA11y);
addParameters({
  options: {
    theme: sparkTheme,
    showRoots: true,
    storySort: (a, b) =>
      a[1].kind === b[1].kind ? 0 : a[1].id.localeCompare(b[1].id, { numeric: true }),
  },
});

addParameters({
  docs: {
    extractComponentDescription: (component, { info }) => {
      if (info) {
        return typeof info === 'string' ? info : info.markdown || info.text;
      }
      return null;
github tinymce / tinymce-angular / .storybook / config.js View on Github external
import { configure, addDecorator } from '@storybook/angular';
import { withNotes } from '@storybook/addon-notes';

addDecorator(withNotes);
function loadStories() {
  require('../stories/index.ts');
}

configure(loadStories, module);
github TeamHive / app-starter / .storybook / config.js View on Github external
import {
    initDsm
} from '@invisionapp/dsm-storybook';
import {
    CUSTOM_ELEMENTS_SCHEMA
} from '@angular/core';
import '@storybook/addon-console';
import {
    setConsoleOptions
} from '@storybook/addon-console';

setConsoleOptions({
    panelExclude: [],
});

addDecorator(
    moduleMetadata({
        schemas: [CUSTOM_ELEMENTS_SCHEMA]
    })
);

import theme from './theme';

addParameters({
    options: {
        theme
    }
});

function loadStories() {
    const paths = [
        require.context('../apps/web', true, /\.stories\.ts$/),
github carbon-design-system / carbon-custom-elements / .storybook / angular / config.ts View on Github external
} else {
    containerStyleNode.textContent = cssText;
  }
  return {
    ...rest,
    template: `
      <a aria-label="Skip to main content" class="bx--assistive-text" href="#main-content">Skip to main content</a>
      <div class="bx--body bx-ce-demo-devenv--container" role="main" data-floating-menu-container="" id="main-content">
        ${template}
      </div>
      <a aria-label="End of content" class="bx--assistive-text" href="#main-content">End of content</a>
    `,
  };
});

addDecorator(withKnobs);

addDecorator((story, { parameters }) =&gt; {
  const { knobs } = parameters;
  if (Object(knobs) === knobs) {
    if (!parameters.props) {
      parameters.props = {};
    }
    Object.keys(knobs).forEach(name =&gt; {
      if (typeof knobs[name] === 'function') {
        parameters.props[name] = knobs[name]();
      }
    });
  }
  return story();
});

@storybook/angular

Storybook for Angular: Develop Angular components in isolation with hot reloading.

MIT
Latest version published 17 days ago

Package Health Score

98 / 100
Full package analysis