From eb459cc248a5940a14193b20d263ffee3d345026 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Thu, 16 Dec 2021 13:40:12 +0100
Subject: chore: create contact page

---
 src/components/Form/TextArea/TextArea.tsx | 42 +++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 src/components/Form/TextArea/TextArea.tsx

(limited to 'src/components/Form/TextArea/TextArea.tsx')

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<string>) => void;
+  required?: boolean;
+  label?: string;
+}) => {
+  const updateValue = (e: ChangeEvent<HTMLTextAreaElement>) => {
+    setValue(e.target.value);
+  };
+
+  return (
+    <>
+      {label && (
+        <label htmlFor={id} className={styles.label}>
+          {label}
+          {required && <span> *</span>}
+        </label>
+      )}
+      <textarea
+        id={id}
+        name={name}
+        value={value}
+        onChange={updateValue}
+        className={`${styles.field} ${styles.textarea}`}
+      />
+    </>
+  );
+};
+
+export default TextArea;
-- 
cgit v1.2.3

