Skip to content

Commit 5847c3f

Browse files
committed
Add Giveaway Page with Countdown Timer, Confetti, and Leaderboard
1 parent 5aa16f3 commit 5847c3f

File tree

3 files changed

+33
-13
lines changed

3 files changed

+33
-13
lines changed

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
"typecheck": "tsc"
1616
},
1717
"dependencies": {
18-
"@docusaurus/core": "3.7.0",
18+
"@docusaurus/core": "^3.7.0",
1919
"@docusaurus/plugin-content-docs": "3.7.0",
2020
"@docusaurus/plugin-google-analytics": "^3.8.1",
2121
"@docusaurus/plugin-ideal-image": "3.7.0",
2222
"@docusaurus/preset-classic": "3.7.0",
23+
"@docusaurus/theme-classic": "^3.8.1",
2324
"@docusaurus/theme-mermaid": "3.7.0",
2425
"@docusaurus/theme-search-algolia": "3.7.0",
2526
"@floating-ui/react": "^0.27.8",
@@ -31,6 +32,7 @@
3132
"@tsparticles/react": "^3.0.0",
3233
"@tsparticles/slim": "^3.8.1",
3334
"@vercel/analytics": "^1.5.0",
35+
"canvas-confetti": "^1.9.3",
3436
"class-variance-authority": "^0.7.1",
3537
"clsx": "^2.1.1",
3638
"dotenv": "^16.5.0",
@@ -41,7 +43,7 @@
4143
"framer-motion": "^12.7.5",
4244
"lucide-react": "^0.503.0",
4345
"prism-react-renderer": "^2.3.0",
44-
"react": "^18.0.0",
46+
"react": "^18.3.1",
4547
"react-dom": "^18.0.0",
4648
"react-icons": "^5.5.0",
4749
"react-slot-counter": "^3.3.1",
@@ -57,6 +59,7 @@
5759
"@docusaurus/tsconfig": "3.7.0",
5860
"@docusaurus/types": "3.7.0",
5961
"@tailwindcss/postcss": "^4.1.4",
62+
"@types/canvas-confetti": "^1.9.0",
6063
"autoprefixer": "^10.4.21",
6164
"postcss": "^8.5.3",
6265
"tailwindcss": "^4.1.4",

src/pages/dashboard/giveaway/index.tsx

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import React, { useEffect, useState } from 'react';
22
import Layout from '@theme/Layout';
33
import Head from '@docusaurus/Head';
4+
import type confettiType from 'canvas-confetti';
45

5-
const GiveawayPage = () => {
6+
const GiveawayPage: React.FC = () => {
67
const [timeLeft, setTimeLeft] = useState({
78
days: '--',
89
hours: '--',
910
minutes: '--',
1011
seconds: '--',
1112
});
1213

13-
const countdownTarget = new Date('2025-08-15T23:59:59').getTime(); // Customize this date
14+
const countdownTarget = new Date('2025-08-15T23:59:59').getTime(); // Update the deadline if needed
1415

16+
// Countdown Timer Effect
1517
useEffect(() => {
1618
const interval = setInterval(() => {
1719
const now = new Date().getTime();
@@ -36,14 +38,27 @@ const GiveawayPage = () => {
3638
});
3739
}, 1000);
3840

39-
// Confetti burst
40-
import('canvas-confetti').then(confetti => {
41-
confetti.default({ particleCount: 150, spread: 70, origin: { y: 0.6 } });
42-
});
43-
4441
return () => clearInterval(interval);
4542
}, []);
4643

44+
// Confetti Effect
45+
useEffect(() => {
46+
const runConfetti = async () => {
47+
const module = await import('canvas-confetti');
48+
const confetti = module.default as typeof confettiType;
49+
50+
confetti({
51+
particleCount: 150,
52+
spread: 70,
53+
origin: { y: 0.6 },
54+
});
55+
};
56+
57+
const timer = setTimeout(runConfetti, 1000);
58+
59+
return () => clearTimeout(timer);
60+
}, []);
61+
4762
return (
4863
<Layout>
4964
<Head>
@@ -56,9 +71,9 @@ const GiveawayPage = () => {
5671
<p className="text-lg mb-8">Participate now and win exclusive swag, resources, and more!</p>
5772

5873
<div className="flex justify-center gap-4 text-center mb-12">
59-
{['days', 'hours', 'minutes', 'seconds'].map(unit => (
74+
{['days', 'hours', 'minutes', 'seconds'].map((unit) => (
6075
<div key={unit} className="bg-white/10 px-6 py-4 rounded-xl shadow-md">
61-
<div className="text-3xl font-bold">{timeLeft[unit]}</div>
76+
<div className="text-3xl font-bold">{timeLeft[unit as keyof typeof timeLeft]}</div>
6277
<div className="text-sm uppercase tracking-widest">{unit}</div>
6378
</div>
6479
))}
@@ -75,7 +90,6 @@ const GiveawayPage = () => {
7590
</tr>
7691
</thead>
7792
<tbody>
78-
{/* Replace this static data with dynamic data if needed */}
7993
<tr className="border-b border-white/10">
8094
<td>1</td>
8195
<td>OpenSourcePro</td>
@@ -95,7 +109,7 @@ const GiveawayPage = () => {
95109
</table>
96110
</div>
97111

98-
<p className="text-sm text-white/60 italic">
112+
<p className="text-sm text-white text-opacity-60 italic">
99113
Winners will be announced after the countdown ends. Stay active on the dashboard to climb up the leaderboard!
100114
</p>
101115
</div>

tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"compilerOptions": {
55
"jsx": "react",
66
"baseUrl": ".",
7+
"esModuleInterop": true,
8+
"moduleResolution": "node",
9+
"resolveJsonModule": true
710

811
},
912
"exclude": [".docusaurus", "build"]

0 commit comments

Comments
 (0)