-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[Feature] add "renderMonth" support + add Persian locale story #449
Conversation
@@ -104,7 +107,7 @@ export default class CalendarMonth extends React.Component { | |||
} = this.props; | |||
|
|||
const { weeks } = this.state; | |||
const monthTitle = month.format(monthFormat); | |||
const monthTitle = renderMonth ? renderMonth(month) : month.format(monthFormat); |
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.
If we're calling a user function here, we'd need to somehow assert that monthTitle
is a string, to match month.format()
- and throw if not.
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.
So what is your suggestion?
I do this part as a code that now exist in CalendarDay
component:
https://github.com/airbnb/react-dates/blob/master/src/components/CalendarDay.jsx#L131
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.
hm, ok, fair point. this can stay as-is, and we can address them all holistically in the future.
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.
OK, @ljharb So any other change needs for this PR?
@@ -1,5 +1,6 @@ | |||
import React from 'react'; | |||
import moment from 'moment'; | |||
import momentJalaali from 'moment-jalaali'; |
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.
Does this need to be added as a dev dep?
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.
Yes, Sorry I missed it. It's added to devDependencies now. Please check it again.
06baeea
to
19f0af3
Compare
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.
I added this same support for the DRP as well. This looks good!
This PR add
renderMonth
to react-dates and help to add custom calendar like Jalali (Persian) calendar in future.It's needed for #447
This is a simple screenshot from story page: