How to use ArgTypesExample method in storybook-root

Best JavaScript code snippet using storybook-root

addon-actions.stories.js

Source:addon-actions.stories.js Github

copy

Full Screen

1/* eslint-disable react/prop-types */2import { window, File } from 'global';3import React, { Fragment } from 'react';4import { action, actions, configureActions } from '@storybook/addon-actions';5import { Form } from '@storybook/components';6const { Button } = Form;7export default {8 title: 'Addons/Actions',9 parameters: {10 options: {11 selectedPanel: 'storybook/actions/panel',12 },13 },14};15export const ArgTypesExample = ({ onClick, onFocus }) => (16 <Button {...{ onClick, onFocus }}>Hello World</Button>17);18ArgTypesExample.argTypes = {19 onClick: { action: 'clicked!' },20 onFocus: { action: true },21};22export const ArgTypesRegexExample = (args, context) => {23 const { someFunction, onClick, onFocus } = args;24 return (25 <Button onMouseOver={someFunction} {...{ onClick, onFocus }}>26 Hello World27 </Button>28 );29};30ArgTypesRegexExample.parameters = { actions: { argTypesRegex: '^on.*' } };31ArgTypesRegexExample.argTypes = { someFunction: {}, onClick: {}, onFocus: {} };32export const BasicExample = () => <Button onClick={action('hello-world')}>Hello World</Button>;33BasicExample.storyName = 'Basic example';34export const MultipleActions = () => (35 <Button {...actions('onClick', 'onMouseOver')}>Hello World</Button>36);37MultipleActions.storyName = 'Multiple actions';38export const MultipleActionsConfig = () => (39 <Button {...actions('onClick', 'onMouseOver', { clearOnStoryChange: false })}>40 Moving away from this story will persist the action logger41 </Button>42);43MultipleActionsConfig.storyName = 'Multiple actions + config';44export const MultipleActionsAsObject = () => (45 <Button {...actions({ onClick: 'clicked', onMouseOver: 'hovered' })}>Hello World</Button>46);47MultipleActionsAsObject.storyName = 'Multiple actions as object';48export const MultipleActionsObjectConfig = () => (49 <Button50 {...actions({ onClick: 'clicked', onMouseOver: 'hovered' }, { clearOnStoryChange: false })}51 >52 Moving away from this story will persist the action logger53 </Button>54);55MultipleActionsObjectConfig.storyName = 'Multiple actions, object + config';56export const CircularPayload = () => {57 const circular = { foo: {} };58 circular.foo.circular = circular;59 return <Button onClick={() => action('circular')(circular)}>Circular Payload</Button>;60};61CircularPayload.storyName = 'Circular Payload';62export const ReservedKeywordAsName = () => <Button onClick={action('delete')}>Delete</Button>;63ReservedKeywordAsName.storyName = 'Reserved keyword as name';64export const AllTypes = () => {65 function A() {}66 function B() {}67 const bound = B.bind({});68 let file;69 try {70 file = new File([''], 'filename.txt', { type: 'text/plain', lastModified: new Date() });71 } catch (error) {72 file = error;73 }74 const reg = /fooBar/g;75 return (76 <Fragment>77 <Button onClick={() => action('Array')(['foo', 'bar', { foo: 'bar' }])}>Array</Button>78 <Button onClick={() => action('Boolean')(false)}>Boolean</Button>79 <Button onClick={() => action('Empty Object')({})}>Empty Object</Button>80 <Button onClick={() => action('File')(file)}>File</Button>81 <Button onClick={() => action('Function', { allowFunction: true })(A)}>Function A</Button>82 <Button onClick={() => action('Function (bound)', { allowFunction: true })(bound)}>83 Bound Function B84 </Button>85 <Button onClick={() => action('Infinity')(Infinity)}>Infinity</Button>86 <Button onClick={() => action('-Infinity')(-Infinity)}>-Infinity</Button>87 <Button onClick={() => action('NaN')(NaN)}>NaN</Button>88 <Button onClick={() => action('null')(null)}>null</Button>89 <Button onClick={() => action('Number')(10000)}>Number</Button>90 <Button91 onClick={() =>92 action('Multiple')(93 'foo',94 1000,95 true,96 false,97 [1, 2, 3],98 null,99 undefined,100 { foo: 'bar' },101 window102 )103 }104 >105 Multiple106 </Button>107 <Button onClick={() => action('Plain Object')({ foo: { bar: { baz: { bar: 'foo' } } } })}>108 Plain Object109 </Button>110 <Button111 onClick={() =>112 action('ObjectDepth2', { depth: 2 })({ root: { one: { two: { three: 'foo' } } } })113 }114 >115 Object (depth: 2)116 </Button>117 <Button onClick={() => action('RegExp')(reg)}>RegExp</Button>118 <Button onClick={() => action('String')('foo')}>String</Button>119 <Button onClick={() => action('Symbol')(Symbol('A_SYMBOL'))}>Symbol</Button>120 <Button onClick={action('SyntheticMouseEvent')}>SyntheticEvent</Button>121 <Button onClick={() => action('undefined')(undefined)}>undefined</Button>122 <Button onClick={() => action('window')(window)}>Window</Button>123 </Fragment>124 );125};126AllTypes.storyName = 'All types';127export const ConfigureActionsDepth = () => {128 configureActions({129 depth: 2,130 });131 return (132 <Button onClick={() => action('ConfiguredDepth')({ root: { one: { two: { three: 'foo' } } } })}>133 Object (configured depth: 2)134 </Button>135 );136};137export const PersistingTheActionLogger = () => (138 <Fragment>139 <p>Moving away from this story will persist the action logger</p>140 <Button onClick={action('clear-action-logger', { clearOnStoryChange: false })}>141 Object (configured clearOnStoryChange: false)142 </Button>143 </Fragment>144);145PersistingTheActionLogger.storyName = 'Persisting the action logger';146export const LimitActionOutput = () => {147 configureActions({148 limit: 2,149 });150 return (151 <Fragment>152 <Button onClick={() => action('False')(false)}>False</Button>153 <Button onClick={() => action('True')(true)}>True</Button>154 </Fragment>155 );156};157LimitActionOutput.storyName = 'Limit Action Output';158export const SkippedViaDisableTrue = () => (159 <Button onClick={action('hello-world')}>Hello World</Button>160);161SkippedViaDisableTrue.storyName = 'skipped via disable:true';162SkippedViaDisableTrue.parameters = {163 actions: { disable: true },...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { ArgTypesExample } from 'storybook-root';2import { Button } from 'storybook-root';3import { Button } from 'storybook-root';4import { Button } from 'storybook-root';5import { Button } from 'storybook-root';6This project is [MIT](

Full Screen

Using AI Code Generation

copy

Full Screen

1import { ArgTypesExample } from "storybook-root";2export const MyComponent = () => <ArgTypesExample />;3import { ArgTypesExample } from "storybook-root";4import { withKnobs } from "@storybook/addon-knobs";5jest.mock("@storybook/addon-knobs", () => ({6 withKnobs: jest.fn((storyFn) => storyFn()),7}));8export const MyComponent = () => <ArgTypesExample />;9import { ArgTypesExample } from "storybook-root";10import { withKnobs } from "@storybook/addon-knobs";11jest.mock("@storybook/addon-knobs", () => ({12 withKnobs: jest.fn((storyFn) => storyFn()),13}));14export const MyComponent = () => <ArgTypesExample />;15import { ArgTypesExample } from "storybook-root";16import {

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful