Skip to content

Commit

Permalink
ContactForm.jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
BVPKARTHIKEYA authored Oct 9, 2024
1 parent 2a54de7 commit 9918ee4
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions src/components/Contact-section/ContactForm.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { useState } from "react";
import "./Contact-section.css"; // Ensure this path is correct
import FirstNameIcon from "../../assets/icons/first-name-icon.png"; // Replace with your actual path
import LastNameIcon from "../../assets/icons/last-name-icon.png"; // Replace with your actual path
import EmailIcon from "../../assets/icons/email-icon.png"; // Replace with your actual path
import MessageIcon from "../../assets/icons/message-icon.png"; // Replace with your actual path
import Github from "../../assets/Social-Icons/Github.png";
import Insta from "../../assets/Social-Icons/instagram.png";
import Twitter from "../../assets/Social-Icons/Twitter.png";

const ContactForm = () => {
const [contactForm, setContactForm] = useState({
Expand All @@ -21,7 +25,6 @@ const ContactForm = () => {
const handleSubmit = (e) => {
e.preventDefault();
const validationContactErrors = {};

if (!contactForm.firstName.trim()) {
validationContactErrors.firstName = "First name is required";
}
Expand All @@ -37,7 +40,6 @@ const ContactForm = () => {
if (!contactForm.message.trim()) {
validationContactErrors.message = "Message is required";
}

setContactErrors(validationContactErrors);

if (Object.keys(validationContactErrors).length === 0) {
Expand All @@ -54,6 +56,7 @@ const ContactForm = () => {
return (
<>
<section className="flex flex-col md:flex-row gap-y-10 my-20">
{/* Left hand side of the form */}
{/* Right hand side of the form */}
<article className="flex flex-1 justify-center p-5 md:p-0 md:mr-24">
<form onSubmit={handleSubmit} className="gap-x-5 w-full">
Expand All @@ -72,7 +75,7 @@ const ContactForm = () => {
</span>
</div>
<div className="flex flex-col md:w-6/12 relative">
<img src={FirstNameIcon} alt="Last Name Icon" className="absolute left-3 top-4 w-5 h-5" />
<img src={LastNameIcon} alt="Last Name Icon" className="absolute left-3 top-4 w-5 h-5" />
<input
className="border-2 border-green rounded-lg h-16 text-green-dark pl-10 placeholder-textBlack p-2"
placeholder="Last name"
Expand All @@ -85,18 +88,20 @@ const ContactForm = () => {
</span>
</div>
</div>
<div className="flex flex-col w-full relative">
<img src={EmailIcon} alt="Email Icon" className="absolute left-3 top-4 w-5 h-5" />
<input
className="border-2 border-green rounded-lg h-16 text-green-dark pl-10 placeholder-textBlack p-2"
placeholder="Email"
name="email"
value={contactForm.email}
onChange={handleChange}
/>
<span className="pl-4 text-[#ff0000] text-sm">
{contactErrors.email}
</span>
<div className="flex flex-col md:flex-row mb-6 justify-between">
<div className="flex flex-col w-full relative">
<img src={EmailIcon} alt="Email Icon" className="absolute left-3 top-4 w-5 h-5" />
<input
className="border-2 border-green rounded-lg h-16 text-green-dark pl-10 placeholder-textBlack p-2"
placeholder="Email"
name="email"
value={contactForm.email}
onChange={handleChange}
/>
<span className="pl-4 text-[#ff0000] text-sm">
{contactErrors.email}
</span>
</div>
</div>

<div className="flex flex-col w-full relative">
Expand All @@ -113,7 +118,7 @@ const ContactForm = () => {
</span>
</div>

<div className="flex justify-center md:justify-start">
<div className="flex justify-center md:justify-start ">
<button
id="text"
className="relative flex cursor-pointer items-center justify-center mt-5 bg-green rounded-lg w-40 lg:w-60 p-3 text-textWhite text-2xl md:text-xl font-bold font-monsterrat ease-in-out duration-300 hover:bg-[transparent] hover:text-green hover:border-green hover:border-[2px]"
Expand Down

0 comments on commit 9918ee4

Please sign in to comment.