-
Notifications
You must be signed in to change notification settings - Fork 3
Toby/countdown #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Toby/countdown #28
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1d653a3
add banner to hero page
spagechi fe8b2ee
add back navbar and footer gap changes
spagechi 854e231
improve responsiveness of hero section and change countdown image
spagechi 1d006a2
add countdown
spagechi 75b1502
update fall application due date and adjust countdown position
spagechi 27761fb
update fall app deadline again
spagechi ed96873
make digits fixed size
spagechi 5508abe
update colon logic so empty span doesn't appear after seconds
spagechi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,66 @@ | ||
| "use client"; | ||
|
|
||
| import { useState, useEffect } from "react"; | ||
| import styles from "./style.module.scss"; | ||
|
|
||
| type CountdownProps = { | ||
| className?: string; | ||
| }; | ||
|
|
||
| const Countdown = ({ className = "" }: CountdownProps) => { | ||
| const [days, setDays] = useState(0); | ||
| const [hours, setHours] = useState(0); | ||
| const [minutes, setMinutes] = useState(0); | ||
| const [seconds, setSeconds] = useState(0); | ||
| let countdownComponents : number[] = [days, hours, minutes, seconds]; | ||
|
|
||
| useEffect(() => { | ||
| const target = new Date("10/02/2026 23:59:59"); | ||
|
|
||
| const interval = setInterval(() => { | ||
| const now = new Date(); | ||
| const difference = target.getTime() - now.getTime(); | ||
|
|
||
| if (difference <= 0) { | ||
| setDays(0); | ||
| setHours(0); | ||
| setMinutes(0); | ||
| setSeconds(0); | ||
| countdownComponents = [days, hours, minutes, seconds]; | ||
| clearInterval(interval); | ||
| } else { | ||
| setDays(Math.floor(difference / (1000 * 60 * 60 * 24))); | ||
| setHours( | ||
| Math.floor( | ||
| (difference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60) | ||
| ) | ||
| ); | ||
| setMinutes( | ||
| Math.floor((difference % (1000 * 60 * 60)) / (1000 * 60)) | ||
| ); | ||
| setSeconds(Math.floor((difference % (1000 * 60)) / 1000)); | ||
| countdownComponents = [days, hours, minutes, seconds]; | ||
| } | ||
| }, 1000); | ||
|
|
||
| return () => clearInterval(interval); | ||
| }, []); | ||
|
|
||
| return ( | ||
| <div className={`${styles.date} ${className}`}> | ||
| {countdownComponents.map((comp, key) => { | ||
| const digits = String(comp).padStart(2, '0').split(''); | ||
|
|
||
| return ( | ||
| <span key={key}> | ||
| <span className={styles.digit}>{digits[0]}</span> | ||
| <span className={styles.digit}>{digits[1]}</span> | ||
| {key < 3 ? <span>:</span> : null} | ||
| </span> | ||
| ); | ||
| })} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default Countdown; | ||
This file contains hidden or 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,13 @@ | ||
| @use "../../styles/vars.scss" as v; // allows you to use pre-defined colors | ||
|
|
||
| .date { | ||
| color: black; | ||
| font-size: 1.25rem; | ||
| font-weight: 700; | ||
|
|
||
| .digit { | ||
| display: inline-block; | ||
| width: 1ch; | ||
| text-align: center; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it's necessary to have hours, seconds, and minutes all be different states; can you think of any other ways we can accomplish this?