@prashis/storybook-addon-message-bus
Interact with message bus via Storybook UI
npm install @prashis/storybook-addon-message-bus
3
Downloads per week

Storybook Addon Message Bus

Storybook Addon w/ GUI for interacting with Message Bus ๐ŸšŽ

storybook-addon-message-bus-demo

Installation

npm i -D @prashis/storybook-addon-message-bus

Then add the following to .storybook/main.js:

module.exports = {
  addons: ["@prashis/storybook-addon-message-bus"],
};

Usage

Add an decorator in .storybook/preview.js (or individual stories) & pass the emitter callback function for emitting events

import { withMessageBus } from "@prashis/storybook-addon-message-bus";
import nanobus from "nanobus";

const bus = nanobus();

const emitter = (name, payload) => {
  bus.emit(name, payload);
};

export const decorators = [withMessageBus({ emitter })];

Finally, pass the list of event names & default payload in story parameters, which will be displayed inside the addon panel

const events = [
  {
    name: "notification.add",
    payload: {
      type: "success",
      message: "Illo et aspernatur saepe exercitationem fugit tenetur.",
    },
  },
];

const Template = () => <Notifications />;

export const List = Template.bind({});
List.parameters = { events };