-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup animated countdown on schedule page (#93)
* setup: basic framer countdown * fix: removed useRef, changed animation exit value * update: temporarily disabled slide up animation * fix: conditional day render * fix: precompute time * fix: margin for the countdown * update: added loading bar * fix: rename to Loader * feat: time until hacking countdown timer * fix: clipboard styling --------- Co-authored-by: Tyler Yu <tyleryy@uci.edu> Co-authored-by: Alexander Liu <a@alexanderliu.com>
- Loading branch information
1 parent
7b9b9df
commit 56117a2
Showing
7 changed files
with
105 additions
and
4 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
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
38 changes: 38 additions & 0 deletions
38
apps/site/src/views/Schedule/components/Countdown/Countdown.module.scss
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,38 @@ | ||
@use "bootstrap-utils" as bootstrap; | ||
|
||
.countdown { | ||
margin: 0; | ||
padding: 96px 0 32px 0; | ||
opacity: 0; | ||
transition: opacity 225ms cubic-bezier(0.32, 0, 0.67, 0); | ||
|
||
span { | ||
text-align: center; | ||
font-weight: 600; | ||
|
||
&.time { | ||
display: block; | ||
@include bootstrap.font-size(6rem); | ||
line-height: 100%; | ||
|
||
.number { | ||
display: inline-block; | ||
text-align: center; | ||
width: 2ch; | ||
} | ||
|
||
.colon { | ||
opacity: 0.75; | ||
} | ||
} | ||
|
||
&.caption { | ||
display: block; | ||
@include bootstrap.font-size(1.5rem); | ||
} | ||
} | ||
} | ||
|
||
.loaded { | ||
opacity: 1; | ||
} |
53 changes: 53 additions & 0 deletions
53
apps/site/src/views/Schedule/components/Countdown/Countdown.tsx
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,53 @@ | ||
"use client"; | ||
|
||
import { useEffect, useState } from "react"; | ||
|
||
import clsx from "clsx"; | ||
import styles from "./Countdown.module.scss"; | ||
|
||
// 10/4/23 10AM in UTC | ||
const hackingStarts = new Date(Date.UTC(2023, 10, 4, 17, 0, 0)); | ||
|
||
export default function Countdown() { | ||
const [remainingSeconds, setRemainingSeconds] = useState<number>(NaN); | ||
|
||
useEffect(() => { | ||
setRemainingSeconds( | ||
(hackingStarts.valueOf() - new Date().valueOf()) / 1000, | ||
); | ||
const interval = setInterval(() => { | ||
setRemainingSeconds((r) => r - 1); | ||
}, 1000); | ||
|
||
return () => clearInterval(interval); | ||
}, []); | ||
|
||
return ( | ||
<div | ||
className={clsx( | ||
styles.countdown, | ||
!isNaN(remainingSeconds) && styles.loaded, | ||
)} | ||
> | ||
<span className={styles.time}> | ||
<span className={styles.number}> | ||
{Math.floor(remainingSeconds / (60 * 60))} | ||
</span> | ||
<span className={styles.colon}>:</span> | ||
<span className={styles.number}> | ||
{Math.floor((remainingSeconds / 60) % 60) | ||
.toString() | ||
.padStart(2, "0")} | ||
</span> | ||
|
||
<span className={styles.colon}>:</span> | ||
<span className={styles.number}> | ||
{Math.floor(remainingSeconds % 60) | ||
.toString() | ||
.padStart(2, "0")} | ||
</span> | ||
</span> | ||
<span className={styles.caption}>Until Hacking Begins</span> | ||
</div> | ||
); | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.