-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8e71c7
commit 67da2a9
Showing
4 changed files
with
48 additions
and
41 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
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
40 changes: 40 additions & 0 deletions
40
packages/grant-explorer/src/features/discovery/RoundDaysLeft.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,40 @@ | ||
import tw from "tailwind-styled-components"; | ||
|
||
export const RoundDaysLeft = ({ | ||
daysLeft = 0, | ||
daysLeftToApply = 0, | ||
isValidRoundEndTime = true, | ||
}) => { | ||
const days = pluralize(["day", "days"]); | ||
return ( | ||
<div className="flex-1"> | ||
{daysLeftToApply > 0 && ( | ||
<DaysLeft data-testid="apply-days-left"> | ||
{daysLeftToApply} {days(daysLeftToApply)} left to apply | ||
</DaysLeft> | ||
)} | ||
<DaysLeft data-testid="days-left"> | ||
{isValidRoundEndTime ? ( | ||
<span> | ||
{daysLeft} {days(daysLeft)} left in round | ||
</span> | ||
) : ( | ||
<span>No end time</span> | ||
)} | ||
</DaysLeft> | ||
</div> | ||
); | ||
}; | ||
|
||
const DaysLeft = tw.div` | ||
text-xs | ||
w-full | ||
font-mono | ||
whitespace-nowrap | ||
`; | ||
|
||
// If we need something more advanced or to use in another place in codebase, we can pull in a library | ||
const pluralize = | ||
([singular = "", plural = ""]) => | ||
(num = 0) => | ||
num ? (num === 1 ? singular : plural) : ""; |