kibana/packages/kbn-storybook
Tyler Smalley 9acf8d2656
Adds @kbn/utils package (#76518)
Moves common utility functions to obtain the repository root,
paths (config/data), and Kibana package.json to a @kbn/utils package.
Moving these existing functions allows them to be used in production, in
other packages because of Kibana.

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
2020-09-15 10:34:39 -07:00
..
lib Adds @kbn/utils package (#76518) 2020-09-15 10:34:39 -07:00
storybook_config Adds @kbn/utils package (#76518) 2020-09-15 10:34:39 -07:00
index.js Remove legacy optimizer (#73154) 2020-08-13 09:08:44 -07:00
package.json Adds @kbn/utils package (#76518) 2020-09-15 10:34:39 -07:00
README.md
yarn.lock Add lockfile symlinks (#55440) 2020-01-27 11:38:20 -05:00

Kibana Storybook

This package provides ability to add Storybook to any Kibana plugin.

Setup Instructions

  1. Add storybook.js launcher file to your plugin. For example, create a file at src/plugins/<plugin>/scripts/storybook.js, with the following contents:

    import { join } from 'path';
    
    // eslint-disable-next-line
    require('@kbn/storybook').runStorybookCli({
      name: '<plugin>',
      storyGlobs: [join(__dirname, '..', 'public', 'components', '**', '*.examples.tsx')],
    });
    
  2. Add your plugin alias to src/dev/storybook/aliases.ts config.

  3. Create sample Storybook stories. For example, in your plugin create create a file at src/plugins/<plugin>/public/components/hello_world/__examples__/hello_world.examples.tsx with the following contents:

    import * as React from 'react';
    import { storiesOf } from '@storybook/react';
    
    storiesOf('Hello world', module).add('default', () => <div>Hello world!</div>);
    
  4. Launch Storybook with yarn storybook <plugin>.