import { useState, useRef, useEffect } from 'react'; import { Heart, Volume2, VolumeX } from 'lucide-react'; export default function EnhancedLoveLetter() { const [isOpen, setIsOpen] = useState(false); const [isClosing, setIsClosing] = useState(false); const [isMuted, setIsMuted] = useState(true); const [isLoading, setIsLoading] = useState(true); const [showHearts, setShowHearts] = useState(false); const audioRef = useRef(null); // Convert Google Drive link to direct link const googleDriveImageId = "1CxBKovwF_K2Enol_d9KIhAUX0bjxi1_n"; const directImageUrl = `https://drive.google.com/uc?export=view&id=${googleDriveImageId}`; useEffect(() => { // Load confetti dynamically const script = document.createElement('script'); script.src = 'https://cdn.jsdelivr.net/npm/canvas-confetti@1.5.1/dist/confetti.browser.min.js'; document.body.appendChild(script); // Preload audio if (audioRef.current) { audioRef.current.load(); } setTimeout(() => { setIsLoading(false); setShowHearts(true); }, 1500); return () => { document.body.removeChild(script); }; }, []); const handleOpen = () => { if (!isOpen && window.confetti) { setIsOpen(true); window.confetti({ particleCount: 100, spread: 70, origin: { y: 0.6 } }); } }; const handleClose = () => { setIsClosing(true); setTimeout(() => { setIsOpen(false); setIsClosing(false); }, 1000); }; const toggleSound = async () => { try { if (audioRef.current) { if (isMuted) { // Play with user interaction const playPromise = audioRef.current.play(); if (playPromise !== undefined) { await playPromise; } } else { audioRef.current.pause(); } setIsMuted(!isMuted); } } catch (error) { console.error("Audio playback error:", error); } }; return (
{/* Loading Animation */} {isLoading && (
)} {/* Floating Hearts Background */} {showHearts && (
{[...Array(20)].map((_, i) => (
))}
)} {/* Sound Control with improved visibility and feedback */}
{/* Envelope */}
{/* Envelope Body */}
{/* Envelope Flap */}
{/* Heart Icon */}
{/* Letter Content */}
{/* Updated Image Section with Google Drive Image */}
Romantic { e.target.onerror = null; // Prevent infinite loop e.target.src = "https://images.unsplash.com/photo-1518621736915-f3b1c41bfd00?ixlib=rb-1.2.1&auto=format&fit=crop&w=600&q=80"; // Fallback image }} />
{/* Text Content */}

My Love Reemchuu,

Even though we're miles apart, you're always in my heart. I miss your smile, your voice, and the warmth you bring to my life. Each day without you is hard, but thoughts of you keep me strong.

I dream of the day I can hold you again, but until then, know that my love for you grows with every passing moment. No distance could ever change how much you mean to me.

Yours, always and forever,
Baby :)

{/* Close Button */}
); }