-
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
Use moment locales for customization #277
Use moment locales for customization #277
Conversation
Interesting, if we do this, how would the API for handling locales, custom week days look like? We should make sure the examples are updated/added too. (since this is a breaking change) For me, this sound like the biggest blocker before we move to a v1.0 of this component. |
Also, adding @RSO here to discuss the change and the future of using moment.js in the component. |
We would depend on the consumer to customize the moment locale themselves -- it would actually be very similar to what happens in the
This would also open up the ability to customize other things, like month names. Once we have the complete story figured out I'll update the docs and examples with our suggestions. I was thinking this could be part of a v1.0 milestone as well. I'll try to think of other things that should be included in the major release. |
Yep, as long as it stays easy to implement and use this component. Are we able to set some sane default s of the moment locales? Would prefer having a good default setup that people can overwrite if they want. |
I think it will better to remain customization points including month such as
Now I am applying a localization by
Actually, I had not known how I could do localization until I found docs from |
Sounds interesting. @rafeememon What do you think? |
I think in @JeffGuKang's case, he was being limited by the default props, specifically |
Found some more extreme sadness re: locales
Mainly because of the second point, I think the |
Updated my PR to reflect my new vision. Thoughts/comments welcome from everyone! |
}, | ||
weekdaysMin: weekdays | ||
}); | ||
localizeMoment(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.
Localizing the moment as soon as it's passed in allows the localization to be passed to weekdays and week start automatically.
@@ -44,8 +44,8 @@ var Day = React.createClass({ | |||
}, | |||
|
|||
isWeekend() { | |||
const weekday = this.props.day.weekday(); | |||
return weekday === 5 || weekday === 6; | |||
const weekday = this.props.day.day(); |
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.
Hooray for tests!
Current coverage is
|
After sleeping on it I've become increasingly convinced that this is the right way to go. I've updated the readme and examples with the new approach. @martijnrusschen, @RSO, could you take another look at this? |
I like the approach. Especially the fact that you can use your global moment locale in the component. Furthermore, the ability to pass in a moment locale as a prop makes it behaving the same as before. |
Let's do it -- these fixes are a long time coming |
Use moment locales for customization
Nice! |
👍 |
Update of #257, #228; fixes #175, #178; probably fixes #126, #160, #203
This is a radical change of how we handle locales. Instead of giving customization points to effectively change the date picker's locale (namely,
locale
,weekdays
, andweekStart
), this would completely defer to moment's handling of locales for custom weekdays/months/etc. I think this is reasonable since applications with different locales will most likely in practice be configuring the moment locale anyway, and if not it's reasonable to request them to do so. After my findings for #257, this would be the simplest thing to do going forward from both a component API and maintainability standpoint. But obviously since this is an API break it needs to be carefully considered.Thoughts/comments welcome!