kibana/packages/kbn-storybook
Ahmad Bamieh 75d6815f92
[Storybook][i18n] initialize i18n with english locale (#185033)
## Summary

We added a check to ensure that `i18n` is initialized on the browser
before any javascript code uses `i18n`. We need to do the same in the
storybook so it works properly.

To summarize in a couple of pictures 😄 

**Before PR:**

![image](3a598dd9-963d-4f4a-aa2a-d98a3d7f379a)


**After PR:**


![image](e0f0b4a7-69f4-4eb1-b5b6-14bdfa716caf)


cc @petrklapka
2024-06-07 12:44:37 -07:00
..
preset chore(NA): moving @kbn/storybook into bazel (#102731) 2021-06-21 20:17:54 +01:00
src [Storybook][i18n] initialize i18n with english locale (#185033) 2024-06-07 12:44:37 -07:00
templates [serverless] Advanced Settings - Field Row components (#165286) 2023-09-11 18:47:22 -04:00
index.ts chore(NA): remove src folder requirement from packages (part 2) (#138476) 2022-08-30 15:57:35 +01:00
kibana.jsonc Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00
package.json Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00
preset.js Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00
README.md [storybook] Fix Presentation Utility to use default setup; add README note (#122140) 2021-12-29 22:32:36 -05:00
tsconfig.json [Storybook][i18n] initialize i18n with english locale (#185033) 2024-06-07 12:44:37 -07:00

Kibana Storybook

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

Setup Instructions

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

    module.exports = require('@kbn/storybook').defaultConfig;
    
  • Add your plugin alias to src/dev/storybook/aliases.ts config.

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

    import { MyComponent } from './my_component';
    
    export default {
      component: MyComponent,
      title: 'Path/In/Side/Navigation/ToComponent',
    };
    
    export function Example() {
      return <MyComponent />;
    }
    
  • Launch Storybook with yarn storybook <plugin>, or build a static site with yarn storybook --site <plugin>.

Customizing configuration

The defaultConfig object provided by the @kbn/storybook package should be all you need to get running, but you can override this in your .storybook/main.js. Using Storybook's configuration options.

You can also add a manager.ts file to customize various aspects of your Storybook. For example, to change the title and link of the Storybook sidebar, you could add:

addons.setConfig({
  theme: create({
    brandTitle: 'My Plugin',
    brandUrl: 'https://github.com/elastic/kibana/tree/main/src/plugins/my_plugin',
  }),
});

Refer to the Storybook documentation for more information.