examples/official-storybook/config.js
function importAll(context) {
  const storyStore = window.__STORYBOOK_CLIENT_API__._storyStore; // eslint-disable-line no-undef, no-underscore-dangle

  context.keys().forEach(filename => {
    const fileExports = context(filename);

    // A old-style story file
    if (!fileExports.default) {
      return;
    }

    const { default: component, ...examples } = fileExports;
    let componentOptions = component;
    if (component.prototype && component.prototype.isReactComponent) {
      componentOptions = { component };
    }
    const kindName = componentOptions.title || componentOptions.component.displayName;

    if (previousExports[filename]) {
      if (previousExports[filename] === fileExports) {
        return;
      }

      // Otherwise clear this kind
      storyStore.removeStoryKind(kindName);
      storyStore.incrementRevision();
    }

    // We pass true here to avoid the warning about HMR. It's cool clientApi, we got this
    const kind = storiesOf(kindName, true);

    (componentOptions.decorators || []).forEach(decorator => {
      kind.addDecorator(decorator);
    });
    if (componentOptions.parameters) {
      kind.addParameters(componentOptions.parameters);
    }

    Object.keys(examples).forEach(key => {
      const example = examples[key];
      const { title = key, parameters } = example;
      kind.add(title, example, parameters);
    });

    previousExports[filename] = fileExports;
  });
}
function importAll(context) {
  const storyStore = window.__STORYBOOK_CLIENT_API__._storyStore; // eslint-disable-line no-undef, no-underscore-dangle

  context.keys().forEach(filename => {
    const fileExports = context(filename);

    // A old-style story file
    if (!fileExports.default) {
      return;
    }

    const { default: component, ...examples } = fileExports;
    let componentOptions = component;
    if (component.prototype && component.prototype.isReactComponent) {
      componentOptions = { component };
    }
    const kindName = componentOptions.title || componentOptions.component.displayName;

    if (previousExports[filename]) {
      if (previousExports[filename] === fileExports) {
        return;
      }

      // Otherwise clear this kind
      storyStore.removeStoryKind(kindName);
      storyStore.incrementRevision();
    }

    // We pass true here to avoid the warning about HMR. It's cool clientApi, we got this
    const kind = storiesOf(kindName, true);

    (componentOptions.decorators || []).forEach(decorator => {
      kind.addDecorator(decorator);
    });
    if (componentOptions.parameters) {
      kind.addParameters(componentOptions.parameters);
    }

    Object.keys(examples).forEach(key => {
      const example = examples[key];
      const { title = key, parameters } = example;
      kind.add(title, example, parameters);
    });

    previousExports[filename] = fileExports;
  });
}
function importAll ( context ) { const storyStore = window . __STORYBOOK_CLIENT_API__ . _storyStore ; // eslint-disable-line no-undef, no-underscore-dangle context . keys ( ) . forEach ( filename => { const fileExports = context ( filename ) ; // A old-style story file if ( ! fileExports . default ) { return ; } const { default : component , ... examples } = fileExports ; let componentOptions = component ; if ( component . prototype && component . prototype . isReactComponent ) { componentOptions = { component } ; } const kindName = componentOptions . title || componentOptions . component . displayName ; if ( previousExports [ filename ] ) { if ( previousExports [ filename ] === fileExports ) { return ; } // Otherwise clear this kind storyStore . removeStoryKind ( kindName ) ; storyStore . incrementRevision ( ) ; } // We pass true here to avoid the warning about HMR. It's cool clientApi, we got this const kind = storiesOf ( kindName , true ) ; ( componentOptions . decorators || [ ] ) . forEach ( decorator => { kind . addDecorator ( decorator ) ; } ) ; if ( componentOptions . parameters ) { kind . addParameters ( componentOptions . parameters ) ; } Object . keys ( examples ) . forEach ( key => { const example = examples [ key ] ; const { title = key , parameters } = example ; kind . add ( title , example , parameters ) ; } ) ; previousExports [ filename ] = fileExports ; } ) ; }
The simplest version of examples would just export this function for users to use
The simplest version of examples would just export this function for users to use