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

[Chore] Minor UI improvements #568

merged 4 commits into from
Oct 5, 2023

Conversation

fonstack
Copy link
Member

@fonstack fonstack commented Oct 5, 2023

Summary by CodeRabbit

  • New Feature: Added a condition to check and display the startTime of the vault in the UI if it is within 24 hours from the current time, enhancing user awareness about upcoming events.
  • Style: Improved the visual layout by adding a top margin to the section subtitle on the Vault Details Page for better content separation and readability.
  • Style: Introduced new styling for markdown code blocks with a distinct background color, improving the readability of code snippets in the application.

@fonstack fonstack requested a review from shayzluf October 5, 2023 13:54
@github-actions
Copy link

github-actions bot commented Oct 5, 2023

Image description CodeRabbit

Walkthrough

This update introduces a new condition to handle the absence of starttime in the vault description, improves UI by adding top margin to a section subtitle, and enhances markdown code block styling with a new CSS rule and variable.

Changes

File(s) Summary
VaultCard.tsx Added a condition to check if starttime exists in the vault.description["project-metadata"] object. If it does and is within 24 hours from the current time, a new UI element is rendered using the Pill component.
InScopeSection.tsx Improved UI by adding the mt-4 class to the <h4> element's className attribute, introducing a top margin of 4 units to the section subtitle.
global.styles.ts, variables.styles.ts Introduced a new CSS rule and variable for styling markdown code blocks. The new CSS variable --markdown-code-backgroud sets the background color for markdown code blocks.

"With each commit we make, our code takes shape 🐇💻

Like a painter with his brush, or a baker with her cake 🎨🍰

From the vault's metadata, to the margins on the page 📝🖥️

To the colors of our code blocks, every detail we engage 🌈🔍"


Uplevel your code reviews with CodeRabbit Pro

CodeRabbit Pro

If you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Image description CodeRabbit

Commits Files that changed from the base of the PR and between cb8bd25 and 16e57c6 commits.
Files selected (4)
  • packages/web/src/components/VaultCard/VaultCard.tsx (3)
  • packages/web/src/pages/Honeypots/VaultDetailsPage/Sections/VaultScopeSection/InScopeSection/InScopeSection.tsx (1)
  • packages/web/src/styles/global.styles.ts (1)
  • packages/web/src/styles/variables.styles.ts (1)
Files ignored due to filter (1)
  • packages/web/src/languages/en.json
Files skipped from review due to trivial changes (3)
  • packages/web/src/pages/Honeypots/VaultDetailsPage/Sections/VaultScopeSection/InScopeSection/InScopeSection.tsx
  • packages/web/src/styles/global.styles.ts
  • packages/web/src/styles/variables.styles.ts
Review comments generated (3)
  • Review: 2
  • LGTM: 1

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

Comment on lines +124 to +132
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>
);
}
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) {

@@ -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()}`} />

@cloudflare-workers-and-pages
Copy link

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 16e57c6
Status: ✅  Deploy successful!
Preview URL: https://f3eddb32.dapp-a9y.pages.dev
Branch Preview URL: https://chore-minor-improvements.dapp-a9y.pages.dev

View logs

@fonstack fonstack requested a review from ben-kaufman October 5, 2023 14:09
@fonstack fonstack merged commit f635365 into develop Oct 5, 2023
4 checks passed
@fonstack fonstack deleted the chore/minor-improvements branch October 5, 2023 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants