-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Conversation
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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.
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 })}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/date_utils.js
Outdated
@@ -168,7 +168,7 @@ export function safeDateFormat(date, { dateFormat, locale }) { | |||
formatDate( | |||
date, | |||
Array.isArray(dateFormat) ? dateFormat[0] : dateFormat, | |||
locale | |||
locale, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -726,23 +726,56 @@ export function getHightLightDaysMap( | |||
return dateClasses; | |||
} | |||
|
|||
export function getHolidaysMap( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
) { | ||
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -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), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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), | |||
}) | |||
}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -323,6 +325,11 @@ export default class DatePicker extends React.Component { | |||
highlightDates: getHightLightDaysMap(this.props.highlightDates), | |||
}); | |||
} | |||
if (prevProps.holidayDates !== this.props.holidayDates) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -45,7 +45,7 @@ const MONTH_NAVIGATION_HORIZONTAL_OFFSET = 1; | |||
|
|||
function getMonthColumnsLayout( | |||
showFourColumnMonthYearPicker, | |||
showTwoColumnMonthYearPicker | |||
showTwoColumnMonthYearPicker, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -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} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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), | |||
}) | |||
}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -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} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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
Reviewed with ❤️ by PullRequest
.prettierrc
Outdated
@@ -0,0 +1,3 @@ | |||
{ | |||
"trailingComma": "none" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
// 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"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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? |
There was a problem hiding this 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 @@ | |||
{ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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.
Reviewed with ❤️ by PullRequest
renderDayContents={renderDayContents} | ||
/> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -15,6 +15,7 @@ import { | |||
isAfter, | |||
getDayOfWeekCode, | |||
formatDate, | |||
filterArrayByDate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -41,7 +42,7 @@ import { | |||
DEFAULT_YEAR_ITEM_NUMBER, | |||
isSameDay, | |||
isMonthDisabled, | |||
isYearDisabled, | |||
isYearDisabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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.
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.