From cf210cc22ea392d8a5d9fa000554902a9d5b494a Mon Sep 17 00:00:00 2001 From: bender Date: Sun, 7 Jun 2026 22:37:58 +0000 Subject: [PATCH] Update src/app/page.tsx --- src/app/page.tsx | 57 +++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 47d2061..86f2f9d 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -7,6 +7,37 @@ import NavbarStyleApple from "@/components/navbar/NavbarStyleApple/NavbarStyleAp import { Heart, Sparkles } from "lucide-react"; import React, { useState, useMemo } from "react"; +// Helper functions for random calculations, defined outside the component +const generateConfettiProperties = () => ({ + left: `${Math.random() * 100}%`, + top: `${Math.random() * 100}%`, + width: `${Math.random() * 10 + 5}px`, + height: `${Math.random() * 10 + 5}px`, + animationDelay: `${Math.random() * 2}s`, + animationDuration: `${Math.random() * 3 + 2}s`, +}); + +const generateHeartProperties = () => ({ + left: `${Math.random() * 100}%`, + top: `${Math.random() * 100}%`, + animationDelay: `${Math.random() * 2}s`, + animationDuration: `${Math.random() * 3 + 2}s`, +}); + +const generateBalloonProperties = () => ({ + left: `${Math.random() * 100}%`, + top: `${Math.random() * 100}%`, + animationDelay: `${Math.random() * 2}s`, + animationDuration: `${Math.random() * 4 + 3}s`, +}); + +const generateConfettiTransform = () => { + const translateX = Math.random() * 400 - 200; + const translateY = Math.random() * 400 - 200; + const rotate = Math.random() * 360; + return `translate(${translateX}px, ${translateY}px) rotate(${rotate}deg)`; +}; + const noMessages = [ "Please kar lo na 🥺", "Main tum se bohat pyar karta hoon ❤️", "Ab to yes kar do na 🥹", "Please Jully, maan jao na ❤️", "Mere liye yes kar do 💕", "Last time bol raha hoon, yes kar do ❤️" ]; @@ -22,12 +53,7 @@ export default function LandingPage() { if (!showCelebration) return []; return Array.from({ length: 50 }).map((_, i) => ({ key: `confetti-${i}`, - left: `${Math.random() * 100}%`, - top: `${Math.random() * 100}%`, - width: `${Math.random() * 10 + 5}px`, - height: `${Math.random() * 10 + 5}px`, - animationDelay: `${Math.random() * 2}s`, - animationDuration: `${Math.random() * 3 + 2}s`, + ...generateConfettiProperties(), })); }, [showCelebration]); @@ -35,10 +61,7 @@ export default function LandingPage() { if (!showCelebration) return []; return Array.from({ length: 20 }).map((_, i) => ({ key: `heart-${i}`, - left: `${Math.random() * 100}%`, - top: `${Math.random() * 100}%`, - animationDelay: `${Math.random() * 2}s`, - animationDuration: `${Math.random() * 3 + 2}s`, + ...generateHeartProperties(), })); }, [showCelebration]); @@ -46,19 +69,13 @@ export default function LandingPage() { if (!showCelebration) return []; return Array.from({ length: 10 }).map((_, i) => ({ key: `balloon-${i}`, - left: `${Math.random() * 100}%`, - top: `${Math.random() * 100}%`, - animationDelay: `${Math.random() * 2}s`, - animationDuration: `${Math.random() * 4 + 3}s`, + ...generateBalloonProperties(), })); }, [showCelebration]); const confettiKeyframeEndTransform = useMemo(() => { if (!showCelebration) return `translate(0, 0) rotate(0deg)`; - const translateX = Math.random() * 400 - 200; - const translateY = Math.random() * 400 - 200; - const rotate = Math.random() * 360; - return `translate(${translateX}px, ${translateY}px) rotate(${rotate}deg)`; + return generateConfettiTransform(); }, [showCelebration]); const handleYes = () => { @@ -87,9 +104,6 @@ export default function LandingPage() { buttons.push({ text: "Yes", onClick: handleYes }); if (showNoButton) { buttons.push({ text: "No", onClick: handleNo }); - } else if (noClickCount >= noMessages.length - 1) { - // If no button is removed, and it's past the messages, show two Yes buttons - buttons.push({ text: "Yes!", onClick: handleYes }); } return buttons; }; @@ -167,7 +181,6 @@ export default function LandingPage() { {showCelebration && (
- {/* Confetti Effect */} {/* Confetti Effect */} {confettiPieces.map((props) => (