-
Notifications
You must be signed in to change notification settings - Fork 95
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 #129 from starknet-id/feat/add_timer
feat: add timer
- Loading branch information
Showing
8 changed files
with
247 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React, { FunctionComponent, useEffect, useState } from "react"; | ||
import styles from "../../styles/components/timer.module.css"; | ||
|
||
type TimerProps = { | ||
expiry: number; | ||
fixed?: boolean; | ||
}; | ||
|
||
const Timer: FunctionComponent<TimerProps> = ({ expiry, fixed = true }) => { | ||
const [timeLeft, setTimeLeft] = useState(expiry - Date.now()); | ||
|
||
useEffect(() => { | ||
const intervalId = setInterval(() => { | ||
setTimeLeft(expiry - Date.now()); | ||
}, 1000); | ||
|
||
return () => clearInterval(intervalId); | ||
}, [expiry]); | ||
|
||
const days = Math.floor(timeLeft / (1000 * 60 * 60 * 24)); | ||
const hours = Math.floor( | ||
(timeLeft % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60) | ||
); | ||
const minutes = Math.floor((timeLeft % (1000 * 60 * 60)) / (1000 * 60)); | ||
const seconds = Math.floor((timeLeft % (1000 * 60)) / 1000); | ||
|
||
return ( | ||
<> | ||
{fixed ? <div className={styles.timerBackground} /> : null} | ||
<div className={`${fixed ? `${styles.timerFixed}` : `${styles.timer}`}`}> | ||
<div className={styles.title}>Expires in</div> | ||
<div className={styles.categories}> | ||
<div>days</div> | ||
<div>hours</div> | ||
<div>minutes</div> | ||
<div>seconds</div> | ||
</div> | ||
<div className={styles.dates}> | ||
<div> | ||
<span className={styles.day}>{days}</span>: | ||
</div> | ||
<div> | ||
<span className={styles.hour}>{hours}</span>: | ||
</div> | ||
<div> | ||
<span className={styles.minute}>{minutes}</span>: | ||
</div> | ||
<div className={styles.second}>{seconds}</div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default Timer; |
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
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,154 @@ | ||
.timerFixed { | ||
position: absolute; | ||
right: 24px; | ||
bottom: 24px; | ||
display: flex; | ||
padding: 8px 12px; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
gap: 8px; | ||
border-radius: 8px; | ||
background: linear-gradient(90deg, var(--background), #070708); | ||
box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25); | ||
width: 298px; | ||
height: 84px; | ||
z-index: 0; | ||
} | ||
|
||
.timer { | ||
position: relative; | ||
display: flex; | ||
padding: 8px 12px; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
gap: 8px; | ||
border-radius: 8px; | ||
background: linear-gradient(90deg, var(--background), #070708); | ||
box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25); | ||
width: 298px; | ||
height: 84px; | ||
margin: 48px auto; | ||
} | ||
|
||
.timer::after { | ||
content: ""; | ||
position: absolute; | ||
top: -10px; | ||
right: -10px; | ||
left: 0; | ||
bottom: 0; | ||
background: linear-gradient(5deg, var(--background) 70%, transparent); | ||
border-radius: 8px; | ||
z-index: -1; | ||
} | ||
|
||
.timer::before { | ||
content: ""; | ||
position: absolute; | ||
top: -1px; | ||
right: -1px; | ||
left: 1px; | ||
bottom: 1px; | ||
background: linear-gradient( | ||
90deg, | ||
#437aba 0%, | ||
#59c2e8 45%, | ||
#00ff77 60%, | ||
#59c2e8 70%, | ||
#437aba50 100% | ||
); | ||
border-radius: 8px; | ||
z-index: -1; | ||
} | ||
|
||
.timerBackground { | ||
position: absolute; | ||
right: 23px; | ||
bottom: 25px; | ||
border-radius: 8px; | ||
background: linear-gradient( | ||
90deg, | ||
#437aba 0%, | ||
#59c2e8 45%, | ||
#00ff77 60%, | ||
#59c2e8 70%, | ||
#437aba50 100% | ||
); | ||
width: 270px; | ||
height: 84px; | ||
mask: linear-gradient(3deg, transparent 80%, black); | ||
} | ||
|
||
.title { | ||
text-align: center; | ||
font-family: Sora; | ||
font-size: 14px; | ||
font-style: normal; | ||
font-weight: 700; | ||
line-height: 20px; | ||
background: var(--primary-gradient, linear-gradient(90deg, #6AFFAF 0%, #5CE3FE 100%)); | ||
background-clip: text; | ||
-webkit-background-clip: text; | ||
-webkit-text-fill-color: transparent; | ||
} | ||
|
||
.categories { | ||
display: flex; | ||
flex-direction: row; | ||
color: var(--secondary); | ||
text-align: center; | ||
font-family: Sora; | ||
font-size: 12px; | ||
font-style: normal; | ||
font-weight: 400; | ||
line-height: 16px; | ||
width: 296px; | ||
padding: 0 12px; | ||
} | ||
|
||
.categories > div { | ||
margin-right: 36px; | ||
width: 68px; | ||
text-align: left; | ||
} | ||
|
||
.dates { | ||
display: flex; | ||
flex-direction: row; | ||
color: var(--secondary); | ||
text-align: right; | ||
font-family: Sora; | ||
font-size: 16px; | ||
font-style: normal; | ||
font-weight: 700; | ||
line-height: 20px; | ||
letter-spacing: 0.16px; | ||
} | ||
|
||
.dates > div { | ||
width: 65px; | ||
text-align: left; | ||
} | ||
|
||
.space { | ||
padding: 0 13px; | ||
} | ||
|
||
.day { | ||
padding: 0 15px 0 12px; | ||
} | ||
|
||
.hour { | ||
padding: 0 15px 0 12px; | ||
} | ||
|
||
.minute { | ||
padding: 0 15px 0 27px; | ||
|
||
} | ||
|
||
.second { | ||
text-align: right !important; | ||
} |
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 |
---|---|---|
|
@@ -229,6 +229,7 @@ | |
align-items: center; | ||
padding: 0.4rem; | ||
gap: 0.5rem; | ||
position: relative; | ||
} | ||
|
||
.featuredQuestInfos { | ||
|
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
8801a00
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.
Successfully deployed to the following URLs:
goerli-starknet-quest – ./
goerli-starknet-quest.vercel.app
goerli-starknet-quest-starknetid.vercel.app
goerli-starknet-quest-git-testnet-starknetid.vercel.app
goerli.starknet.quest