mirror of
				https://github.com/snowball-tools/snowballtools-base.git
				synced 2025-10-31 22:34:07 +00:00 
			
		
		
		
	[4/n][Storybook] Input update argTypes
This commit is contained in:
		
							parent
							
								
									294675c276
								
							
						
					
					
						commit
						43d7c94cb0
					
				| @ -1,8 +1,11 @@ | |||||||
| import { StoryObj, Meta } from '@storybook/react'; | import { StoryObj, Meta } from '@storybook/react'; | ||||||
| 
 | 
 | ||||||
| import { Input } from 'components/shared/Input'; | import { Input, InputTheme } from 'components/shared/Input'; | ||||||
| import { PlusIcon } from 'components/shared/CustomIcon'; | import { PlusIcon } from 'components/shared/CustomIcon'; | ||||||
| 
 | 
 | ||||||
|  | const inputStates: InputTheme['state'][] = ['default', 'error']; | ||||||
|  | const inputSizes: InputTheme['size'][] = ['sm', 'md']; | ||||||
|  | 
 | ||||||
| const meta: Meta<typeof Input> = { | const meta: Meta<typeof Input> = { | ||||||
|   title: 'Components/Input', |   title: 'Components/Input', | ||||||
|   component: Input, |   component: Input, | ||||||
| @ -17,6 +20,24 @@ const meta: Meta<typeof Input> = { | |||||||
|     helperText: { |     helperText: { | ||||||
|       control: 'text', |       control: 'text', | ||||||
|     }, |     }, | ||||||
|  |     state: { | ||||||
|  |       control: 'select', | ||||||
|  |       options: inputStates, | ||||||
|  |     }, | ||||||
|  |     size: { | ||||||
|  |       control: 'select', | ||||||
|  |       options: inputSizes, | ||||||
|  |     }, | ||||||
|  |     appearance: { | ||||||
|  |       control: 'text', | ||||||
|  |     }, | ||||||
|  |     placeholder: { | ||||||
|  |       control: 'text', | ||||||
|  |     }, | ||||||
|  |   }, | ||||||
|  |   args: { | ||||||
|  |     state: 'default', | ||||||
|  |     size: 'md', | ||||||
|   }, |   }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| @ -25,20 +46,28 @@ export default meta; | |||||||
| type Story = StoryObj<typeof Input>; | type Story = StoryObj<typeof Input>; | ||||||
| 
 | 
 | ||||||
| export const Default: Story = { | export const Default: Story = { | ||||||
|   render: ({ label, description, leftIcon, rightIcon, helperText }) => ( |   render: ({ label, description, leftIcon, rightIcon, helperText, ...arg }) => ( | ||||||
|     <Input |     <Input | ||||||
|       label={label} |       label={label} | ||||||
|       description={description} |       description={description} | ||||||
|       leftIcon={leftIcon} |       leftIcon={leftIcon} | ||||||
|       rightIcon={rightIcon} |       rightIcon={rightIcon} | ||||||
|       helperText={helperText} |       helperText={helperText} | ||||||
|  |       {...arg} | ||||||
|     /> |     /> | ||||||
|   ), |   ), | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const WithLeftIcon: Story = { | export const WithLeftIcon: Story = { | ||||||
|   render: ({ label, description, leftIcon }) => ( |   render: ({ label, description, leftIcon, rightIcon, helperText, ...arg }) => ( | ||||||
|     <Input label={label} description={description} leftIcon={leftIcon} /> |     <Input | ||||||
|  |       label={label} | ||||||
|  |       description={description} | ||||||
|  |       leftIcon={leftIcon} | ||||||
|  |       rightIcon={rightIcon} | ||||||
|  |       helperText={helperText} | ||||||
|  |       {...arg} | ||||||
|  |     /> | ||||||
|   ), |   ), | ||||||
|   args: { |   args: { | ||||||
|     ...Default.args, |     ...Default.args, | ||||||
| @ -47,8 +76,15 @@ export const WithLeftIcon: Story = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const WithRightIcon: Story = { | export const WithRightIcon: Story = { | ||||||
|   render: ({ label, description, rightIcon }) => ( |   render: ({ label, description, leftIcon, rightIcon, helperText, ...arg }) => ( | ||||||
|     <Input label={label} description={description} rightIcon={rightIcon} /> |     <Input | ||||||
|  |       label={label} | ||||||
|  |       description={description} | ||||||
|  |       leftIcon={leftIcon} | ||||||
|  |       rightIcon={rightIcon} | ||||||
|  |       helperText={helperText} | ||||||
|  |       {...arg} | ||||||
|  |     /> | ||||||
|   ), |   ), | ||||||
|   args: { |   args: { | ||||||
|     ...Default.args, |     ...Default.args, | ||||||
| @ -57,12 +93,14 @@ export const WithRightIcon: Story = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const WithLeftAndRightIcon: Story = { | export const WithLeftAndRightIcon: Story = { | ||||||
|   render: ({ label, description, leftIcon, rightIcon }) => ( |   render: ({ label, description, leftIcon, rightIcon, helperText, ...arg }) => ( | ||||||
|     <Input |     <Input | ||||||
|       label={label} |       label={label} | ||||||
|       description={description} |       description={description} | ||||||
|       leftIcon={leftIcon} |       leftIcon={leftIcon} | ||||||
|       rightIcon={rightIcon} |       rightIcon={rightIcon} | ||||||
|  |       helperText={helperText} | ||||||
|  |       {...arg} | ||||||
|     /> |     /> | ||||||
|   ), |   ), | ||||||
|   args: { |   args: { | ||||||
| @ -73,8 +111,15 @@ export const WithLeftAndRightIcon: Story = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const WithDescription: Story = { | export const WithDescription: Story = { | ||||||
|   render: ({ label, description }) => ( |   render: ({ label, description, leftIcon, rightIcon, helperText, ...arg }) => ( | ||||||
|     <Input label={label} description={description} /> |     <Input | ||||||
|  |       label={label} | ||||||
|  |       description={description} | ||||||
|  |       leftIcon={leftIcon} | ||||||
|  |       rightIcon={rightIcon} | ||||||
|  |       helperText={helperText} | ||||||
|  |       {...arg} | ||||||
|  |     /> | ||||||
|   ), |   ), | ||||||
|   args: { |   args: { | ||||||
|     ...Default.args, |     ...Default.args, | ||||||
| @ -83,7 +128,16 @@ export const WithDescription: Story = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const WithHelperText: Story = { | export const WithHelperText: Story = { | ||||||
|   render: ({ helperText }) => <Input helperText={helperText} />, |   render: ({ label, description, leftIcon, rightIcon, helperText, ...arg }) => ( | ||||||
|  |     <Input | ||||||
|  |       label={label} | ||||||
|  |       description={description} | ||||||
|  |       leftIcon={leftIcon} | ||||||
|  |       rightIcon={rightIcon} | ||||||
|  |       helperText={helperText} | ||||||
|  |       {...arg} | ||||||
|  |     /> | ||||||
|  |   ), | ||||||
|   args: { |   args: { | ||||||
|     ...Default.args, |     ...Default.args, | ||||||
|     helperText: 'helper text', |     helperText: 'helper text', | ||||||
| @ -91,7 +145,16 @@ export const WithHelperText: Story = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const WithLabel: Story = { | export const WithLabel: Story = { | ||||||
|   render: ({ label }) => <Input label={label} />, |   render: ({ label, description, leftIcon, rightIcon, helperText, ...arg }) => ( | ||||||
|  |     <Input | ||||||
|  |       label={label} | ||||||
|  |       description={description} | ||||||
|  |       leftIcon={leftIcon} | ||||||
|  |       rightIcon={rightIcon} | ||||||
|  |       helperText={helperText} | ||||||
|  |       {...arg} | ||||||
|  |     /> | ||||||
|  |   ), | ||||||
|   args: { |   args: { | ||||||
|     ...Default.args, |     ...Default.args, | ||||||
|     label: 'label', |     label: 'label', | ||||||
| @ -99,7 +162,16 @@ export const WithLabel: Story = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const WithPlaceholder: Story = { | export const WithPlaceholder: Story = { | ||||||
|   render: ({ placeholder }) => <Input placeholder={placeholder} />, |   render: ({ label, description, leftIcon, rightIcon, helperText, ...arg }) => ( | ||||||
|  |     <Input | ||||||
|  |       label={label} | ||||||
|  |       description={description} | ||||||
|  |       leftIcon={leftIcon} | ||||||
|  |       rightIcon={rightIcon} | ||||||
|  |       helperText={helperText} | ||||||
|  |       {...arg} | ||||||
|  |     /> | ||||||
|  |   ), | ||||||
|   args: { |   args: { | ||||||
|     ...Default.args, |     ...Default.args, | ||||||
|     placeholder: 'placeholder', |     placeholder: 'placeholder', | ||||||
| @ -107,7 +179,16 @@ export const WithPlaceholder: Story = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const WithValue: Story = { | export const WithValue: Story = { | ||||||
|   render: ({ value }) => <Input value={value} />, |   render: ({ label, description, leftIcon, rightIcon, helperText, ...arg }) => ( | ||||||
|  |     <Input | ||||||
|  |       label={label} | ||||||
|  |       description={description} | ||||||
|  |       leftIcon={leftIcon} | ||||||
|  |       rightIcon={rightIcon} | ||||||
|  |       helperText={helperText} | ||||||
|  |       {...arg} | ||||||
|  |     /> | ||||||
|  |   ), | ||||||
|   args: { |   args: { | ||||||
|     ...Default.args, |     ...Default.args, | ||||||
|     value: 'Value', |     value: 'Value', | ||||||
| @ -115,7 +196,16 @@ export const WithValue: Story = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const WithDisabled: Story = { | export const WithDisabled: Story = { | ||||||
|   render: ({ disabled }) => <Input disabled={disabled} />, |   render: ({ label, description, leftIcon, rightIcon, helperText, ...arg }) => ( | ||||||
|  |     <Input | ||||||
|  |       label={label} | ||||||
|  |       description={description} | ||||||
|  |       leftIcon={leftIcon} | ||||||
|  |       rightIcon={rightIcon} | ||||||
|  |       helperText={helperText} | ||||||
|  |       {...arg} | ||||||
|  |     /> | ||||||
|  |   ), | ||||||
|   args: { |   args: { | ||||||
|     ...Default.args, |     ...Default.args, | ||||||
|     disabled: true, |     disabled: true, | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user