diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-04-08 22:36:24 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-04-08 23:31:58 +0200 |
| commit | 0b3146f7278929c4d1b33dd8f94f34e351e5e5a9 (patch) | |
| tree | 6a784b197a283a7da07c2e1df80a29fee8b3790a /src/components/atoms/forms/field.tsx | |
| parent | 61278678ea8a8febee0574cd0f6006492d7b15cb (diff) | |
chore: add a Settings modal component
Diffstat (limited to 'src/components/atoms/forms/field.tsx')
| -rw-r--r-- | src/components/atoms/forms/field.tsx | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/components/atoms/forms/field.tsx b/src/components/atoms/forms/field.tsx index 513d2ba..2e75d0f 100644 --- a/src/components/atoms/forms/field.tsx +++ b/src/components/atoms/forms/field.tsx @@ -1,4 +1,4 @@ -import { ChangeEvent, FC, SetStateAction } from 'react'; +import { ChangeEvent, SetStateAction, VFC } from 'react'; import styles from './forms.module.scss'; export type FieldType = @@ -14,6 +14,14 @@ export type FieldType = export type FieldProps = { /** + * One or more ids that refers to the field name. + */ + 'aria-labelledby'?: string; + /** + * Add classnames to the field. + */ + className?: string; + /** * Field state. Either enabled (false) or disabled (true). */ disabled?: boolean; @@ -64,7 +72,12 @@ export type FieldProps = { * * Render either an input or a textarea. */ -const Field: FC<FieldProps> = ({ setValue, type, ...props }) => { +const Field: VFC<FieldProps> = ({ + className = '', + setValue, + type, + ...props +}) => { /** * Update select value when an option is selected. * @param e - The option change event. @@ -78,14 +91,14 @@ const Field: FC<FieldProps> = ({ setValue, type, ...props }) => { return type === 'textarea' ? ( <textarea onChange={updateValue} - className={`${styles.field} ${styles['field--textarea']}`} + className={`${styles.field} ${styles['field--textarea']} ${className}`} {...props} /> ) : ( <input type={type} onChange={updateValue} - className={styles.field} + className={`${styles.field} ${className}`} {...props} /> ); |
