Skip to content

Commit 7dfe75c

Browse files
lucksptFrancisca105
authored andcommitted
confetti on animation end
1 parent 04f5c5a commit 7dfe75c

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

src/components/prize/PrizeDrawAnimation.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import Image from "next/image";
44
import { useEffect, useState } from "react";
5+
import Confetti from "react-confetti";
6+
import { useWindowSize } from "react-use";
57

68
interface PrizeDrawAnimationProps {
79
participants: User[];
@@ -30,6 +32,7 @@ export function PrizeDrawAnimation({
3032
const [showWinner, setShowWinner] = useState(false);
3133
const [showPrize, setShowPrize] = useState(false);
3234
const [animationDuration, setAnimationDuration] = useState(1000);
35+
const { width: windowWidth, height: windowHeight } = useWindowSize();
3336

3437
useEffect(() => {
3538
// Calculate dynamic timing based on participant count
@@ -191,6 +194,14 @@ export function PrizeDrawAnimation({
191194
{/* Winner reveal */}
192195
{showWinner && (
193196
<div className="absolute inset-0 flex items-center justify-center animate-winner-reveal">
197+
{/* Confetti effect */}
198+
<Confetti
199+
width={windowWidth}
200+
height={windowHeight}
201+
numberOfPieces={500}
202+
recycle={false}
203+
/>
204+
194205
<div className="relative flex flex-col items-center gap-6">
195206
<div className="relative">
196207
<Image

src/components/prize/PrizeTile.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,14 @@ export function PrizeTile({
106106
/>
107107
{winner && !isOverlayOpen && (
108108
<div className="flex flex-col justify-center items-center text-center gap-y-2 w-full">
109-
<Confetti
110-
width={windowWidth}
111-
height={windowHeight}
112-
numberOfPieces={500}
113-
recycle={false}
114-
/>
109+
{ disableAnimation && (
110+
<Confetti
111+
width={windowWidth}
112+
height={windowHeight}
113+
numberOfPieces={500}
114+
recycle={false}
115+
/>
116+
)}
115117
<Link href={`/users/${winner.id}`}>
116118
<Image
117119
className="size-[128px] object-contain"

0 commit comments

Comments
 (0)