From a6ff5eee45215effb3344cb5d631a27a7c0369aa Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Fri, 22 Sep 2023 19:34:01 +0200 Subject: refactor(components): rewrite form components --- .../atoms/forms/fields/select/select.tsx | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/components/atoms/forms/fields/select/select.tsx (limited to 'src/components/atoms/forms/fields/select/select.tsx') diff --git a/src/components/atoms/forms/fields/select/select.tsx b/src/components/atoms/forms/fields/select/select.tsx new file mode 100644 index 0000000..887dacc --- /dev/null +++ b/src/components/atoms/forms/fields/select/select.tsx @@ -0,0 +1,76 @@ +import { FC, SelectHTMLAttributes } from 'react'; +import styles from '../fields.module.scss'; + +export type SelectOptions = { + /** + * The option id. + */ + id: string; + /** + * The option name. + */ + name: string; + /** + * The option value. + */ + value: string; +}; + +export type SelectProps = Omit< + SelectHTMLAttributes, + 'disabled' | 'hidden' | 'required' +> & { + /** + * Should the select field be disabled? + * + * @default false + */ + isDisabled?: boolean; + /** + * Should the select field be hidden? + * + * @default false + */ + isHidden?: boolean; + /** + * Is the select field required? + * + * @default false + */ + isRequired?: boolean; + /** + * True if the field is required. Default: false. + */ + options: SelectOptions[]; +}; + +/** + * Select component + * + * Render a HTML select element. + */ +export const Select: FC = ({ + className = '', + isDisabled = false, + isHidden = false, + isRequired = false, + options, + ...props +}) => { + const selectClass = `${styles.field} ${styles['field--select']} ${className}`; + + return ( + + ); +}; -- cgit v1.2.3