// WhatsApp floating widget + modal — tema adaptável por prop // Usage: function WhatsAppWidget({ theme, lang, content }) { const [open, setOpen] = React.useState(false); const [form, setForm] = React.useState({ name: '', email: '', phone: '', service: '' }); const [submitting, setSubmitting] = React.useState(false); const t = content.wa; const handleSubmit = (e) => { e.preventDefault(); if (!form.name || !form.phone) return; setSubmitting(true); const msg = encodeURIComponent( `${lang === 'pt' ? 'Olá! Sou' : 'Hi! I\'m'} ${form.name}.\n` + `${lang === 'pt' ? 'E-mail' : 'Email'}: ${form.email || '—'}\n` + `${lang === 'pt' ? 'Interesse' : 'Interest'}: ${form.service || '—'}` ); setTimeout(() => { // Placeholder — the real number would go here window.open(`https://wa.me/5511975435859?text=${msg}`, '_blank'); setSubmitting(false); setOpen(false); setForm({ name: '', email: '', phone: '', service: '' }); }, 600); }; const T = theme; return ( <> {/* Floating button */} {/* Backdrop + Modal */} {open && (
setOpen(false)} style={{ position: 'fixed', inset: 0, background: 'rgba(10,10,10,0.55)', backdropFilter: 'blur(4px)', zIndex: 9999, display: 'flex', alignItems: 'flex-end', justifyContent: 'flex-end', padding: 24, animation: 'auraFade .2s ease', }} >
e.stopPropagation()} style={{ width: 'min(420px, 100%)', background: T.surface, color: T.fg, borderRadius: T.radius || 20, border: T.border || 'none', overflow: 'hidden', marginBottom: 90, marginRight: 0, boxShadow: '0 30px 80px rgba(0,0,0,0.4)', fontFamily: T.font, animation: 'auraSlideUp .35s cubic-bezier(.2,.8,.2,1)', }} > {/* Header */}
Estúdio Aura
{t.title}
{t.sub}
{/* Form */}
setForm({ ...form, name: v })} placeholder={t.name + ' *'} theme={T} required /> setForm({ ...form, email: v })} placeholder={t.email} theme={T} type="email" />
🇧🇷 +55
setForm({ ...form, phone: v })} placeholder={t.phone + ' *'} theme={T} type="tel" required style={{ flex: 1 }} />
setForm({ ...form, service: v })} placeholder={t.service} options={t.services} theme={T} />
)} ); } function WAField({ value, onChange, placeholder, theme, type = 'text', required, style }) { return ( onChange(e.target.value)} placeholder={placeholder} required={required} style={{ height: 46, padding: '0 14px', background: theme.inputBg, border: theme.inputBorder, borderRadius: theme.inputRadius || 10, fontSize: 14, color: theme.fg, fontFamily: theme.font, outline: 'none', width: '100%', boxSizing: 'border-box', transition: 'border-color .15s', ...style, }} onFocus={(e) => { if (theme.focusBorder) e.target.style.border = theme.focusBorder; }} onBlur={(e) => { e.target.style.border = theme.inputBorder; }} /> ); } function WASelect({ value, onChange, placeholder, options, theme }) { return ( ); } // Global animations for the widget if (typeof document !== 'undefined' && !document.getElementById('aura-wa-anims')) { const s = document.createElement('style'); s.id = 'aura-wa-anims'; s.textContent = ` @keyframes auraPulse { 0%,100%{transform:scale(1);opacity:1} 50%{transform:scale(1.3);opacity:.7} } @keyframes auraFade { from{opacity:0} to{opacity:1} } @keyframes auraSlideUp { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} } `; document.head.appendChild(s); } Object.assign(window, { WhatsAppWidget });