|
| 1 | +"use client" |
| 2 | + |
| 3 | +import { useState, useEffect } from "react" |
| 4 | +import { Heart, Share2 } from "lucide-react" |
| 5 | +import confetti from "canvas-confetti" |
| 6 | + |
| 7 | +export default function ValentinePage() { |
| 8 | + const [showMessage, setShowMessage] = useState(false) |
| 9 | + const [answer, setAnswer] = useState<string | null>(null) |
| 10 | + |
| 11 | + useEffect(() => { |
| 12 | + const timer = setTimeout(() => setShowMessage(true), 1000) |
| 13 | + return () => clearTimeout(timer) |
| 14 | + }, []) |
| 15 | + |
| 16 | + const handleAnswer = (response: "yes" | "no") => { |
| 17 | + setAnswer(response) |
| 18 | + if (response === "yes") { |
| 19 | + confetti({ |
| 20 | + particleCount: 100, |
| 21 | + spread: 70, |
| 22 | + origin: { y: 0.6 }, |
| 23 | + }) |
| 24 | + } |
| 25 | + } |
| 26 | + |
| 27 | + const shareLink = () => { |
| 28 | + if (navigator.share) { |
| 29 | + navigator |
| 30 | + .share({ |
| 31 | + title: "¿Quieres ser mi San Valentín?", |
| 32 | + url: window.location.href, |
| 33 | + }) |
| 34 | + .then(() => { |
| 35 | + console.log("Gracias por compartir!") |
| 36 | + }) |
| 37 | + .catch(console.error) |
| 38 | + } else { |
| 39 | + // Fallback para navegadores que no soportan Web Share API |
| 40 | + navigator.clipboard.writeText(window.location.href).then( |
| 41 | + () => { |
| 42 | + alert("Enlace copiado al portapapeles!") |
| 43 | + }, |
| 44 | + (err) => { |
| 45 | + console.error("No se pudo copiar el texto: ", err) |
| 46 | + }, |
| 47 | + ) |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + return ( |
| 52 | + <div className="min-h-screen bg-gradient-to-br from-pink-200 to-red-100 flex flex-col items-center justify-center p-4 text-center"> |
| 53 | + <div className={`transition-opacity duration-1000 ${showMessage ? "opacity-100" : "opacity-0"}`}> |
| 54 | + <h1 className="text-4xl font-bold text-red-600 mb-6">Mi princesa hermosa Amarantha Perez</h1> |
| 55 | + <div className="text-3xl font-semibold text-pink-700 mb-8 animate-pulse">¿Quieres ser mi San Valentín?</div> |
| 56 | + <div className="flex justify-center space-x-4 mb-8"> |
| 57 | + <Heart className="text-red-500 w-16 h-16 animate-bounce" /> |
| 58 | + <Heart className="text-pink-500 w-16 h-16 animate-bounce delay-100" /> |
| 59 | + <Heart className="text-red-500 w-16 h-16 animate-bounce delay-200" /> |
| 60 | + </div> |
| 61 | + {answer === null ? ( |
| 62 | + <div className="space-x-4"> |
| 63 | + <button |
| 64 | + onClick={() => handleAnswer("yes")} |
| 65 | + className="bg-green-500 hover:bg-green-600 text-white font-bold py-2 px-4 rounded-full transition duration-300" |
| 66 | + > |
| 67 | + ¡Sí, quiero! |
| 68 | + </button> |
| 69 | + <button |
| 70 | + onClick={() => handleAnswer("no")} |
| 71 | + className="bg-gray-500 hover:bg-gray-600 text-white font-bold py-2 px-4 rounded-full transition duration-300" |
| 72 | + > |
| 73 | + No, gracias |
| 74 | + </button> |
| 75 | + </div> |
| 76 | + ) : ( |
| 77 | + <div className="text-2xl font-bold mt-4"> |
| 78 | + {answer === "yes" ? "¡Qué felicidad! ¡Te amo! ❤️" : "Oh, está bien. Quizás la próxima vez. 😢"} |
| 79 | + </div> |
| 80 | + )} |
| 81 | + </div> |
| 82 | + <button |
| 83 | + onClick={shareLink} |
| 84 | + className="mt-8 bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded-full transition duration-300 flex items-center" |
| 85 | + > |
| 86 | + <Share2 className="mr-2" /> Compartir |
| 87 | + </button> |
| 88 | + </div> |
| 89 | + ) |
| 90 | +} |
| 91 | + |
| 92 | + |
0 commit comments