mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-05 02:41:08 +08:00
1.2 KiB
1.2 KiB
Storybook Addon Events
This Storybook addon allows you to add events for your stories.
Getting Started
*note: addons require @kadira/storybook 2.x or greater
npm i --save-dev @z4o4z/storybook-addon-events
Then create a file called addons.js
in your storybook config.
Add following content to it:
import '@kadira/storybook/addons';
import '@z4o4z/storybook-addon-events/register';
Then write your stories like this:
import React from 'react';
import EventEmiter from 'event-emiter';
import { storiesOf } from '@kadira/storybook';
import { WithEvents } from '@z4o4z/storybook-addon-events';
import MyContainerWithEmiter from './MyContainerWithEmiter';
const emiter = new EventEmmiter();
storiesOf('Button', module)
.add('with text', () => (
<WithEvents
emit={emiter.emit}
toggleLike={{
title: 'Toggle like',
name: 'togle-like',
payload: {},
}}
like-fetched={{
title: 'Toggle like',
name: 'togle-like',
payload: {},
}}
>
<MyContainerWithEmiter emiter={emiter}/>
</WithEvents>
));