diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-03-31 17:57:39 +0200 | 
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-03-31 17:57:39 +0200 | 
| commit | b145ed4492de834f5cea9437e9772c4f7fbe90ec (patch) | |
| tree | 76a0b99d5106bc30719bba9e7f13ba30f42e9d8c /src/components/atoms/forms/field.stories.tsx | |
| parent | 8370602f37ad6aa02485d85e5b179b76c3f15701 (diff) | |
chore: add a Field component
Diffstat (limited to 'src/components/atoms/forms/field.stories.tsx')
| -rw-r--r-- | src/components/atoms/forms/field.stories.tsx | 176 | 
1 files changed, 176 insertions, 0 deletions
| diff --git a/src/components/atoms/forms/field.stories.tsx b/src/components/atoms/forms/field.stories.tsx new file mode 100644 index 0000000..0406f10 --- /dev/null +++ b/src/components/atoms/forms/field.stories.tsx @@ -0,0 +1,176 @@ +import { ComponentMeta, ComponentStory } from '@storybook/react'; +import FieldComponent from './field'; + +export default { +  title: 'Atoms/Forms', +  component: FieldComponent, +  args: { +    disabled: false, +    required: false, +    setValue: () => null, +    type: 'text', +    value: '', +  }, +  argTypes: { +    disabled: { +      control: { +        type: 'boolean', +      }, +      description: 'Field state: either enabled or disabled.', +      table: { +        category: 'Options', +        defaultValue: { summary: false }, +      }, +      type: { +        name: 'boolean', +        required: false, +      }, +    }, +    id: { +      control: { +        type: 'text', +      }, +      description: 'Field id.', +      table: { +        category: 'Options', +      }, +      type: { +        name: 'string', +        required: false, +      }, +    }, +    max: { +      control: { +        type: 'number', +      }, +      description: 'Maximum value.', +      table: { +        category: 'Options', +      }, +      type: { +        name: 'number', +        required: false, +      }, +    }, +    min: { +      control: { +        type: 'number', +      }, +      description: 'Minimum value.', +      table: { +        category: 'Options', +      }, +      type: { +        name: 'number', +        required: false, +      }, +    }, +    name: { +      control: { +        type: 'text', +      }, +      description: 'Field name.', +      table: { +        category: 'Options', +      }, +      type: { +        name: 'string', +        required: false, +      }, +    }, +    placeholder: { +      control: { +        type: 'text', +      }, +      description: 'A placeholder value.', +      table: { +        category: 'Options', +      }, +      type: { +        name: 'string', +        required: false, +      }, +    }, +    required: { +      control: { +        type: 'boolean', +      }, +      description: 'Determine if the field is required.', +      table: { +        category: 'Options', +        defaultValue: { summary: false }, +      }, +      type: { +        name: 'boolean', +        required: false, +      }, +    }, +    setValue: { +      control: { +        type: null, +      }, +      description: 'Callback function to set field value.', +      table: { +        category: 'Events', +      }, +      type: { +        name: 'function', +        required: true, +      }, +    }, +    step: { +      control: { +        type: 'number', +      }, +      description: 'Field incremental values that are valid.', +      table: { +        category: 'Options', +      }, +      type: { +        name: 'number', +        required: false, +      }, +    }, +    type: { +      control: { +        type: 'select', +      }, +      description: 'Field type: input type or textarea.', +      options: [ +        'datetime-local', +        'email', +        'number', +        'search', +        'tel', +        'text', +        'textarea', +        'time', +        'url', +      ], +      type: { +        name: 'string', +        required: true, +      }, +    }, +    value: { +      control: { +        type: 'text', +      }, +      description: 'Field value.', +      type: { +        name: 'string', +        required: true, +      }, +    }, +  }, +} as ComponentMeta<typeof FieldComponent>; + +const Template: ComponentStory<typeof FieldComponent> = (args) => ( +  <FieldComponent {...args} /> +); + +export const Field = Template.bind({}); +Field.args = { +  setValue: () => null, +  value: '', +}; | 
