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 {
|
2019-11-13 18:17:20 +08:00
|
|
|
title: 'Addons/Actions',
|
2019-06-24 00:39:54 +08:00
|
|
|
};
|
|
|
|
|
2019-11-19 21:08:32 +01:00
|
|
|
export const Story1 = () => withActions('click')(button);
|
|
|
|
Story1.story = { name: 'Hello World' };
|
|
|
|
export const Story2 = () => withActions('click', 'contextmenu')(button);
|
|
|
|
Story2.story = { name: 'Multiple actions' };
|
2019-06-24 00:39:54 +08:00
|
|
|
|
2019-11-19 21:08:32 +01:00
|
|
|
export const Story3 = () =>
|
2019-06-24 00:39:54 +08:00
|
|
|
withActions('click', 'contextmenu', { clearOnStoryChange: false })(button);
|
2019-11-19 21:08:32 +01:00
|
|
|
Story3.story = { name: 'Multiple actions + config' };
|
2019-06-24 00:39:54 +08:00
|
|
|
|
2019-11-19 21:08:32 +01:00
|
|
|
export const Story4 = () => withActions({ click: 'clicked', contextmenu: 'right clicked' })(button);
|
|
|
|
Story4.story = { name: 'Multiple actions, object' };
|
2019-06-24 00:39:54 +08:00
|
|
|
|
2019-11-19 21:08:32 +01:00
|
|
|
export const Story5 = () =>
|
2019-06-24 00:39:54 +08:00
|
|
|
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-11-19 21:08:32 +01:00
|
|
|
Story5.story = { name: 'Multiple actions, selector' };
|
2019-06-24 00:39:54 +08:00
|
|
|
|
2019-11-19 21:08:32 +01:00
|
|
|
export const Story6 = () =>
|
2019-11-15 21:48:31 +01:00
|
|
|
withActions(
|
|
|
|
{ click: 'clicked', contextmenu: 'right clicked' },
|
|
|
|
{ clearOnStoryChange: false }
|
|
|
|
)(button);
|
2019-11-19 21:08:32 +01:00
|
|
|
Story6.story = { name: 'Multiple actions, object + config' };
|
2019-06-24 00:39:54 +08:00
|
|
|
|
2019-11-19 21:08:32 +01:00
|
|
|
export const Story7 = () => pickTarget.withActions('click', 'contextmenu')(button);
|
|
|
|
Story7.story = { name: 'Decorated actions' };
|
2019-06-24 00:39:54 +08:00
|
|
|
|
2019-11-19 21:08:32 +01:00
|
|
|
export const Story8 = () =>
|
2019-06-24 00:39:54 +08:00
|
|
|
pickTarget.withActions('click', 'contextmenu', { clearOnStoryChange: false })(button);
|
2019-11-19 21:08:32 +01:00
|
|
|
Story8.story = { name: 'Decorated actions + config' };
|