2025-02-08 09:02:21 +00:00
|
|
|
"use client";
|
|
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
|
import ReactConfetti from "react-confetti";
|
|
|
|
|
import { useWindowSize } from "react-use";
|
|
|
|
|
import { useMediaQuery } from "usehooks-ts";
|
2025-01-06 11:43:35 +00:00
|
|
|
|
2025-01-06 13:17:03 +00:00
|
|
|
const Confetti = ({
|
|
|
|
|
numberOfPieces = 200,
|
2025-01-08 13:33:56 +00:00
|
|
|
showConfetti,
|
2025-01-06 13:17:03 +00:00
|
|
|
}: {
|
|
|
|
|
numberOfPieces?: number;
|
2025-01-08 13:33:56 +00:00
|
|
|
showConfetti: boolean;
|
2025-01-06 13:17:03 +00:00
|
|
|
}) => {
|
2025-02-08 09:02:21 +00:00
|
|
|
const [recycle, setRecycle] = useState<boolean>(true);
|
2025-01-06 11:43:35 +00:00
|
|
|
const { width, height } = useWindowSize();
|
|
|
|
|
const colors = [
|
2025-02-08 09:02:21 +00:00
|
|
|
"linear-gradient(45deg, #5D5D72, #8589DE)",
|
|
|
|
|
"linear-gradient(45deg, #E1E0FF, #575992)",
|
|
|
|
|
"#8589DE",
|
|
|
|
|
"#575992",
|
|
|
|
|
"#E1E0FF",
|
|
|
|
|
"#FF3131",
|
2025-01-06 11:43:35 +00:00
|
|
|
];
|
|
|
|
|
|
2025-02-08 09:02:21 +00:00
|
|
|
const mobile = useMediaQuery("(max-width: 426px)");
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setTimeout(() => setRecycle(false), 30000);
|
|
|
|
|
}, []);
|
2025-01-09 14:53:20 +00:00
|
|
|
|
2025-01-06 11:43:35 +00:00
|
|
|
return (
|
|
|
|
|
<div className="fixed top-0 left-0 z-50">
|
|
|
|
|
<ReactConfetti
|
|
|
|
|
width={width}
|
|
|
|
|
height={height}
|
2025-02-08 09:02:21 +00:00
|
|
|
recycle={recycle}
|
|
|
|
|
numberOfPieces={mobile ? 200 / 3 : 200}
|
2025-01-08 13:33:56 +00:00
|
|
|
tweenDuration={500}
|
2025-01-06 11:43:35 +00:00
|
|
|
colors={colors}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default Confetti;
|