Skip to content
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

[Chore] Minor UI improvements #568

Merged
merged 4 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/web/src/components/VaultCard/VaultCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export const VaultCard = ({
const getAuditStatusPill = () => {
if (!vault.description) return null;
if (!vault.description["project-metadata"].endtime) return null;
if (!vault.description["project-metadata"].starttime) return null;

if (auditPayout) {
return (
Expand All @@ -120,6 +121,16 @@ export const VaultCard = ({
}

if (vault.dateStatus === "upcoming") {
const startTime = moment(vault.description["project-metadata"].starttime * 1000);

if (startTime.diff(moment(), "hours") <= 24) {
return (
<div className="mb-4">
<Pill transparent dotColor="yellow" text={`${t("starting")} ${startTime.fromNow()}`} />
</div>
);
}
Comment on lines +124 to +132
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

The code is using moment() to handle date and time. While this isn't necessarily a problem, it's worth noting that Moment.js is now considered a legacy project and is no longer being maintained. It's recommended to use other libraries like Luxon or date-fns for handling dates and times in JavaScript. Here's how you could refactor the code with Luxon:

- const startTime = moment(vault.description["project-metadata"].starttime * 1000);
+ import { DateTime } from 'luxon';
+ const startTime = DateTime.fromMillis(vault.description["project-metadata"].starttime * 1000);

- if (startTime.diff(moment(), "hours") <= 24) {
+ if (DateTime.local().diff(startTime, 'hours').hours <= 24) {


return (
<div className="mb-4">
<Pill transparent dotColor="yellow" text={t("upcoming")} />
Expand All @@ -132,7 +143,7 @@ export const VaultCard = ({
if (endTime.diff(moment(), "hours") <= 24) {
return (
<div className="mb-4">
<Pill transparent dotColor="yellow" text={`${t("endingSoon")} ${endTime.fromNow()}`} />
<Pill transparent dotColor="yellow" text={`${t("ending")} ${endTime.fromNow()}`} />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

Similar to the previous comment, consider replacing Moment.js with another library like Luxon or date-fns.

- <Pill transparent dotColor="yellow" text={`${t("ending")} ${endTime.fromNow()}`} />
+ import { DateTime } from 'luxon';
+ const endTime = DateTime.fromMillis(vault.description["project-metadata"].endtime * 1000);
+ <Pill transparent dotColor="yellow" text={`${t("ending")} ${endTime.toRelative()}`} />

</div>
);
} else {
Expand Down
3 changes: 3 additions & 0 deletions packages/web/src/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,9 @@
"finishedCompetitions": "Finished competitions",
"liveNow": "Live now",
"endingSoon": "Ending soon",
"startingSoon": "Starting soon",
"ending": "Ending",
"starting": "Starting",
"paidCompetition": "Paid competition",
"paidAssets": "Paid assets",
"paid": "Paid",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export const InScopeSection = ({ vault }: InScopeSectionProps) => {
{/* Documentation */}
{docsLink && (
<>
<h4 className="section-subtitle">
<h4 className="section-subtitle mt-4">
<DocumentIcon className="icon" />
<span>{t("documentation")}</span>
</h4>
Expand Down
7 changes: 7 additions & 0 deletions packages/web/src/styles/global.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,11 @@ export const GlobalStyle = createGlobalStyle`
}
}
}

// Markdown styles
.wmde-markdown {
pre > code {
background: var(--markdown-code-backgroud);
}
}
`;
1 change: 1 addition & 0 deletions packages/web/src/styles/variables.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const variables = css`
--background-3: #242541;
--background-4: #3b3e6d;
--disabled-input: #070a14;
--markdown-code-backgroud: rgba(110, 118, 129, 0.4);

--white: #ffffff;
--error-red: #ff6464;
Expand Down