Skip to content

Commit

Permalink
Countdown done
Browse files Browse the repository at this point in the history
  • Loading branch information
himanibhammar committed Oct 4, 2024
1 parent 093211f commit b3b3d1e
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 4 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
"prepare": "husky"
},
"dependencies": {
"@fontsource/inter": "^5.1.0",
"autoprefixer": "^10.4.20",
"husky": "^9.0.11",
"lint-staged": "^15.2.7",
"next": "14.2.4",
"postcss": "^8.4.47",
"react": "^18",
"react-countdown": "^2.3.6",
"react-dom": "^18",
"tailwindcss": "^3.4.13"
},
Expand Down
9 changes: 9 additions & 0 deletions public/audience.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions src/pages/Hurryup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
'use client'
import React, { useState, useEffect } from 'react';
import Countdown from 'react-countdown';

const targetDate = new Date('2024-10-17T00:00:00').getTime();

export default function HurryUp() {
const [isMounted, setIsMounted] = useState(false);

// Ensure the component only renders after mounting on the client
useEffect(() => {
setIsMounted(true);
}, []);

return (
<div className="bg-[url('/audience.svg')] bg-cover bg-center bg-no-repeat backdrop:blur-md h-screen w-full">
<div className="relative flex flex-col items-center justify-center h-screen">
<h1 className=" w-[1127px] h-[105px] text-[48px] leading-[58.09px] font-bold text-center text-white mb-2 -mt-10 ">
Hurry Up!
</h1>

{isMounted ? (
<Countdown
date={targetDate}
renderer={({ days, hours, minutes, seconds }) => {
// Calculate weeks and remaining days
const weeks = Math.floor(days / 7);

return (
<div className="grid grid-cols-5 gap-14 text-center bg-transparent">
<div className="flex flex-col items-center" aria-label="Weeks left">
<div className="mb-2 flex h-[140px] w-[140px] flex-col items-center justify-center rounded-lg bg-amber-500 p-2 shadow-lg">
<span className=" text-[76px] w-[170px] h-[105px] font-bold text-white leading-[91.98px] ">{weeks}</span>
</div>
<span className="text-sm font-semibold uppercase text-white drop-shadow-md">weeks</span>
</div>
<div className="flex flex-col items-center" aria-label="Days left">
<div className="mb-2 flex h-[140px] w-[140px] flex-col items-center justify-center rounded-lg bg-amber-500 p-2 shadow-lg">
<span className=" text-[76px] w-[170px] h-[105px] font-bold text-white leading-[91.98px]">{days}</span>
</div>
<span className="text-sm font-semibold uppercase text-white drop-shadow-md">days</span>
</div>
<div className="flex flex-col items-center" aria-label="Hours left">
<div className="mb-2 flex h-[140px] w-[140px] flex-col items-center justify-center rounded-lg bg-amber-500 p-2 shadow-lg">
<span className=" text-[76px] w-[170px] h-[105px] font-bold text-white leading-[91.98px]">{hours}</span>
</div>
<span className="text-sm font-semibold uppercase text-white drop-shadow-md">Hours</span>
</div>
<div className="flex flex-col items-center" aria-label="Minutes left">
<div className="mb-2 flex h-[140px] w-[140px] flex-col items-center justify-center rounded-lg bg-amber-500 p-2 shadow-lg">
<span className=" text-[76px] w-[170px] h-[105px] font-bold text-white leading-[91.98px]">{minutes}</span>
</div>
<span className="text-sm font-semibold uppercase text-white drop-shadow-md">Minutes</span>
</div>
<div className="flex flex-col items-center" aria-label="Seconds left">
<div className="mb-2 flex h-[140px] w-[140px] flex-col items-center justify-center rounded-lg bg-amber-500 p-2 shadow-lg">
<span className=" text-[76px] w-[170px] h-[105px] font-bold text-white leading-[91.98px]">{seconds}</span>
</div>
<span className="text-sm font-semibold uppercase text-white drop-shadow-md">Seconds</span>
</div>
</div>
);
}}
/>
) : (
<div>Loading...</div> // Placeholder to avoid hydration errors
)}
</div>
</div>
);
}
1 change: 1 addition & 0 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "@/styles/globals.css";
import '@fontsource/inter/400.css';
import type { AppProps } from "next/app";

export default function App({ Component, pageProps }: AppProps) {
Expand Down
8 changes: 5 additions & 3 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import Sidebar from "@/components";

import HurryUp from "./Hurryup";

export default function Home() {
return (
<>
<div className="text-3xl text-red-400">Hello World</div>
<Sidebar />

<HurryUp/>

</>
);
}
14 changes: 13 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.57.0.tgz#a5417ae8427873f1dd08b70b3574b453e67b5f7f"
integrity sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==

"@fontsource/inter@^5.1.0":
version "5.1.0"
resolved "https://registry.yarnpkg.com/@fontsource/inter/-/inter-5.1.0.tgz#ab629b2c662457022d2d6a29854b8dc8ba538c47"
integrity sha512-zKZR3kf1G0noIes1frLfOHP5EXVVm0M7sV/l9f/AaYf+M/DId35FO4LkigWjqWYjTJZGgplhdv4cB+ssvCqr5A==

"@humanwhocodes/config-array@^0.11.14":
version "0.11.14"
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.14.tgz#d78e481a039f7566ecc9660b4ea7fe6b1fec442b"
Expand Down Expand Up @@ -2591,7 +2596,7 @@ pretty-format@^29.7.0:
ansi-styles "^5.0.0"
react-is "^18.0.0"

prop-types@^15.8.1:
prop-types@^15.7.2, prop-types@^15.8.1:
version "15.8.1"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
Expand All @@ -2610,6 +2615,13 @@ queue-microtask@^1.2.2:
resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243"
integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==

react-countdown@^2.3.6:
version "2.3.6"
resolved "https://registry.yarnpkg.com/react-countdown/-/react-countdown-2.3.6.tgz#26699ea87e548bd7c981281e5a8fd8b511f774ff"
integrity sha512-ZfX6S08Hb6x6W6eCn1hMDvxPICI/T30fd+gaeVTCR/2cGZ2WJ3f26e4ImNIMX1fHkopJrUdnRpWXP13/D39+gg==
dependencies:
prop-types "^15.7.2"

react-dom@^18:
version "18.3.1"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.3.1.tgz#c2265d79511b57d479b3dd3fdfa51536494c5cb4"
Expand Down

0 comments on commit b3b3d1e

Please sign in to comment.