-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from anushkaj-01/main
Add complete timer and navbar section. Add react-router-dom as dependency.
- Loading branch information
Showing
16 changed files
with
265 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React from 'react'; | ||
import {UseCountdown} from '/src/hooks/UseCountdown.jsx'; | ||
import '/src/index.css'; | ||
const ExpiredNotice = () => { | ||
return ( | ||
<div className="expired-notice"> | ||
<span>Expired!!!</span> | ||
<p>Please select a future date and time.</p> | ||
</div> | ||
); | ||
}; | ||
const DateTimeDisplay = ({ value, type, isDanger }) => { | ||
return ( | ||
<div className='countdown flex flex-col items-center font-vt323 font-[400] text-[#D9D9D9] '> | ||
<div className='mr-[10px] '> | ||
<p className='text-[60px] h-[4rem] ' >{type !== 'Days' && <span className="text-[60px] ml-[1rem]">:</span>} {value.toString()}</p> | ||
</div> | ||
{type == 'Days' && <span className="text-[25px] ml-[0.5rem]">{type}</span>} | ||
{type == 'Hours' && <span className="text-[25px] ml-[2.9rem]">{type}</span>} | ||
{type == 'Minutes' && <span className="text-[25px] ml-[3rem]">{type}</span>} | ||
{type == 'Minutes' || type=='Seconds' && <span className="text-[25px] ml-[3rem]">{type}</span>} | ||
{/* <span className='text-[25px] ml-[1.5rem]'>{type}</span> */} | ||
|
||
</div> | ||
); | ||
}; | ||
const ShowCounter = ({ days, hours, minutes, seconds }) => { | ||
return ( | ||
<div className="show-counter flex items-center"> | ||
|
||
<DateTimeDisplay value={days} type={'Days'} isDanger={days <= 3} /> | ||
|
||
<DateTimeDisplay value={hours} type={'Hours'} isDanger={false} /> | ||
|
||
<DateTimeDisplay value={minutes} type={'Minutes'} isDanger={false} /> | ||
|
||
<DateTimeDisplay value={seconds} type={'Seconds'} isDanger={false} /> | ||
|
||
</div> | ||
); | ||
}; | ||
|
||
const CountdownTimer = ({ targetDate }) => { | ||
|
||
const [days, hours, minutes, seconds] = UseCountdown(targetDate); | ||
|
||
if (days + hours + minutes + seconds <= 0) { | ||
return <ExpiredNotice />; | ||
} else { | ||
return ( | ||
<section className='flex justify-center'> | ||
<ShowCounter | ||
days={days} | ||
hours={hours} | ||
minutes={minutes} | ||
seconds={seconds} | ||
/> | ||
</section> | ||
); | ||
} | ||
}; | ||
export default CountdownTimer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
export default function Navbar(){ | ||
const scrollToSchedule = () => { | ||
const scheduleSection = document.getElementById('schedule'); | ||
if (scheduleSection) { | ||
scheduleSection.scrollIntoView({ behavior: 'smooth' }); | ||
} | ||
}; | ||
const scrollToFooter = () => { | ||
const footerSection = document.getElementById('footer'); | ||
if (footerSection) { | ||
footerSection.scrollIntoView({ behavior: 'smooth' }); | ||
} | ||
}; | ||
return( | ||
<> | ||
<nav className="flex bg-gradient-to-b from-[#040842] to-[#040842] justify-between w-[100vw] h-[100px] mt-0 bg-blue-800 font-vt323"> | ||
<img className="ml-[2%] pt-[1%]" src="./public/images/logo.svg"></img> | ||
|
||
<ul className="flex space-x-[3rem] text-[2rem] text-white items-center"> | ||
<a onClick={scrollToSchedule} style={{ cursor: 'pointer' }}><li>SCHEDULE</li></a> | ||
<li style={{ cursor: 'pointer' }}>TRACKS</li> | ||
<li style={{ cursor: 'pointer' }}>PRIZES</li> | ||
<a onClick={scrollToFooter} style={{ cursor: 'pointer' }}><li>MORE</li></a> | ||
</ul> | ||
<img className="mr-[3%] pt-[1%]" src="./public/images/IIITlogo.svg"></img> | ||
|
||
</nav> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { useEffect, useState } from 'react'; | ||
|
||
const UseCountdown = (targetDate) => { | ||
// targetDate = "aug 24, 2024 02:0:00"; | ||
const countDownDate = new Date(targetDate).getTime(); | ||
|
||
const [countDown, setCountDown] = useState( | ||
countDownDate - new Date().getTime() | ||
); | ||
|
||
useEffect(() => { | ||
const interval = setInterval(() => { | ||
setCountDown(countDownDate - new Date().getTime()); | ||
}, 1000); | ||
|
||
return () => clearInterval(interval); | ||
}, [countDownDate]); | ||
|
||
return getReturnValues(countDown); | ||
}; | ||
|
||
const getReturnValues = (countDown) => { | ||
// calculate time left | ||
const days = Math.floor(countDown / (1000 * 60 * 60 * 24)); | ||
const hours = Math.floor( | ||
(countDown % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60) | ||
); | ||
const minutes = Math.floor((countDown % (1000 * 60 * 60)) / (1000 * 60)); | ||
const seconds = Math.floor((countDown % (1000 * 60)) / 1000); | ||
|
||
return [days, hours, minutes, seconds]; | ||
}; | ||
|
||
export {UseCountdown}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import CountdownTimer from "../components/CountdownTimer" | ||
export default function TimerSection(){ | ||
return( | ||
<> | ||
<section className="width-[100vh] flex flex-col justify-center font-[vt323]"> | ||
<p className="text-[#F21212] text-[60px] mb-0">Hurry Up</p> | ||
<p className="text-[36px] text-[#9D44C0]">Hacking ends in</p> | ||
<CountdownTimer targetDate={"aug 24, 2024 02:01:00"}/> | ||
</section> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters