Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/z4o4z/storybook-addon-events

This Storybook addon allows you to add events for your stories.
https://github.com/z4o4z/storybook-addon-events

events react storybook

Last synced: about 2 months ago
JSON representation

This Storybook addon allows you to add events for your stories.

Awesome Lists containing this project

README

        

# Storybook Addon Events

This [storybook](https://storybooks.js.org) ([source](https://github.com/storybooks/storybook)) addon allows you to add events for your stories.

![Storybook Addon Events Example](docs/demo1.png)
[Storybook Addon Events Live Demo](https://z4o4z.github.io/storybook-addon-events/index.html)

### Getting Started
**note: addons require @kadira/storybook 2.x or greater*

```sh
npm i --save-dev @z4o4z/storybook-addon-events
```

Then create a file called `addons.js` in your storybook config.

Add following content to it:

```js
import '@kadira/storybook/addons';
import '@z4o4z/storybook-addon-events/register';
```

Then write your stories like this:

```js
import React from 'react';
import EventEmiter from 'event-emiter';
import { storiesOf } from '@kadira/storybook';
import WithEvents from '@z4o4z/storybook-addon-events';

import Logger from './Logger';
import * as EVENTS from './events';

const emiter = new EventEmiter();
const emit = emiter.emit.bind(emiter);

storiesOf('WithEvents', module)
.addDecorator(getStory => (

{getStory()}

))
.add('Logger', () => );
```