How to use the @storybook/addon-actions.decorate function in @storybook/addon-actions

To help you get started, we’ve selected a few @storybook/addon-actions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github storybookjs / storybook / examples / html-kitchen-sink / stories / react / addon-actions.stories.js View on Github external
import { window, File } from 'global';
import React, { Fragment } from 'react';
import { storiesOf } from '@storybook/html';
import {
  action,
  actions,
  configureActions,
  decorate,
  decorateAction,
} from '@storybook/addon-actions';
import { Form } from '@storybook/components';

const { Button } = Form;

const pickNative = decorate([args => [args[0].nativeEvent]]);
const pickNativeAction = decorateAction([args => [args[0].nativeEvent]]);

storiesOf('React|Actions', module)
  .addParameters({
    framework: 'react',
    options: {
      selectedPanel: 'storybook/actions/panel',
    },
  })

  .add('Basic example', () =&gt; <button>Hello World</button>)
  .add('Multiple actions', () =&gt; (
    <button>Hello World</button>
  ))
  .add('Multiple actions + config', () =&gt; (
    <button></button>
github storybookjs / storybook / examples / html-kitchen-sink / stories / addon-actions.stories.js View on Github external
import { withActions, decorate } from '@storybook/addon-actions';

const pickTarget = decorate([args =&gt; [args[0].target]]);

const button = () =&gt; `<button type="button">Hello World</button>`;

export default {
  title: 'Addons/Actions',
};

export const story1 = () =&gt; withActions('click')(button);
story1.story = { name: 'Hello World' };
export const story2 = () =&gt; withActions('click', 'contextmenu')(button);
story2.story = { name: 'Multiple actions' };

export const story3 = () =&gt;
  withActions('click', 'contextmenu', { clearOnStoryChange: false })(button);
story3.story = { name: 'Multiple actions + config' };
github mikechabot / react-json-form-engine / stories / util / index.js View on Github external
export const logInstance = instance => {
    return decorate([() => [{ model: instance.serializeModel() }]]);
};
github Doist / reactist / .storybook / stories / components / CheckboxStory.js View on Github external
render() {
        return (
            <section>
                 this.setState(() =&gt; ({ checked }))
                    ]).action('Checkbox Toggle')}
                /&gt;
            </section>
        )
    }
}
github storybookjs / storybook / examples / official-storybook / stories / deprecated / addon-actions.stories.js View on Github external
import { window, File } from 'global';
import React, { Fragment } from 'react';
import {
  action,
  actions,
  configureActions,
  decorate,
  decorateAction,
} from '@storybook/addon-actions';
import { Form } from '@storybook/components';

const { Button } = Form;

const pickNative = decorate([args =&gt; [args[0].nativeEvent]]);
const pickNativeAction = decorateAction([args =&gt; [args[0].nativeEvent]]);

export default {
  title: 'Addons|Actions.deprecated',
};

export const decoratedAction = () =&gt; (
  <button>Native Event</button>
);

decoratedAction.story = {
  name: 'Decorated Action',
};
github CleverCloud / clever-components / stories / lib / event-action.js View on Github external
import { action, decorate } from '@storybook/addon-actions';

const customEvent = decorate([(args) => {
  return [JSON.stringify(args[0].detail)];
}]);

export function customEventAction (eventName) {
  return customEvent.action(eventName);
}

export function withCustomEventActions (...eventNames) {
  return customEvent.withActions(...eventNames);
}

export function eventAction (eventName) {
  return action(eventName);
}
github storybookjs / storybook / examples / official-storybook / stories / addon-actions.stories.js View on Github external
import { window, File } from 'global';
import React, { Fragment } from 'react';
import {
  action,
  actions,
  configureActions,
  decorate,
  decorateAction,
} from '@storybook/addon-actions';
import { Form } from '@storybook/components';

const { Button } = Form;

const pickNative = decorate([args =&gt; [args[0].nativeEvent]]);
const pickNativeAction = decorateAction([args =&gt; [args[0].nativeEvent]]);

export default {
  title: 'Addons/Actions',
  parameters: {
    options: {
      selectedPanel: 'storybook/actions/panel',
    },
  },
};

export const basicExample = () =&gt; <button>Hello World</button>;

basicExample.story = {
  name: 'Basic example',
};
github storybookjs / storybook / examples / web-components-kitchen-sink / stories / addon-actions.stories.js View on Github external
import { withActions, decorate } from '@storybook/addon-actions';
import { html } from 'lit-html';

const pickTarget = decorate([args =&gt; [args[0].target]]);

const button = () =&gt; html`
  <button type="button">Hello World</button>
`;

export default {
  title: 'Addons/Actions',
};

export const story1 = () =&gt; withActions('click')(button);
story1.story = { name: 'Hello World' };
export const story2 = () =&gt; withActions('click', 'contextmenu')(button);
story2.story = { name: 'Multiple actions' };

export const story3 = () =&gt;
  withActions('click', 'contextmenu', { clearOnStoryChange: false })(button);