|
| 1 | +import type { Meta, Story } from '@metamask/snaps-storybook'; |
| 2 | + |
| 3 | +import type { InputProps } from './Input'; |
| 4 | +import { Input } from './Input'; |
| 5 | + |
| 6 | +const meta: Meta<typeof Input> = { |
| 7 | + title: 'Forms/Input', |
| 8 | + component: Input, |
| 9 | + argTypes: { |
| 10 | + name: { |
| 11 | + description: |
| 12 | + 'The name of the input field. This is used to identify the input field in the form data.', |
| 13 | + }, |
| 14 | + type: { |
| 15 | + description: 'The type of the input field.', |
| 16 | + options: ['text', 'password', 'number'], |
| 17 | + control: 'select', |
| 18 | + }, |
| 19 | + value: { |
| 20 | + description: 'The default value of the input field.', |
| 21 | + control: 'text', |
| 22 | + }, |
| 23 | + placeholder: { |
| 24 | + description: 'The placeholder text of the input field.', |
| 25 | + control: 'text', |
| 26 | + }, |
| 27 | + }, |
| 28 | +}; |
| 29 | + |
| 30 | +export default meta; |
| 31 | + |
| 32 | +/** |
| 33 | + * The input component renders an input field. |
| 34 | + */ |
| 35 | +export const Default: Story<InputProps> = { |
| 36 | + render: (props) => <Input {...props} />, |
| 37 | + args: { |
| 38 | + name: 'input', |
| 39 | + placeholder: 'This is the placeholder text', |
| 40 | + }, |
| 41 | +}; |
| 42 | + |
| 43 | +/** |
| 44 | + * Number inputs only accept numbers. |
| 45 | + */ |
| 46 | +export const Number: Story<InputProps> = { |
| 47 | + render: (props) => <Input {...props} />, |
| 48 | + args: { |
| 49 | + name: 'input', |
| 50 | + type: 'number', |
| 51 | + placeholder: 'This input only accepts numbers', |
| 52 | + }, |
| 53 | +}; |
| 54 | + |
| 55 | +/** |
| 56 | + * Password inputs hide the entered text. |
| 57 | + */ |
| 58 | +export const Password: Story<InputProps> = { |
| 59 | + render: (props) => <Input {...props} />, |
| 60 | + args: { |
| 61 | + name: 'input', |
| 62 | + type: 'password', |
| 63 | + placeholder: 'This is a password input', |
| 64 | + }, |
| 65 | +}; |
| 66 | + |
| 67 | +/** |
| 68 | + * It's possible to set a default value for the input. The value can be changed |
| 69 | + * by the user. |
| 70 | + */ |
| 71 | +export const DefaultValue: Story<InputProps> = { |
| 72 | + render: (props) => <Input {...props} />, |
| 73 | + args: { |
| 74 | + name: 'input', |
| 75 | + value: 'Default value', |
| 76 | + placeholder: 'This input has a default value', |
| 77 | + }, |
| 78 | +}; |
0 commit comments