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

Add a render function for customizable week header text #1787

Merged
merged 1 commit into from Sep 17, 2019

Conversation

caseklim
Copy link
Collaborator

Summary

Add a function renderWeekHeaderText (would renderWeekHeaderElemement be more appropriate?) that allows the week header text for a calendar month to be customized.

Screenshots

Default

image

With custom week header text

image

@coveralls
Copy link

coveralls commented Sep 17, 2019

Coverage Status

Coverage remained the same at 85.005% when pulling bfbc01d on caseklim--customizable-week-header-text into c588a9d on master.

@caseklim caseklim added the semver-minor: new stuff Any feature or API addition. label Sep 17, 2019
@@ -88,6 +88,7 @@ const propTypes = forbidExtraProps({
// month props
renderMonthText: mutuallyExclusiveProps(PropTypes.func, 'renderMonthText', 'renderMonthElement'),
renderMonthElement: mutuallyExclusiveProps(PropTypes.func, 'renderMonthText', 'renderMonthElement'),
renderWeekHeaderText: PropTypes.func,
Copy link
Contributor

Choose a reason for hiding this comment

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

I like your suggestion of renderWeekHeaderElement, since an element would be a valid return value.

@@ -149,6 +150,7 @@ export const defaultProps = {
// month props
renderMonthText: null,
renderMonthElement: null,
renderWeekHeaderText: null,
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if this is better or worse, but did you consider making the default for this:

renderWeekHeaderText: day => <small>{day}</small>

?

That would collapse the number of conditionals from 2 (the ternary in the render prop and the default prop) to 1 (just the default prop).

But maybe it would be harder to see what the default is when scanning the component?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ooh I like that idea! though I tend to see this pattern more where the function prop is optional and then some functionality is used in its place, rather than assigning that functionality as the default to the function prop—so I'm inclined to keep this as-is for consistency.

Copy link
Contributor

@ahuth ahuth left a comment

Choose a reason for hiding this comment

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

Good idea, and LGTM 🤘

@caseklim caseklim force-pushed the caseklim--customizable-week-header-text branch from 1a3547e to 9bea561 Compare September 17, 2019 22:45
@caseklim caseklim force-pushed the caseklim--customizable-week-header-text branch from 9bea561 to 21ec280 Compare September 17, 2019 23:29
@caseklim caseklim merged commit fab1721 into master Sep 17, 2019
@caseklim caseklim deleted the caseklim--customizable-week-header-text branch September 17, 2019 23:41
@ahuth ahuth mentioned this pull request Sep 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-minor: new stuff Any feature or API addition.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants