2020-02-25 12:58:35 -05:00
|
|
|
import { withActions } from '@storybook/addon-actions';
|
2018-05-02 20:31:53 +03:00
|
|
|
|
2020-02-23 19:26:29 -05:00
|
|
|
const buttonStory = () => () => `<button type="button">Hello World</button>`;
|
2018-05-02 20:31:53 +03:00
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2020-02-23 18:30:30 -05:00
|
|
|
export const Story1 = buttonStory();
|
2020-05-25 13:32:05 +08:00
|
|
|
Story1.storyName = 'Hello World';
|
|
|
|
|
|
|
|
Story1.parameters = {
|
|
|
|
actions: {
|
|
|
|
handles: ['click'],
|
2020-02-23 19:26:29 -05:00
|
|
|
},
|
2020-02-23 18:30:30 -05:00
|
|
|
};
|
2019-06-24 00:39:54 +08:00
|
|
|
|
2020-02-23 18:30:30 -05:00
|
|
|
export const Story2 = buttonStory();
|
2020-05-25 13:32:05 +08:00
|
|
|
Story2.storyName = 'Multiple actions';
|
|
|
|
|
|
|
|
Story2.parameters = {
|
|
|
|
actions: {
|
|
|
|
handles: ['click', 'contextmenu'],
|
2020-02-23 19:26:29 -05:00
|
|
|
},
|
2020-02-23 18:30:30 -05:00
|
|
|
};
|
2019-06-24 00:39:54 +08:00
|
|
|
|
2020-02-23 18:30:30 -05:00
|
|
|
export const Story3 = buttonStory();
|
2020-05-25 13:32:05 +08:00
|
|
|
Story3.storyName = 'Multiple actions + config';
|
|
|
|
|
|
|
|
Story3.parameters = {
|
|
|
|
actions: {
|
|
|
|
handles: ['click', 'contextmenu', { clearOnStoryChange: false }],
|
2020-02-23 19:26:29 -05:00
|
|
|
},
|
|
|
|
};
|
2019-06-24 00:39:54 +08:00
|
|
|
|
2020-02-23 18:30:30 -05:00
|
|
|
export const Story4 = buttonStory();
|
2020-05-25 13:32:05 +08:00
|
|
|
Story4.storyName = 'Multiple actions, object';
|
|
|
|
|
|
|
|
Story4.parameters = {
|
|
|
|
actions: {
|
|
|
|
handles: [{ click: 'clicked', contextmenu: 'right clicked' }],
|
2020-02-23 19:26:29 -05:00
|
|
|
},
|
2020-02-23 18:30:30 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
export const Story5 = () => `
|
2018-05-02 20:31:53 +03:00
|
|
|
<div>
|
|
|
|
Clicks on this button will be logged: <button class="btn" type="button">Button</button>
|
|
|
|
</div>
|
2020-02-23 18:30:30 -05:00
|
|
|
`;
|
2020-05-25 13:32:05 +08:00
|
|
|
Story5.storyName = 'Multiple actions, selector';
|
|
|
|
|
|
|
|
Story5.parameters = {
|
|
|
|
actions: {
|
|
|
|
handles: [{ 'click .btn': 'clicked', contextmenu: 'right clicked' }],
|
2020-02-23 19:26:29 -05:00
|
|
|
},
|
2020-02-23 18:30:30 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
export const Story6 = buttonStory();
|
2020-05-25 13:32:05 +08:00
|
|
|
Story6.storyName = 'Multiple actions, object + config';
|
|
|
|
|
|
|
|
Story6.parameters = {
|
|
|
|
actions: {
|
|
|
|
handles: [{ click: 'clicked', contextmenu: 'right clicked' }, { clearOnStoryChange: false }],
|
2020-02-23 19:26:29 -05:00
|
|
|
},
|
2020-02-23 18:30:30 -05:00
|
|
|
};
|
|
|
|
|
2020-02-24 11:49:16 -05:00
|
|
|
export const DeprecatedDecoratorsStory1 = buttonStory();
|
2020-05-25 13:32:05 +08:00
|
|
|
DeprecatedDecoratorsStory1.storyName = 'Deprecated decorators - Single action';
|
|
|
|
DeprecatedDecoratorsStory1.decorators = [withActions('click')];
|
2020-02-23 20:18:42 -05:00
|
|
|
|
2020-02-24 11:49:16 -05:00
|
|
|
export const DeprecatedDecoratorsStory2 = buttonStory();
|
2020-05-25 13:32:05 +08:00
|
|
|
DeprecatedDecoratorsStory2.storyName = 'Deprecated decorators - Multiple actions';
|
|
|
|
DeprecatedDecoratorsStory2.decorators = [withActions('click', 'contextmenu')];
|
2020-02-23 20:18:42 -05:00
|
|
|
|
2020-02-24 11:49:16 -05:00
|
|
|
export const DeprecatedDecoratorsStory3 = buttonStory();
|
2020-05-25 13:32:05 +08:00
|
|
|
DeprecatedDecoratorsStory3.storyName = 'Deprecated decorators - Multiple actions + config';
|
|
|
|
DeprecatedDecoratorsStory3.decorators = [
|
|
|
|
withActions('click', 'contextmenu', { clearOnStoryChange: false }),
|
|
|
|
];
|
2020-02-23 20:18:42 -05:00
|
|
|
|
2020-02-24 11:49:16 -05:00
|
|
|
export const DeprecatedDecoratorsStory4 = buttonStory();
|
2020-05-25 13:32:05 +08:00
|
|
|
DeprecatedDecoratorsStory4.storyName = 'Deprecated decorators - Multiple actions, object';
|
|
|
|
DeprecatedDecoratorsStory4.decorators = [
|
|
|
|
withActions({ click: 'clicked', contextmenu: 'right clicked' }),
|
|
|
|
];
|