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

Added shortcut to today's date in Fresh Releases using a Calendar Ico… #3125

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

granth23
Copy link
Contributor

Problem

LB-1528: Add shortcut to today's date in Fresh Releases

Solution

Added a calendar icon in the datewise scroll bar as a ticker to directly refer to today's date.

image

Action

  • Let me know if any additional details or corrections are required.
  • If the changes look good, kindly proceed with merging the PR.

Copy link
Member

@MonkeyDo MonkeyDo left a comment

Choose a reason for hiding this comment

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

Looking good, thanks for working on this it will improve the page straight away!

<FontAwesomeIcon
icon={faCalendarCheck}
size="2xl"
style={{ color: "#353070" }}
Copy link
Member

Choose a reason for hiding this comment

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

We have a constant COLOR_LB_BLUE , which you can import from frontend/js/src/utils/constants.ts
Also you can directly use the color prop instead of style:
color={COLOR_LB_BLUE}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion

@granth23
Copy link
Contributor Author

Made the necessary changes, thanks for the suggestion

@granth23 granth23 requested a review from MonkeyDo January 15, 2025 04:04
Comment on lines 30 to 49
const today = new Date();
const todayString = today.toISOString().split("T")[0];
const formattedTodayString = formatReleaseDate(todayString);
const filteredDates = Object.keys(releasesPerDate).filter((date) =>
date !== todayString
? releasesPerDate[date] >= minReleasesThreshold
: releasesPerDate[date] > 0
);

dataArr = filteredDates.map((item) => formatReleaseDate(item));
dataArr = filteredDates.map((item) =>
formatReleaseDate(item) === formattedTodayString ? (
<FontAwesomeIcon
icon={faCalendarCheck}
size="2xl"
color={COLOR_LB_BLUE}
/>
) : (
formatReleaseDate(item)
)
);
Copy link
Member

Choose a reason for hiding this comment

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

I had another read through the code and I figured we can simplify this quite a lot thanks to a utility function from the date-fns library that we use in LB:
https://date-fns.org/v4.1.0/docs/isToday

From testing in the console on their website, it should be as simple as doing:

image
and removing today, todayString and formattedTodayString.

Of course you'll need to import { isToday } from "date-fns";

    const filteredDates = Object.keys(releasesPerDate).filter((date) =>
      !isToday(new Date(date))
        ? releasesPerDate[date] >= minReleasesThreshold
        : releasesPerDate[date] > 0
    );

    dataArr = filteredDates.map((item) =>
      isToday(new Date(item)) ? (
        <FontAwesomeIcon
          icon={faCalendarCheck}
          size="2xl"
          color={COLOR_LB_BLUE}
        />
      ) : (
        formatReleaseDate(item)
      )
    );

@@ -15,7 +18,7 @@ function createMarks(
sortDirection: string,
order: string
) {
let dataArr: Array<string> = [];
let dataArr: Array<React.ReactNode> = [];
Copy link
Member

Choose a reason for hiding this comment

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

This might be more appropriate:

Suggested change
let dataArr: Array<React.ReactNode> = [];
let dataArr: Array<string | JSX.Element> = [];

@granth23 granth23 requested a review from MonkeyDo January 15, 2025 17:50
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