From cb4764f8670f67627c407591c89b8d3637c190a7 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Fri, 25 Feb 2022 18:02:55 +0100 Subject: refactor: replace label elements with Label component --- src/components/Form/Form.module.scss | 12 ------------ src/components/Form/Input/Input.tsx | 19 +++++++++---------- src/components/Form/TextArea/TextArea.tsx | 13 +++---------- 3 files changed, 12 insertions(+), 32 deletions(-) (limited to 'src/components/Form') diff --git a/src/components/Form/Form.module.scss b/src/components/Form/Form.module.scss index e805c52..6ccdb11 100644 --- a/src/components/Form/Form.module.scss +++ b/src/components/Form/Form.module.scss @@ -27,14 +27,6 @@ max-width: 45ch; } -.label { - display: block; - color: var(--color-primary-darker); - font-size: var(--font-size-sm); - font-variant: small-caps; - font-weight: 600; -} - .field { width: 100%; padding: var(--spacing-2xs) var(--spacing-xs); @@ -63,10 +55,6 @@ min-height: fun.convert-px(200); } -.required { - color: var(--color-secondary); -} - .wrapper--search { > input { padding-right: calc(var(--btn-size) + var(--spacing-2xs)); diff --git a/src/components/Form/Input/Input.tsx b/src/components/Form/Input/Input.tsx index 986ea63..07f0410 100644 --- a/src/components/Form/Input/Input.tsx +++ b/src/components/Form/Input/Input.tsx @@ -1,4 +1,10 @@ -import { ChangeEvent, ForwardedRef, forwardRef, SetStateAction } from 'react'; +import { + ChangeEvent, + ForwardedRef, + forwardRef, + ReactElement, + SetStateAction, +} from 'react'; import styles from '../Form.module.scss'; type InputType = 'text' | 'email' | 'number' | 'search'; @@ -10,7 +16,6 @@ const Input = ( value, setValue, type = 'text', - required = false, label, }: { id: string; @@ -18,8 +23,7 @@ const Input = ( value: string; setValue: (value: SetStateAction) => void; type?: InputType; - required?: boolean; - label?: string; + label?: ReactElement; }, ref: ForwardedRef ) => { @@ -29,12 +33,7 @@ const Input = ( return ( <> - {label && ( - - )} + {label} ) => void; - required?: boolean; - label?: string; + label?: ReactElement; }) => { const updateValue = (e: ChangeEvent) => { setValue(e.target.value); @@ -22,12 +20,7 @@ const TextArea = ({ return ( <> - {label && ( - - )} + {label}