2018-05-02 20:31:53 +03:00
|
|
|
import { withActions, decorate } from '@storybook/addon-actions';
|
|
|
|
|
|
|
|
const pickTarget = decorate([args => [args[0].target]]);
|
|
|
|
|
|
|
|
const button = () => `<button type="button">Hello World</button>`;
|
|
|
|
|
2019-06-24 00:39:54 +08:00
|
|
|
export default {
|
|
|
|
title: 'Addons|Actions',
|
|
|
|
};
|
|
|
|
|
|
|
|
export const story1 = () => withActions('click')(button);
|
2019-06-27 18:10:45 +08:00
|
|
|
story1.story = { name: 'Hello World' };
|
2019-06-24 00:39:54 +08:00
|
|
|
export const story2 = () => withActions('click', 'contextmenu')(button);
|
2019-06-27 18:10:45 +08:00
|
|
|
story2.story = { name: 'Multiple actions' };
|
2019-06-24 00:39:54 +08:00
|
|
|
|
|
|
|
export const story3 = () =>
|
|
|
|
withActions('click', 'contextmenu', { clearOnStoryChange: false })(button);
|
2019-06-27 18:10:45 +08:00
|
|
|
story3.story = { name: 'Multiple actions + config' };
|
2019-06-24 00:39:54 +08:00
|
|
|
|
|
|
|
export const story4 = () => withActions({ click: 'clicked', contextmenu: 'right clicked' })(button);
|
2019-06-27 18:10:45 +08:00
|
|
|
story4.story = { name: 'Multiple actions, object' };
|
2019-06-24 00:39:54 +08:00
|
|
|
|
|
|
|
export const story5 = () =>
|
|
|
|
withActions({ 'click .btn': 'clicked', contextmenu: 'right clicked' })(
|
|
|
|
() => `
|
2018-05-02 20:31:53 +03:00
|
|
|
<div>
|
|
|
|
Clicks on this button will be logged: <button class="btn" type="button">Button</button>
|
|
|
|
</div>
|
|
|
|
`
|
|
|
|
);
|
2019-06-27 18:10:45 +08:00
|
|
|
story5.story = { name: 'Multiple actions, selector' };
|
2019-06-24 00:39:54 +08:00
|
|
|
|
|
|
|
export const story6 = () =>
|
|
|
|
withActions({ click: 'clicked', contextmenu: 'right clicked' }, { clearOnStoryChange: false })(
|
|
|
|
button
|
|
|
|
);
|
2019-06-27 18:10:45 +08:00
|
|
|
story6.story = { name: 'Multiple actions, object + config' };
|
2019-06-24 00:39:54 +08:00
|
|
|
|
|
|
|
export const story7 = () => pickTarget.withActions('click', 'contextmenu')(button);
|
2019-06-27 18:10:45 +08:00
|
|
|
story7.story = { name: 'Decorated actions' };
|
2019-06-24 00:39:54 +08:00
|
|
|
|
|
|
|
export const story8 = () =>
|
|
|
|
pickTarget.withActions('click', 'contextmenu', { clearOnStoryChange: false })(button);
|
2019-06-27 18:10:45 +08:00
|
|
|
story8.story = { name: 'Decorated actions + config' };
|