Skip to content

Commit 2524768

Browse files
committed
Add reusable form input component
1 parent d521385 commit 2524768

File tree

2 files changed

+61
-51
lines changed

2 files changed

+61
-51
lines changed

src/components/contact/ContactForm.jsx

+28-51
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Button from '../reusable/Button';
2+
import FormInput from '../reusable/FormInput';
23

34
const ContactForm = () => {
45
return (
@@ -13,57 +14,33 @@ const ContactForm = () => {
1314
<p className="font-general-medium text-primary-dark dark:text-primary-light text-2xl mb-8">
1415
Contact Form
1516
</p>
16-
<div className="font-general-regular">
17-
<label
18-
className="block text-lg text-primary-dark dark:text-primary-light mb-2"
19-
htmlFor="name"
20-
>
21-
Full Name
22-
</label>
23-
<input
24-
className="w-full px-5 py-2 border border-gray-300 dark:border-primary-dark border-opacity-50 text-primary-dark dark:text-secondary-light bg-ternary-light dark:bg-ternary-dark rounded-md shadow-sm text-md"
25-
id="name"
26-
name="name"
27-
type="text"
28-
required
29-
placeholder="Your Name"
30-
aria-label="Name"
31-
/>
32-
</div>
33-
<div className="mt-6">
34-
<label
35-
className="block text-lg text-primary-dark dark:text-primary-light mb-2"
36-
htmlFor="email"
37-
>
38-
Email
39-
</label>
40-
<input
41-
className="w-full px-5 py-2 border border-gray-300 dark:border-primary-dark border-opacity-50 text-primary-dark dark:text-secondary-light bg-ternary-light dark:bg-ternary-dark rounded-md shadow-sm text-md"
42-
id="email"
43-
name="email"
44-
type="text"
45-
required
46-
placeholder="Your Email"
47-
aria-label="Email"
48-
/>
49-
</div>
50-
<div className="mt-6">
51-
<label
52-
className="block text-lg text-primary-dark dark:text-primary-light mb-2"
53-
htmlFor="subject"
54-
>
55-
Subject
56-
</label>
57-
<input
58-
className="w-full px-5 py-2 border border-gray-300 dark:border-primary-dark border-opacity-50 text-primary-dark dark:text-secondary-light bg-ternary-light dark:bg-ternary-dark rounded-md shadow-sm text-md"
59-
id="subject"
60-
name="subject"
61-
type="text"
62-
required
63-
placeholder="Subject"
64-
aria-label="Subject"
65-
/>
66-
</div>
17+
<FormInput
18+
inputLabel="Full Name"
19+
labelFor="name"
20+
inputType="text"
21+
inputId="name"
22+
inputName="name"
23+
placeholderText="Your Name"
24+
ariaLabelName="Name"
25+
/>
26+
<FormInput
27+
inputLabel="Email"
28+
labelFor="email"
29+
inputType="email"
30+
inputId="email"
31+
inputName="email"
32+
placeholderText="Your email"
33+
ariaLabelName="Email"
34+
/>
35+
<FormInput
36+
inputLabel="Subject"
37+
labelFor="subject"
38+
inputType="text"
39+
inputId="subject"
40+
inputName="subject"
41+
placeholderText="Subject"
42+
ariaLabelName="Subject"
43+
/>
6744

6845
<div className="mt-6">
6946
<label

src/components/reusable/FormInput.jsx

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React from 'react';
2+
3+
const FormInput = ({
4+
inputLabel,
5+
labelFor,
6+
inputType,
7+
inputId,
8+
inputName,
9+
placeholderText,
10+
ariaLabelName,
11+
}) => {
12+
return (
13+
<div className="font-general-regular mb-4">
14+
<label
15+
className="block text-lg text-primary-dark dark:text-primary-light mb-1"
16+
htmlFor={labelFor}
17+
>
18+
{inputLabel}
19+
</label>
20+
<input
21+
className="w-full px-5 py-2 border border-gray-300 dark:border-primary-dark border-opacity-50 text-primary-dark dark:text-secondary-light bg-ternary-light dark:bg-ternary-dark rounded-md shadow-sm text-md"
22+
type={inputType}
23+
id={inputId}
24+
name={inputName}
25+
placeholder={placeholderText}
26+
aria-label={ariaLabelName}
27+
required
28+
/>
29+
</div>
30+
);
31+
};
32+
33+
export default FormInput;

0 commit comments

Comments
 (0)