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

This enhancement aims to add a holiday list as parameters or props to the react-datepicker component. #4189

Closed
wants to merge 22 commits into from

Conversation

sushilkundu143
Copy link

The background will be set to orange for holidays in the calendar. If a holiday is selected, its background color will change to blue. Additionally, on mouseover, a tooltip will display the details of the corresponding holiday.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

✅ This pull request was sent to the PullRequest network.


@sushilkundu143 you can click here to see the review status or cancel the code review job.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

PullRequest Breakdown

Reviewable lines of change

+ 186
- 60

91% JavaScript
8% SCSS
1% Other

Generated lines of change

+ 1,352
- 1,308

Type of change

Feature - These changes are adding a new feature or improvement to existing code.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

This is looking like a great start, but I have some concerns left inline.

Image of Graham C Graham C


Reviewed with ❤️ by PullRequest

@@ -526,7 +531,7 @@ export default class exampleComponents extends React.Component {
onClick={(e) =>
this.handleAnchorClick(
e,
`example-${slugify(example.title, { lower: true })}`
`example-${slugify(example.title, { lower: true })}`,
Copy link

Choose a reason for hiding this comment

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

This unrelated change should be reverted. Trailing commas are great, but should not be added on mass within this PR - I'd recommend sending in a separate PR if you'd like to add trailing commas into places.

🔺 Best Practices (Critical)

Image of Graham C Graham C

src/calendar.jsx Outdated
@@ -54,7 +54,7 @@ const DROPDOWN_FOCUS_CLASSNAMES = [
const isDropdownSelect = (element = {}) => {
const classNames = (element.className || "").split(/\s+/);
return DROPDOWN_FOCUS_CLASSNAMES.some(
(testClassname) => classNames.indexOf(testClassname) >= 0
(testClassname) => classNames.indexOf(testClassname) >= 0,
Copy link

Choose a reason for hiding this comment

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

All these unrelated changes should be reverted. Trailing commas are great, but should not be added on mass within this PR - I'd recommend sending in a separate PR if you'd like to add trailing commas into places.

🔺 Best Practices (Critical)

Image of Graham C Graham C

@@ -168,7 +168,7 @@ export function safeDateFormat(date, { dateFormat, locale }) {
formatDate(
date,
Array.isArray(dateFormat) ? dateFormat[0] : dateFormat,
locale
locale,
Copy link

Choose a reason for hiding this comment

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

All these unrelated changes should be reverted.

🔺 Best Practices (Critical)

Image of Graham C Graham C

@@ -726,23 +726,56 @@ export function getHightLightDaysMap(
return dateClasses;
}

export function getHolidaysMap(
Copy link

Choose a reason for hiding this comment

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

This function needs test coverage.

🔺 Improve Test Coverage (Critical)

Image of Graham C Graham C

) {
const endPeriod = Math.ceil(getYear(date) / yearItemNumber) * yearItemNumber;
const startPeriod = endPeriod - (yearItemNumber - 1);
return { startPeriod, endPeriod };
}

// Utility function to filter the array from the Map based on the date
export function filterArrayByDate(date, dateMap) {
Copy link

Choose a reason for hiding this comment

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

This function needs test coverage.

🔺 Improve Test Coverage (Critical)

Image of Graham C Graham C

@@ -26,6 +27,7 @@ export default class Day extends React.Component {
dayClassName: PropTypes.func,
endDate: PropTypes.instanceOf(Date),
highlightDates: PropTypes.instanceOf(Map),
holidayDates: PropTypes.instanceOf(Map),
Copy link

Choose a reason for hiding this comment

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

The new logic in this file needs test coverage.

🔺 Improve Test Coverage (Critical)

Image of Graham C Graham C

src/index.jsx Outdated
@@ -163,13 +164,14 @@ export default class DatePicker extends React.Component {
PropTypes.shape({
start: PropTypes.instanceOf(Date),
end: PropTypes.instanceOf(Date),
})
}),
Copy link

Choose a reason for hiding this comment

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

All these unrelated changes should be reverted.

🔺 Best Practices (Critical)

Image of Graham C Graham C

@@ -323,6 +325,11 @@ export default class DatePicker extends React.Component {
highlightDates: getHightLightDaysMap(this.props.highlightDates),
});
}
if (prevProps.holidayDates !== this.props.holidayDates) {
Copy link

Choose a reason for hiding this comment

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

The new logic in this file needs test coverage.

🔺 Improve Test Coverage (Critical)

Image of Graham C Graham C

@@ -45,7 +45,7 @@ const MONTH_NAVIGATION_HORIZONTAL_OFFSET = 1;

function getMonthColumnsLayout(
showFourColumnMonthYearPicker,
showTwoColumnMonthYearPicker
showTwoColumnMonthYearPicker,
Copy link

Choose a reason for hiding this comment

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

All these unrelated changes should be reverted.

🔺 Best Practices (Critical)

Image of Graham C Graham C

Copy link

Choose a reason for hiding this comment

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

This issue remains. It is not the job of this PR to re-format the code, even if the formatting is bad. Another PR should be created to deal with that.

Image of Graham C Graham C

@@ -319,6 +320,7 @@ export default class Month extends React.Component {
inline={this.props.inline}
shouldFocusDayInline={this.props.shouldFocusDayInline}
highlightDates={this.props.highlightDates}
holidayDates={this.props.holidayDates}
Copy link

Choose a reason for hiding this comment

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

The new logic in this file needs test coverage.

🔺 Improve Test Coverage (Critical)

Image of Graham C Graham C

src/week.jsx Outdated
@@ -23,11 +23,12 @@ export default class Week extends React.Component {
PropTypes.shape({
start: PropTypes.instanceOf(Date),
end: PropTypes.instanceOf(Date),
})
}),
Copy link

Choose a reason for hiding this comment

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

All these unrelated changes should be reverted.

🔺 Best Practices (Critical)

Image of Graham C Graham C

@@ -133,6 +134,7 @@ export default class Week extends React.Component {
includeDates={this.props.includeDates}
includeDateIntervals={this.props.includeDateIntervals}
highlightDates={this.props.highlightDates}
holidayDates={this.props.holidayDates}
Copy link

Choose a reason for hiding this comment

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

The new logic in this file needs test coverage.

🔺 Improve Test Coverage (Critical)

Image of Graham C Graham C

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

Overall no issues are noted with this PR. Though there are some suggestions that should be though about before merging

Image of David K David K


Reviewed with ❤️ by PullRequest

.prettierrc Outdated
@@ -0,0 +1,3 @@
{
"trailingComma": "none"
Copy link

Choose a reason for hiding this comment

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

Did you know that by setting this to "all" typically resolves to fewer line changes in diffs. Because when a entry is added at the end of an object definition you don't end up modifying the line above to have the comma.

🔹 Giving Information (Nice to have)

Image of David K David K


// Utility function to filter the array from the Map based on the date
export function filterArrayByDate(date, dateMap) {
const formattedDate = formatDate(date, "MM.dd.yyyy");
Copy link

Choose a reason for hiding this comment

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

Would reccomend having a const DATE_FORMAT = "MM.dd.yyyy" defined and use that rather than re-using the same value. This will reduce potential problems in the future.

Since I note this is in at least 3 places in the current pull request.

🔸 Reduce Future Bugs (Important)

Image of David K David K

@martijnrusschen
Copy link
Member

This looks very similar to https://reactdatepicker.com/#example-highlight-dates-with-custom-class-names-and-ranges. Can you explain how this would be different and can't be solved by the example above?

Copy link
Member

@martijnrusschen martijnrusschen left a comment

Choose a reason for hiding this comment

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

Code contains a bunch of unrelated changes. After checking the code, this looks very similar to the highlight day function. Can't you achieve what you're trying to do with the existing functions? Test coverage seems to be missing too.

@@ -0,0 +1,3 @@
{
Copy link
Member

Choose a reason for hiding this comment

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

This isn't related to this PR. Please revert

Copy link

Choose a reason for hiding this comment

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

Agreed, this change should not be included.

Image of Graham C Graham C

Copy link
Member

Choose a reason for hiding this comment

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

Please revert

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

PullRequest reviewed the updates made to #4189 up until the latest commit (b4101de). No further issues were found.

Reviewed by:

Image of David K David K

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

All of the issues raised in the previous reviews remain, and further issues have been introduced - detailed inline.

Image of Graham C Graham C


Reviewed with ❤️ by PullRequest

renderDayContents={renderDayContents}
/>
);
};
Copy link

Choose a reason for hiding this comment

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

The docs-site/yarn.lock file should not be modified by this PR, and all changes to that file should not be included in this PR.

🔺 Bug (Critical)

Image of Graham C Graham C

@@ -15,6 +15,7 @@ import {
isAfter,
getDayOfWeekCode,
formatDate,
filterArrayByDate
Copy link

Choose a reason for hiding this comment

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

Missing trailing comma.

🔸 Best Practices (Important)

Image of Graham C Graham C

@@ -41,7 +42,7 @@ import {
DEFAULT_YEAR_ITEM_NUMBER,
isSameDay,
isMonthDisabled,
isYearDisabled,
isYearDisabled
Copy link

Choose a reason for hiding this comment

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

This change should not be included.

🔺 Bug (Critical)

Image of Graham C Graham C

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

Due to inactivity, PullRequest has cancelled this review job. You can reactivate the code review job from the PullRequest dashboard.

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.

3 participants