-
-
Notifications
You must be signed in to change notification settings - Fork 727
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
New labels prop #35
Comments
Not sure if call the prop |
I'm a little concerned about having this project be opinionated about the best way to implement this feature. I could see situations in which both I wonder if what's really needed is a hook to add any additional attributes to a given day element. That way, the author could determine how |
In this way, localization concerns for this feature are offloaded to the implementation, instead of this project. |
I agree with your point. There's a function renderDay(day, modifiers) {
return <div title="MyCustomLocalizedTitle">{ day.getDate() }</div>;
}
render() {
return <DayPicker renderDay={renderDay} />;
} The component would still append the proper |
I like where that's going. But in that solution, you'd be responsible for adding additional element properties ( In this way, the implementation would be responsible for transferring the generated properties on the new element. And it gives opportunity for the props to be modified as needed. function renderDay(day, props) {
// Modify props, as needed.
return <div {...props} title="MyCustomLocalizedTitle">{ day.getDate() }</div>;
}
render() {
return <DayPicker renderDay={renderDay} />;
} A potential good consequence of this is that internally, you could be using this same mechanism, and therefore, the project is dog-fooding its own API. Some pseudo code to explain what I mean: // src/DayPicker.js
static defaultProps = {
renderDay: (day, props) => (<div {...props}>{ day.getDate() }</div>)
}
renderDay(month, day) {
// ...
const { renderDay } = this.props;
// Construct `props` object instead of applying properties directly on the JSX element.
// Handle all modifier details.
return renderDay(day, props);
} |
In extending this idea, I wonder how necessary some of the Day handlers are ( |
By the way, documentation regarding transferring props: |
Yes I don't see the need to explicitly pass the Passing the whole day cell should also be "enough" backward compatible, because the dev already wraps the content into an element (or he/she passes just a string). I need to confirm this, in case we could add a deprecation warning. PS. It already dog-feeds that prop :-) |
However I'd like to add default support for |
Seems like a worthy endeavor. Just keep in mind that not every Day cell will need an Do<div
class="DayPicker-Day DayPicker-Day--today DayPicker-Day--selected"
aria-label="Today"
aria-selected="true"
...>
29
</div> <div
class="DayPicker-Day DayPicker-Day--selected"
aria-selected="true"
...>
30
</div> Do not<div
class="DayPicker-Day DayPicker-Day--today DayPicker-Day--selected"
aria-label="Today, Selected"
aria-selected="true"
...>
29
</div> <div
class="DayPicker-Day DayPicker-Day--selected"
aria-label="Selected"
aria-selected="true"
...>
30
</div> |
Perfect thanks for the hint! |
I'm closing this as such values can be changed from a custom LocaleUtils prop. |
A
labels
prop may help to implementtitle
andaria-label
attributes (see #33). Example:The text was updated successfully, but these errors were encountered: