2020-02-23 18:30:30 -05:00
|
|
|
import { decorate } from '@storybook/addon-actions';
|
2018-05-02 20:31:53 +03:00
|
|
|
|
|
|
|
const pickTarget = decorate([args => [args[0].target]]);
|
|
|
|
|
2020-02-23 18:30:30 -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();
|
|
|
|
Story1.story = {
|
|
|
|
name: 'Hello World',
|
|
|
|
parameters: {
|
|
|
|
actions: {
|
|
|
|
handles: ['click']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2019-06-24 00:39:54 +08:00
|
|
|
|
2020-02-23 18:30:30 -05:00
|
|
|
export const Story2 = buttonStory();
|
|
|
|
Story2.story = {
|
|
|
|
name: 'Multiple actions',
|
|
|
|
parameters: {
|
|
|
|
actions: {
|
|
|
|
handles: ['click', 'contextmenu']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2019-06-24 00:39:54 +08:00
|
|
|
|
2020-02-23 18:30:30 -05:00
|
|
|
export const Story3 = buttonStory();
|
|
|
|
Story3.story = {
|
|
|
|
name: 'Multiple actions + config',
|
|
|
|
parameters: {
|
|
|
|
actions: {
|
|
|
|
handles: ['click', 'contextmenu', { clearOnStoryChange: false }]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2019-06-24 00:39:54 +08:00
|
|
|
|
2020-02-23 18:30:30 -05:00
|
|
|
export const Story4 = buttonStory();
|
|
|
|
Story4.story = {
|
|
|
|
name: 'Multiple actions, object',
|
|
|
|
parameters: {
|
|
|
|
actions: {
|
|
|
|
handles: [{ click: 'clicked', contextmenu: 'right clicked' }]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
`;
|
|
|
|
Story5.story = {
|
|
|
|
name: 'Multiple actions, selector',
|
|
|
|
parameters: {
|
|
|
|
actions: {
|
|
|
|
handles: [{ 'click .btn': 'clicked', contextmenu: 'right clicked' }]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export const Story6 = buttonStory();
|
|
|
|
Story6.story = {
|
|
|
|
name: 'Multiple actions, object + config',
|
|
|
|
parameters: {
|
|
|
|
actions: {
|
|
|
|
handles: [
|
|
|
|
{ click: 'clicked', contextmenu: 'right clicked' },
|
|
|
|
{ clearOnStoryChange: false }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export const Story7 = () => pickTarget.withActions('click', 'contextmenu')(buttonStory());
|
2019-11-19 21:08:32 +01:00
|
|
|
Story7.story = { name: 'Decorated actions' };
|
2019-06-24 00:39:54 +08:00
|
|
|
|
2019-11-19 21:08:32 +01:00
|
|
|
export const Story8 = () =>
|
2020-02-23 18:30:30 -05:00
|
|
|
pickTarget.withActions('click', 'contextmenu', { clearOnStoryChange: false })(buttonStory());
|
2019-11-19 21:08:32 +01:00
|
|
|
Story8.story = { name: 'Decorated actions + config' };
|
2020-02-23 18:30:30 -05:00
|
|
|
|
|
|
|
export const Story9 = buttonStory()
|
|
|
|
Story9.story = {
|
|
|
|
name: 'Parameters array shortcut',
|
|
|
|
parameters: {
|
|
|
|
actions: [
|
|
|
|
{ click: 'clicked', contextmenu: 'right clicked' },
|
|
|
|
{ clearOnStoryChange: false }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
};
|