From eb459cc248a5940a14193b20d263ffee3d345026 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Thu, 16 Dec 2021 13:40:12 +0100 Subject: chore: create contact page --- src/components/Form/Form.module.scss | 31 ++++++++++++++++++++ src/components/Form/Form.tsx | 16 +++++++++++ src/components/Form/FormItem/FormItem.tsx | 7 +++++ src/components/Form/Input/Input.tsx | 47 +++++++++++++++++++++++++++++++ src/components/Form/TextArea/TextArea.tsx | 42 +++++++++++++++++++++++++++ src/components/Form/index.tsx | 6 ++++ 6 files changed, 149 insertions(+) create mode 100644 src/components/Form/Form.module.scss create mode 100644 src/components/Form/Form.tsx create mode 100644 src/components/Form/FormItem/FormItem.tsx create mode 100644 src/components/Form/Input/Input.tsx create mode 100644 src/components/Form/TextArea/TextArea.tsx create mode 100644 src/components/Form/index.tsx (limited to 'src/components/Form') diff --git a/src/components/Form/Form.module.scss b/src/components/Form/Form.module.scss new file mode 100644 index 0000000..f23dfde --- /dev/null +++ b/src/components/Form/Form.module.scss @@ -0,0 +1,31 @@ +@use "@styles/abstracts/functions" as fun; + +.wrapper { + width: 100%; +} + +.item { + margin: var(--spacing-xs) 0; + max-width: 45ch; +} + +.label { + display: block; + font-size: var(--font-size-sm); + font-variant: small-caps; + font-weight: 600; +} + +.field { + border: fun.convert-px(1) solid var(--color-border); + width: 100%; + padding: var(--spacing-2xs) var(--spacing-xs); + + &:focus { + border-color: var(--color-primary); + } +} + +.textarea { + min-height: fun.convert-px(200); +} diff --git a/src/components/Form/Form.tsx b/src/components/Form/Form.tsx new file mode 100644 index 0000000..cc97526 --- /dev/null +++ b/src/components/Form/Form.tsx @@ -0,0 +1,16 @@ +import { FormEvent } from 'react'; +import styles from './Form.module.scss'; + +const Form: React.FunctionComponent = ({ children }) => { + const submitForm = (e: FormEvent) => { + e.preventDefault(); + }; + + return ( +
+ {children} +
+ ); +}; + +export default Form; diff --git a/src/components/Form/FormItem/FormItem.tsx b/src/components/Form/FormItem/FormItem.tsx new file mode 100644 index 0000000..0f12e64 --- /dev/null +++ b/src/components/Form/FormItem/FormItem.tsx @@ -0,0 +1,7 @@ +import styles from '../Form.module.scss'; + +const FormItem: React.FunctionComponent = ({ children }) => { + return
{children}
; +}; + +export default FormItem; diff --git a/src/components/Form/Input/Input.tsx b/src/components/Form/Input/Input.tsx new file mode 100644 index 0000000..901b9ab --- /dev/null +++ b/src/components/Form/Input/Input.tsx @@ -0,0 +1,47 @@ +import { ChangeEvent, SetStateAction } from 'react'; +import styles from '../Form.module.scss'; + +type InputType = 'text' | 'number'; + +const Input = ({ + id, + name, + value, + setValue, + type = 'text', + required = false, + label, +}: { + id: string; + name: string; + value: string; + setValue: (value: SetStateAction) => void; + type?: InputType; + required?: boolean; + label?: string; +}) => { + const updateValue = (e: ChangeEvent) => { + setValue(e.target.value); + }; + + return ( + <> + {label && ( + + )} + + + ); +}; + +export default Input; diff --git a/src/components/Form/TextArea/TextArea.tsx b/src/components/Form/TextArea/TextArea.tsx new file mode 100644 index 0000000..729ef6d --- /dev/null +++ b/src/components/Form/TextArea/TextArea.tsx @@ -0,0 +1,42 @@ +import { ChangeEvent, SetStateAction } from 'react'; +import styles from '../Form.module.scss'; + +const TextArea = ({ + id, + name, + value, + setValue, + required = false, + label, +}: { + id: string; + name: string; + value: string; + setValue: (value: SetStateAction) => void; + required?: boolean; + label?: string; +}) => { + const updateValue = (e: ChangeEvent) => { + setValue(e.target.value); + }; + + return ( + <> + {label && ( + + )} +