Skip to content

Commit 004fcf7

Browse files
Merge pull request #33 from sliit-foss/feat/add-countdown
Add Countdown
2 parents 438fa36 + 100c59b commit 004fcf7

File tree

10 files changed

+3341
-2310
lines changed

10 files changed

+3341
-2310
lines changed

apps/2024/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"dependencies": {
1111
"@app/utils": "workspace:*",
12+
"@radix-ui/react-separator": "1.1.0",
1213
"lodash": "4.17.21",
1314
"react": "18.2.0",
1415
"react-dom": "18.2.0",
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import * as SeparatorPrimitive from '@radix-ui/react-separator';
2+
import * as React from 'react';
3+
import { twMerge } from 'tailwind-merge';
4+
5+
const Separator = React.forwardRef(({ className, orientation = 'vertical', decorative = true, ...props }, ref) => (
6+
<SeparatorPrimitive.Root
7+
ref={ref}
8+
decorative={decorative}
9+
orientation={orientation}
10+
className={twMerge(
11+
'shrink-0 bg-border',
12+
'bg-black/10',
13+
'mx-4',
14+
'lg:mx-7',
15+
orientation === 'vertical' ? 'h-100px w-[1px] ' : 'h-[1px] w-full',
16+
className
17+
)}
18+
{...props}
19+
/>
20+
));
21+
Separator.displayName = SeparatorPrimitive.Root.displayName;
22+
23+
export { Separator };

apps/2024/src/components/common/typography/body.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { twMerge } from 'tailwind-merge';
33
const BodyText = ({ children, className, ...props }) => {
44
return (
55
<span
6-
className={twMerge('text-[20px] sm:text-[28px] text-center lg:text-start font-consolas', className)}
6+
className={twMerge(
7+
'text-[1.25rem] sm:text-[1.75rem] lg:text-[1.5rem] 2xl:text-[1.75rem] text-center lg:text-start font-consolas',
8+
className
9+
)}
710
{...props}>
811
{children}
912
</span>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Separator } from '@/components/common/separator/index';
2+
import useCountdown from '@/hooks/countdown';
3+
import TimeItem from './time-item';
4+
5+
const CountDown = () => {
6+
const { days, hours, minutes, seconds } = useCountdown({ targetDate: new Date('September 7, 2024 00:00:00') });
7+
8+
return (
9+
<div className="bg-white text-center rounded-[15px] ">
10+
<div className="pt-3 lg:pt-5 font-consolas text-black/70">Registration Ends In...</div>
11+
<div className="flex px-6 lg:px-8 pb-4 lg:pb-5 pt-2 font-inter">
12+
<TimeItem key={'d'} value={days} unit="DD" />
13+
<Separator />
14+
<TimeItem key={'h'} value={hours} unit="HH" />
15+
<Separator />
16+
<TimeItem key={'m'} value={minutes} unit="MM" />
17+
<Separator />
18+
<TimeItem key={'s'} value={seconds} unit="SS" />
19+
</div>
20+
</div>
21+
);
22+
};
23+
24+
export default CountDown;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const TimeItem = ({ value, unit }) => {
2+
return (
3+
<div className="w-14">
4+
<div className="font-bold text-2xl lg:text-4xl">{value}</div>
5+
<div className="font-light text-black text-xs lg:text-sm lg:mt-2">{unit}</div>
6+
</div>
7+
);
8+
};
9+
10+
export default TimeItem;

apps/2024/src/components/landing/hero.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@ import { BodyText, Button } from '@/components/common';
22
import { registrationLink } from '@/constants';
33
import { currentYear, isRegistrationsOpen } from '@/constants/status';
44
import { Bashaway } from '@/icons';
5+
import { CountDown } from '.';
56

67
const Hero = () => {
78
return (
8-
<div className="flex flex-col justify-center items-center gap-y-8 py-4 min-h-[calc(100lvh-70px)]">
9-
<Bashaway className="w-[280px] sm:w-[400px] h-[58px] sm:h-[78px]" />
9+
<div className="flex flex-col justify-center items-center gap-y-5 lg:gap-y-4 2xl:gap-y-8 min-h-[calc(100lvh-160px)] lg:min-h-[calc(100lvh-70px)]">
10+
<Bashaway className="w-[280px] sm:w-[400px] h-[40px] sm:h-[68px] lg:h-[60px] 2xl:h-[70px]" />
1011
<BodyText className="lg:text-center max-w-5xl px-8">
1112
A unique competition that keeps the coders around the island on their toes. Welcome to Bashaway {currentYear},
1213
the third edition of the first-ever scripting and automation competition in Sri Lanka!
1314
</BodyText>
15+
<CountDown />
1416
<Button
1517
to={`${registrationLink}`}
1618
target="_blank"
17-
className="mt-2 sm:text-[22px] px-6 py-2 rounded-full tracking-[0.44px]"
19+
className="mt-1 sm:text-[22px] px-6 py-2 rounded-full tracking-[0.44px] z-30"
1820
disabled={!isRegistrationsOpen}>
1921
{isRegistrationsOpen ? 'Register Now' : 'Registration Closed'}
2022
</Button>

apps/2024/src/components/landing/index.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ export { default as Rules } from './rules';
1111
export { default as Sponsors } from './sponsors';
1212
export { default as Timeline } from './timeline';
1313
export { default as KnowledgePartners } from './knowledge-partners';
14+
export { default as CountDown } from './countdown';

apps/2024/src/hooks/countdown.jsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { useEffect } from 'react';
2+
import { useState } from 'react';
3+
4+
function useCountdown({ targetDate }) {
5+
const countDownDate = targetDate.getTime();
6+
const [remainingTime, setRemainingTime] = useState(countDownDate - new Date().getTime());
7+
8+
useEffect(() => {
9+
const interval = setInterval(() => {
10+
setRemainingTime(countDownDate - new Date().getTime());
11+
}, 1000);
12+
13+
return () => clearInterval(interval);
14+
}, [targetDate]);
15+
16+
const formatTimeUnit = (val) =>
17+
Number(val).toLocaleString('en-US', {
18+
minimumIntegerDigits: 2
19+
});
20+
21+
const extractUnitVals = (remainingTime) => {
22+
const days = formatTimeUnit(Math.floor(remainingTime / (1000 * 60 * 60 * 24)));
23+
const hours = formatTimeUnit(Math.floor((remainingTime % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)));
24+
const minutes = formatTimeUnit(Math.floor((remainingTime % (1000 * 60 * 60)) / (1000 * 60)));
25+
const seconds = formatTimeUnit(Math.floor((remainingTime % (1000 * 60)) / 1000));
26+
27+
return {
28+
days,
29+
hours,
30+
minutes,
31+
seconds,
32+
milliSeconds: remainingTime
33+
};
34+
};
35+
36+
return extractUnitVals(remainingTime);
37+
}
38+
39+
export default useCountdown;

apps/2024/src/pages/landing.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616

1717
const Landing = () => {
1818
return (
19-
<div className="flex flex-col">
19+
<div>
2020
<Hero />
2121
<Marquee />
2222
<Mission />

0 commit comments

Comments
 (0)