Countdown.tsx37 lines · main
1import Countdown from 'react-countdown'
2
3import { CountdownWidget } from '../CountdownWidget'
4
5const CountdownComponent = ({
6 date,
7 showCard = true,
8}: {
9 date: string | number | Date
10 showCard?: boolean
11}) => {
12 if (!date) return null
13
14 const renderer = ({ days, hours, minutes, seconds, completed }: any) => {
15 if (completed) {
16 // Render a completed state
17 return null
18 } else {
19 // Render countdown
20 return (
21 <CountdownWidget
22 days={days}
23 hours={hours}
24 minutes={minutes}
25 seconds={seconds}
26 showCard={showCard}
27 className="text-emerald-400 [text-shadow:0_0_15px_rgba(52,211,153,0.8)]"
28 dividerClassName="text-emerald-400 [text-shadow:0_0_15px_rgba(52,211,153,0.8)]"
29 />
30 )
31 }
32 }
33
34 return <Countdown date={new Date(date)} renderer={renderer} />
35}
36
37export default CountdownComponent