feat: add bounty countdown timer#1341
Open
TUPM96 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Introduces shared frontend utilities and motion variants, and replaces static deadline labels with a live-updating countdown component for bounties.
Changes:
- Added
BountyCountdowncomponent (with urgency styling) and unit/UI tests. - Introduced shared
utils.ts(time/currency formatting + language colors) and reusableframer-motionvariants. - Updated bounty card/detail views and
.gitignoreto use/track the new shared lib directory.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/lib/utils.ts | Adds shared formatting helpers and LANG_COLORS used by bounty UI. |
| frontend/src/lib/animations.ts | Adds reusable Framer Motion variants for consistent animations. |
| frontend/src/components/bounty/BountyDetail.tsx | Swaps static deadline display for BountyCountdown. |
| frontend/src/components/bounty/BountyCountdown.tsx | New live-updating countdown with urgency states + styles. |
| frontend/src/components/bounty/BountyCard.tsx | Uses BountyCountdown in the card metadata row. |
| frontend/src/tests/bounty-countdown.test.tsx | Adds tests for countdown state formatting and live updates. |
| .gitignore | Un-ignores frontend/src/lib so the new shared modules are committed. |
Comment on lines
+80
to
+82
| setNow(Date.now()); | ||
| const interval = window.setInterval(() => setNow(Date.now()), 1000); | ||
| return () => window.clearInterval(interval); |
Comment on lines
+80
to
+89
| setNow(Date.now()); | ||
| const interval = window.setInterval(() => setNow(Date.now()), 1000); | ||
| return () => window.clearInterval(interval); | ||
| }, [deadline]); | ||
|
|
||
| const countdown = getCountdownState(deadline, now); | ||
|
|
||
| return ( | ||
| <span | ||
| aria-live="polite" |
Comment on lines
+13
to
+23
| export function getCountdownState(deadline: string, now = Date.now()): CountdownState { | ||
| const deadlineTime = new Date(deadline).getTime(); | ||
|
|
||
| if (Number.isNaN(deadlineTime)) { | ||
| return { | ||
| urgency: 'expired', | ||
| label: 'Expired', | ||
| isExpired: true, | ||
| totalMinutes: 0, | ||
| }; | ||
| } |
Comment on lines
+50
to
+67
| export function timeLeft(deadline?: string | null): string { | ||
| if (!deadline) return 'No deadline'; | ||
|
|
||
| const date = new Date(deadline); | ||
| if (Number.isNaN(date.getTime())) return 'Invalid deadline'; | ||
|
|
||
| const deltaMs = date.getTime() - Date.now(); | ||
| if (deltaMs <= 0) return 'Expired'; | ||
|
|
||
| const totalMinutes = Math.floor(deltaMs / 60000); | ||
| const days = Math.floor(totalMinutes / (24 * 60)); | ||
| const hours = Math.floor((totalMinutes % (24 * 60)) / 60); | ||
| const minutes = totalMinutes % 60; | ||
|
|
||
| if (days > 0) return `${days}d ${hours}h left`; | ||
| if (hours > 0) return `${hours}h ${minutes}m left`; | ||
| return `${Math.max(minutes, 1)}m left`; | ||
| } |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #826
Summary
Verification
Wallet