diff --git a/bun.lockb b/bun.lockb index 5541d0f..4476cd5 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 067779f..ec1cee4 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "axios-case-converter": "^1.1.1", "cookies-next": "^5.0.2", "feed": "^4.2.2", - "next": "^15.1.4", + "next": "^15.1.5", "next-nprogress-bar": "^2.4.3", "react": "^19.0.0", "react-dom": "^19.0.0", @@ -43,15 +43,16 @@ "zustand": "^5.0.3" }, "devDependencies": { - "typescript": "^5.7.3", + "@eslint/eslintrc": "^3.2.0", "@types/node": "^20.17.12", "@types/react": "^19.0.4", "@types/react-dom": "^19.0.2", - "postcss": "^8.4.49", - "tailwindcss": "^3.4.17", + "daisyui": "^4.12.23", "eslint": "^9.18.0", "eslint-config-next": "15.1.3", - "@eslint/eslintrc": "^3.2.0" + "postcss": "^8.4.49", + "tailwindcss": "^3.4.17", + "typescript": "^5.7.3" }, "trustedDependencies": [ "@vercel/speed-insights", diff --git a/src/components/events/CountdownTimer.tsx b/src/components/events/CountdownTimer.tsx new file mode 100644 index 0000000..c386943 --- /dev/null +++ b/src/components/events/CountdownTimer.tsx @@ -0,0 +1,76 @@ +import { Noto_Serif_TC } from 'next/font/google' +import { useState, useEffect } from 'react' + +export interface TimeDiff { + days: number + hours: number + minutes: number + seconds: number + isCountdown: boolean +} + +const serifFont = Noto_Serif_TC({ + weight: ['400', '500', '700'], + display: 'swap', +}) + +export function CountdownTimer({ targetDate, onUpdate }: { targetDate: Date; onUpdate: (diff: TimeDiff) => void }) { + const [timeDiff, setTimeDiff] = useState({ + days: 0, + hours: 0, + minutes: 0, + seconds: 0, + isCountdown: true, + }) + + useEffect(() => { + const updateTimeDiff = () => { + const now = new Date() + const diff = targetDate.getTime() - now.getTime() + + const absDiff = Math.abs(diff) + const isCountdown = diff > 0 + + const days = Math.floor(absDiff / (1000 * 60 * 60 * 24)) + const hours = Math.floor((absDiff / (1000 * 60 * 60)) % 24) + const minutes = Math.floor((absDiff / (1000 * 60)) % 60) + const seconds = Math.floor((absDiff / 1000) % 60) + + setTimeDiff({ days, hours, minutes, seconds, isCountdown }) + onUpdate({ days, hours, minutes, seconds, isCountdown }) + } + + const intervalId = setInterval(updateTimeDiff, 1000) + + return () => clearInterval(intervalId) + }, []) + + return ( +