Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

created contact form #49

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
"dependencies": {
"@docusaurus/core": "3.1.0",
"@docusaurus/preset-classic": "3.1.0",
"@emailjs/browser": "^4.3.3",
"@mdx-js/react": "^3.0.0",
"clsx": "^2.0.0",
"emailjs": "^4.0.3",
"postcss-loader": "^8.0.0",
"prism-react-renderer": "^2.3.0",
"react": "^18.0.0",
Expand Down
138 changes: 138 additions & 0 deletions src/components/UI Components/ContactPageForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import { useState } from "react";
import { FaUser, FaEnvelope, FaBook, FaMessage} from "react-icons/fa6";
import Message from "../../../static/img/message.svg";
import emailjs from "@emailjs/browser";


type formFields = {
name: string;
email: string;
question: string;
comment: string;
};

const ContactPageForm = () => {
const [formValues, setFormValues] = useState<formFields>({
name: "",
email: "",
question: "",
comment: "",
});
const [formSent, setFormSent] = useState<boolean>(false);

const updateFormValues = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
const fieldName = e.target.name;
const fieldValue = e.target.value;
setFormValues((values) => ({ ...values, [fieldName]: fieldValue }));
};

const submit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault(); // stop page refresh on submit

//idrk what to do with the form inputs, probably send to an API somewhere
emailjs.sendForm('service_g5pvqxb', 'template_tznfo8k', e.target as HTMLFormElement, 'yrcBV_oYPU2TTOtbs');
setFormValues({name: "", email:"", question:"", comment:""});
setFormSent(true);
};

return (<>
<div className="flex bg-slate-100 relative justify-around mt-20 md:px-8 p-0 md:py-16">
<div className="hidden md:block ml-8">
<Message/>
</div>
<div className="relative bg-white rounded-md md:shadow-md md:shadow-slate-200 shadow-none p-8 md:ml-8 m-0 md:w-3/5 w-full pb-20">
<h2 className="m-2">Get In Touch!</h2>
<form
onSubmit={submit}
className="relative"
>
<div className="text-lg grid grid-cols-2">
<div className="mx-2 mt-6">
<h4 className="font-medium my-2">Your Name:</h4>
<div style={{border: "1px solid rgb(148, 163, 184)"}} className="flex flex-row items-start rounded-sm border-2 border-slate-400 pl-3">
<div className="pt-2">
<FaUser/>
</div>
<input
required
type="text"
name="name"
placeholder="Name:"
value={formValues.name}
onChange={updateFormValues}
className=" text-sm border-0 focus:outline-none focus:bg-gray-100 p-1 m-1 w-full"
/>
</div>
</div>
<div className="mx-2 mt-6">
<h4 className="font-medium my-2">Your Email:</h4>
<div style={{border: "1px solid rgb(148, 163, 184)"}} className="flex flex-row items-top rounded-sm border-2 border-slate-400 pl-3">
<div className="pt-2">
<FaEnvelope/>
</div>
<input
required
type="text"
name="email"
placeholder="Email:"
value={formValues.email}
onChange={updateFormValues}
className=" text-sm border-0 focus:outline-none focus:bg-gray-100 p-1 m-1 w-full"
/>
</div>
</div>
</div>
<div className="mx-2 mt-6">
<h4 className="font-medium my-2">Your Question:</h4>
<div style={{border: "1px solid rgb(148, 163, 184)"}} className="flex flex-row items-start rounded-sm border-2 border-slate-400 pl-3">
<div className="pt-2">
<FaBook/>
</div>
<input
type="text"
name="question"
placeholder="Subject:"
value={formValues.question}
onChange={updateFormValues}
className=" text-sm border-0 focus:outline-none focus:bg-gray-100 p-1 m-1 w-full"
/>
</div>
</div>
<div className="mx-2 mt-6">
<h4 className="font-medium my-2">Your Comment:</h4>
<div style={{border: "1px solid rgb(148, 163, 184)"}} className="flex flex-row items-start rounded-sm border-2 border-slate-400 pl-3">
<div className="pt-2">
<FaMessage/>
</div>
<textarea
name="comment"
placeholder="Message:"
value={formValues.comment}
onChange={updateFormValues}
className="text-sm border-0 focus:outline-none focus:bg-gray-100 p-1 m-1 w-full font-sans resize-y"
/>
</div>
</div>
<input
type="submit"
value="Send Message"
className="btn bg-green-600 hover:bg-green-700 border-none text-lg font-medium font-sans text-white rounded-md m-2 mt-8 py-2 px-4 cursor-pointer"
>
</input>
</form>
{ formSent ?
<div className="absolute top-0 left-0 w-full h-full rounded-md bg-white bg-opacity-80 flex flex-col justify-center items-center">
<h2>Message Sent!</h2>
<button
className="btn bg-green-600 hover:bg-green-700 border-none text-lg font-medium font-sans text-white rounded-md m-2 mt-8 py-2 px-4 cursor-pointer"
onClick={()=> setFormSent(false)}
>
Send Another
</button>
</div> : null}
</div>
</div>
</>);
};

export default ContactPageForm;
9 changes: 3 additions & 6 deletions src/pages/contact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ import Layout from '@theme/Layout';
import styles from "@site/src/pages/index.module.css";
import Heading from "@theme/Heading";
import SquaredButton from '../components/UI Components/SquaredButton';
import ContactPageForm from '../components/UI Components/ContactPageForm';

function ContactPageHeader() {

return (
<Layout>
<section className="relative md:py-24 py-16">



<section className="relative md:pt-24 pt-16">
<div className="container">
<div className="grid grid-cols-1 pt-16 pb-8 text-center">
<h3 className="pt-12 mb-4 md:leading-normal text-4xl leading-normal font-semibold">Contact Us</h3>
Expand All @@ -25,7 +23,6 @@ function ContactPageHeader() {
<p className="mt-1 text-slate-400 max-w-xl mx-auto"> Let's chat! </p>
</div>


<div className="grid grid-cols-1 lg:grid-cols-3 md:grid-cols-2 gap-[30px]">
<div className="text-center px-6 mt-6">
<div
Expand Down Expand Up @@ -78,7 +75,7 @@ function ContactPageHeader() {
</div>
</div>
</div>

<ContactPageForm/>
</section>
</Layout>
);
Expand Down
Loading