11import React , { useEffect , useState } from 'react' ;
22import Layout from '@theme/Layout' ;
33import 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 >
0 commit comments