|
| 1 | +import { disableProps, InSpacingDecorator } from '../../index'; |
| 2 | + |
| 3 | +import { stretchingValues, pinValues, contentPlacingValues } from './fixtures'; |
| 4 | + |
| 5 | +type CreateMetaProps = { |
| 6 | + component: any; |
| 7 | + componentConfig: any; |
| 8 | + title?: string; |
| 9 | + defaultArgs?: {}; |
| 10 | + additionalArgTypes?: {}; |
| 11 | + disablePropsList?: []; |
| 12 | +}; |
| 13 | + |
| 14 | +export const createMeta = ({ |
| 15 | + component, |
| 16 | + componentConfig, |
| 17 | + title = 'Data Entry/Button', |
| 18 | + defaultArgs = {}, |
| 19 | + additionalArgTypes = {}, |
| 20 | + disablePropsList = [], |
| 21 | +}: CreateMetaProps) => { |
| 22 | + return { |
| 23 | + title, |
| 24 | + decorators: [InSpacingDecorator], |
| 25 | + component, |
| 26 | + args: { |
| 27 | + view: 'default', |
| 28 | + size: 'm', |
| 29 | + contentPlacing: 'default', |
| 30 | + stretching: 'auto', |
| 31 | + text: 'Button', |
| 32 | + value: '', |
| 33 | + disabled: false, |
| 34 | + focused: true, |
| 35 | + square: false, |
| 36 | + isLoading: false, |
| 37 | + ...defaultArgs, |
| 38 | + }, |
| 39 | + argTypes: { |
| 40 | + view: { |
| 41 | + options: componentConfig.views, |
| 42 | + control: { type: 'select' }, |
| 43 | + table: { |
| 44 | + category: 'Appearance', |
| 45 | + }, |
| 46 | + }, |
| 47 | + size: { |
| 48 | + options: componentConfig.sizes, |
| 49 | + control: { type: 'select' }, |
| 50 | + table: { |
| 51 | + category: 'Appearance', |
| 52 | + }, |
| 53 | + }, |
| 54 | + contentPlacing: { |
| 55 | + options: contentPlacingValues, |
| 56 | + control: { type: 'select' }, |
| 57 | + table: { |
| 58 | + category: 'Other', |
| 59 | + }, |
| 60 | + }, |
| 61 | + stretching: { |
| 62 | + options: stretchingValues, |
| 63 | + control: { type: 'select' }, |
| 64 | + table: { |
| 65 | + category: 'Other', |
| 66 | + }, |
| 67 | + }, |
| 68 | + pin: { |
| 69 | + options: pinValues, |
| 70 | + control: { type: 'select' }, |
| 71 | + table: { defaultValue: { summary: 'bottom' }, category: 'Other' }, |
| 72 | + }, |
| 73 | + isLoading: { |
| 74 | + control: { type: 'boolean' }, |
| 75 | + table: { defaultValue: { summary: 'false' }, category: 'State' }, |
| 76 | + }, |
| 77 | + disabled: { |
| 78 | + control: { type: 'boolean' }, |
| 79 | + table: { defaultValue: { summary: 'false' }, category: 'State' }, |
| 80 | + }, |
| 81 | + value: { |
| 82 | + control: { type: 'text' }, |
| 83 | + table: { |
| 84 | + category: 'Content', |
| 85 | + }, |
| 86 | + }, |
| 87 | + text: { |
| 88 | + control: { type: 'text' }, |
| 89 | + table: { |
| 90 | + category: 'Content', |
| 91 | + }, |
| 92 | + }, |
| 93 | + ...additionalArgTypes, |
| 94 | + ...disableProps([ |
| 95 | + 'theme', |
| 96 | + 'loader', |
| 97 | + 'onClick', |
| 98 | + 'onFocus', |
| 99 | + 'onBlur', |
| 100 | + 'outlined', |
| 101 | + 'contentLeft', |
| 102 | + 'contentRight', |
| 103 | + 'shiftLeft', |
| 104 | + 'shiftRight', |
| 105 | + 'stretch', |
| 106 | + 'as', |
| 107 | + 'forwardedAs', |
| 108 | + 'pin', |
| 109 | + 'focused', |
| 110 | + 'blur', |
| 111 | + 'square', |
| 112 | + ...disablePropsList, |
| 113 | + ]), |
| 114 | + }, |
| 115 | + }; |
| 116 | +}; |
0 commit comments