-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContactForm.js
More file actions
105 lines (98 loc) · 3.14 KB
/
ContactForm.js
File metadata and controls
105 lines (98 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
'use client'
import { useState } from "react"
import { motion } from "framer-motion"
import styles from "./ContactForm.module.css"
export default function ContactForm() {
const [form, setForm] = useState({ name: "", email: "", message: "" })
const [sending, setSending] = useState(false)
const [sent, setSent] = useState(false)
const handleChange = (e) =>
setForm((prev) => ({ ...prev, [e.target.name]: e.target.value }))
const handleSubmit = async (e) => {
e.preventDefault()
setSending(true)
await new Promise((r) => setTimeout(r, 1500))
setSending(false)
setSent(true)
setForm({ name: "", email: "", message: "" })
setTimeout(() => setSent(false), 4000)
}
return (
<section id="contato" className={styles.section}>
<div className="container">
<h2 className="section-title">Entre em Contato</h2>
<p className="section-subtitle">
Pronto para migrar seus projetos para o futuro? Fale conosco.
</p>
</div>
<motion.form
className={styles.form}
onSubmit={handleSubmit}
initial={{ opacity: 0, y: 30 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.6 }}
>
<div className={styles.row}>
<div className={styles.field}>
<label className={styles.label} htmlFor="name">Nome</label>
<input
id="name"
name="name"
className={styles.input}
placeholder="Seu nome"
value={form.name}
onChange={handleChange}
required
/>
</div>
<div className={styles.field}>
<label className={styles.label} htmlFor="email">Email</label>
<input
id="email"
name="email"
type="email"
className={styles.input}
placeholder="seu@email.com"
value={form.email}
onChange={handleChange}
required
/>
</div>
</div>
<div className={styles.field}>
<label className={styles.label} htmlFor="message">Mensagem</label>
<textarea
id="message"
name="message"
className={`${styles.input} ${styles.textarea}`}
placeholder="Conte-nos sobre seu projeto..."
rows={5}
value={form.message}
onChange={handleChange}
required
/>
</div>
<button
type="submit"
className="btn btn-primary"
style={{ width: "100%", justifyContent: "center" }}
disabled={sending}
>
{sending ? (
"Enviando..."
) : sent ? (
"✓ Mensagem Enviada!"
) : (
<>
Enviar Mensagem
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round">
<path d="M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z" />
</svg>
</>
)}
</button>
</motion.form>
</section>
)
}