Skip to content

Commit

Permalink
Merge pull request #171 from Puskar-Roy/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Puskar-Roy authored Nov 10, 2024
2 parents 069542d + 832a2ef commit b6389ee
Show file tree
Hide file tree
Showing 2 changed files with 188 additions and 66 deletions.
134 changes: 68 additions & 66 deletions apps/web/components/ContactForm.tsx
Original file line number Diff line number Diff line change
@@ -1,90 +1,92 @@
// Import necessary modules from React
import React, { useState } from 'react';
import { FaMapMarkerAlt, FaPhone, FaEnvelope } from 'react-icons/fa';

// Interface to define the props for ContactForm
interface ContactFormProps {
onClose: () => void; // Function to handle modal close event
onClose: () => void;
}

// Functional component definition for ContactForm
const ContactForm: React.FC<ContactFormProps> = ({ onClose }) => {
// State to manage form data (name, email, and message)
const [formData, setFormData] = useState({ name: '', email: '', message: '' });

// State to track if the form has been submitted
const [submitted, setSubmitted] = useState(false);

// Event handler for input and textarea changes
const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
const { name, value } = e.target; // Destructure name and value from the target element
setFormData((prev) => ({ ...prev, [name]: value })); // Update the form state dynamically
const { name, value } = e.target;
setFormData((prev) => ({ ...prev, [name]: value }));
};

// Event handler for form submission
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault(); // Prevent default form submission behavior
console.log(formData); // Log form data (can be replaced with API call)
setSubmitted(true); // Set the submitted state to true
setFormData({ name: '', email: '', message: '' }); // Reset form fields after submission
e.preventDefault();
console.log(formData);
setSubmitted(true);
setFormData({ name: '', email: '', message: '' });
};

return (
<div className="modal">
<div className="modal-content dark-theme">
{/* Close button for the modal */}
<span className="close" onClick={onClose}>&times;</span>

{/* Conditional rendering based on form submission status */}
{submitted ? (
<div className="success-message">Thank you for contacting us!</div>
) : (
<form onSubmit={handleSubmit}>
<h2 className="form-title neon-title">Contact Us</h2>

{/* Name Input Field */}
<label htmlFor="name">Name:</label>
<input
type="text"
id="name"
name="name"
value={formData.name}
onChange={handleChange}
required
className="form-input neon-input"
/>

{/* Email Input Field */}
<label htmlFor="email">Email:</label>
<input
type="email"
id="email"
name="email"
value={formData.email}
onChange={handleChange}
required
className="form-input neon-input"
/>

{/* Message Textarea */}
<label htmlFor="message">Message:</label>
<textarea
id="message"
name="message"
value={formData.message}
onChange={handleChange}
required
className="form-textarea neon-input"
></textarea>

{/* Submit Button */}
<button type="submit" className="submit-button neon-button">
Send Message
</button>
</form>
)}
<div className="contact-container">
<div className="info-column">
<h2 className="info-title"><b>Contact Information</b></h2>
<p>
<FaMapMarkerAlt className="info-icon" size={40} />
<strong> Location:</strong><br /> Kolkata - 700121
</p>
<br />
<p>
<FaPhone className="info-icon" size={40} />
<strong> Phone:</strong><br /> +123 456 7890
</p>
<br />
<p>
<FaEnvelope className="info-icon" size={40} />
<strong> Email:</strong><br /> puskarroy600@gmail.com
</p>
</div>
<div className="separator" /> {/* Added separator */}
<div className="form-column">
{submitted ? (
<div className="success-message">Thank you for contacting us!</div>
) : (
<form onSubmit={handleSubmit}>
<h2 className="form-title neon-title">Contact Us</h2>
<label htmlFor="name">Name:</label>
<input
type="text"
id="name"
name="name"
value={formData.name}
onChange={handleChange}
required
className="form-input neon-input"
/>
<label htmlFor="email">Email:</label>
<input
type="email"
id="email"
name="email"
value={formData.email}
onChange={handleChange}
required
className="form-input neon-input"
/>
<label htmlFor="message">Message:</label>
<textarea
id="message"
name="message"
value={formData.message}
onChange={handleChange}
required
className="form-textarea neon-input"
></textarea>
<button type="submit" className="submit-button neon-button">Send Message</button>
</form>
)}
</div>
</div>
</div>
</div>
);
};

export default ContactForm; // Export the ContactForm component
export default ContactForm;
120 changes: 120 additions & 0 deletions apps/web/components/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,126 @@
max-width: 90%;
box-shadow: 0px 0px 10px rgba(255, 255, 255, 0.1);
}
.modal {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: rgba(0, 0, 0, 0.8); /* Dark overlay */
display: flex;
justify-content: center;
align-items: center;
z-index: 1000;
}

.modal-content {
background: #1c1c1c; /* Dark background for the modal */
border-radius: 10px;
padding: 20px;
box-shadow: 0 0 20px rgba(255, 165, 0, 0.6); /* Orange glow */
width: 90%;
max-width: 800px;
position: relative;
display: flex; /* Flex layout for columns */
}

.close {
position: absolute;
top: 10px;
right: 15px;
color: #ff4500; /* Orange red color */
font-size: 24px;
cursor: pointer;
}

.contact-container {
display: flex;
width: 100%; /* Ensure the container fills the modal */
}

.info-column {
flex: 1; /* Left column takes up 1 part */
padding: 10px;
color: #ff4500; /* Orange red text */
margin-top: 5rem;
}

.form-column {
flex: 2; /* Right column takes up 2 parts */
padding: 10px;
}
.separator {
width:1px; /* Width of the vertical line */
background-color: #fc5f26; /* Line color */
margin: 0 20px;
opacity: 0.6;/* Margin between the columns */
height: auto; /* Stretch to fit */
}
.info-title {
margin-top: -12px;
margin-bottom: 10px;
font-size: 1.2rem;
}

.form-title {
color: #ff4500; /* Orange red color */
text-align: center;
margin-bottom: 20px;
margin-left: -280px;
text-shadow: 0 0 10px rgba(255, 165, 0, 0.8); /* Neon effect */
}

.form-input,
.form-textarea {
width: 100%;
padding: 10px;
margin: 10px 0;
border: 2px solid #ff4500; /* Orange red border */
border-radius: 5px;
background: #333; /* Dark background for inputs */
color: #fff; /* White text color */
transition: border-color 0.3s;
}

.form-input:focus,
.form-textarea:focus {
border-color: #ff4500; /* Bright orange border on focus */
outline: none; /* Remove default outline */
}

.submit-button {
background: linear-gradient(45deg, #ff4500, #ff8c00); /* Orange gradient */
color: #fff;
border: none;
padding: 10px;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
width: 100%;
transition: background 0.3s;
box-shadow: 0 0 2px rgba(255, 165, 0, 0.8); /* Neon effect */
}

.submit-button:hover {
background: linear-gradient(45deg, #ff8c00, #ff4500); /* Reverse gradient on hover */
}

.success-message {
color: #ff8c00; /* Light orange color */
text-align: center;
margin-top: 20px;
font-size: 18px;
}
.info-icon {
margin-right: 10px; /* Space between the icon and text */
color: #ff4500; /* Orange red color for the icons */
vertical-align: middle; /* Align icon vertically with text */
font-size: 1.5em;
display: flex; /* Use flexbox for each row */
align-items: center;
/* Additional size adjustment */
}

.close {
color: #fff;
Expand Down

0 comments on commit b6389ee

Please sign in to comment.