diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-09-20 16:38:54 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-09-20 16:38:54 +0200 |
| commit | f861e6a269ba9f62700776d3cd13b644a9e836d4 (patch) | |
| tree | a5a107e7a6e4ff8b4261fe04349357bc00b783ee /src/components/atoms/forms/label.tsx | |
| parent | 03331c44276ec56e9f235e4d5ee75030455a753f (diff) | |
refactor: use named export for everything except pages
Next expect a default export for pages so only those components should
use default exports. Everything else should use named exports to
reduce the number of import statements.
Diffstat (limited to 'src/components/atoms/forms/label.tsx')
| -rw-r--r-- | src/components/atoms/forms/label.tsx | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/src/components/atoms/forms/label.tsx b/src/components/atoms/forms/label.tsx index 2ec614f..6764579 100644 --- a/src/components/atoms/forms/label.tsx +++ b/src/components/atoms/forms/label.tsx @@ -1,24 +1,12 @@ -import { FC, ReactNode } from 'react'; +import { FC, LabelHTMLAttributes, ReactNode } from 'react'; import styles from './label.module.scss'; -export type LabelProps = { - /** - * An accessible name for the label. - */ - 'aria-label'?: string; +export type LabelProps = LabelHTMLAttributes<HTMLLabelElement> & { /** * The label body. */ children: ReactNode; /** - * Add classnames to the label. - */ - className?: string; - /** - * The field id. - */ - htmlFor?: string; - /** * Is the field required? Default: false. */ required?: boolean; @@ -33,7 +21,7 @@ export type LabelProps = { * * Render a HTML label element. */ -const Label: FC<LabelProps> = ({ +export const Label: FC<LabelProps> = ({ children, className = '', required = false, @@ -41,13 +29,12 @@ const Label: FC<LabelProps> = ({ ...props }) => { const sizeClass = styles[`label--${size}`]; + const labelClass = `${styles.label} ${sizeClass} ${className}`; return ( - <label className={`${styles.label} ${sizeClass} ${className}`} {...props}> + <label {...props} className={labelClass}> {children} {required && <span className={styles.required}> *</span>} </label> ); }; - -export default Label; |
