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

added new customization 'dayPropGetter' #634

Merged
merged 3 commits into from
Dec 5, 2017
Merged

Conversation

eschreiner
Copy link
Contributor

Hi there,

I have extended the code with another optional customization function dayPropGetter(date) that can be used to customize e.g. the background of days in the month, week, and work week views without the need for custom components, e.g. to render all past dates with a gray background.

Please consider it for merging into master. Let me know if I should update anything (like the function's name) before you accept this pull request.

Best regards,
Erich

Copy link
Owner

@jquense jquense left a comment

Choose a reason for hiding this comment

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

Looks good just some notes. Thanks!

let { selecting, startIdx, endIdx } = this.state;

return (
<div className='rbc-row-bg'>
{range.map((date, index) => {
let selected = selecting && index >= startIdx && index <= endIdx;
const { className, style: dayStyles } = (dayPropGetter && dayPropGetter(date)) || {};
const segmStyles = segStyle(1, range.length)
const styles = Object.assign({}, segmStyles, dayStyles)
Copy link
Owner

Choose a reason for hiding this comment

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

segmentStyles should be assigned in last so they cannot be overridden by the dayPropGetter styles

src/DayColumn.js Outdated
dates.isToday(max) && 'rbc-today'
)}
style={Object.assign({}, slotStyle, style)}
Copy link
Owner

Choose a reason for hiding this comment

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

same here style, slotStyle

src/TimeSlot.js Outdated
@@ -22,7 +23,7 @@ export default class TimeSlot extends Component {
}

render() {
const { value, slotPropGetter } = this.props;
const { value, slotPropGetter, dayPropGetter } = this.props;
Copy link
Owner

Choose a reason for hiding this comment

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

this isn't used here (and shouldn't be)

return (
<TimeSlot
key={slotNumber}
slotPropGetter={slotPropGetter}
dayPropGetter={dayPropGetter}
Copy link
Owner

Choose a reason for hiding this comment

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

remove

src/TimeGrid.js Outdated
@@ -201,7 +202,7 @@ export default class TimeGrid extends Component {
}

renderEvents(range, events, today){
let { min, max, endAccessor, startAccessor, components } = this.props;
let { min, max, endAccessor, startAccessor, components, dayPropGetter } = this.props;
Copy link
Owner

Choose a reason for hiding this comment

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

doesn't need to be spread out here

src/TimeGrid.js Outdated
dates.isToday(date) && 'rbc-today',
)}
style={segStyle(1, this.slots)}
style={Object.assign({}, segStyle(1, this.slots), style)}
Copy link
Owner

Choose a reason for hiding this comment

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

order

@eschreiner
Copy link
Contributor Author

Hi Jason,

thank you for the thorough review.

I have updated my code according to your comments. Do I need to do anything additional (besides committing) from my side?

Thanks again & best regards,
Erich

Copy link
Owner

@jquense jquense left a comment

Choose a reason for hiding this comment

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

looks good thanks!

@eschreiner
Copy link
Contributor Author

eschreiner commented Dec 5, 2017

Hi again,

I have just moved the demo code for the new dayPropGetter to the 'rendering' demo. The 7th and 12th of each month get an orange background and a custom border color.

  • Is there any documentation that I should update / extend accordingly?
  • When will you be able to merge these changes and create a new release?

Thank you again & best regards,
Erich

@eschreiner
Copy link
Contributor Author

This new feature provides a solution for #272 .

@jquense jquense merged commit 5b06a53 into jquense:master Dec 5, 2017
@jquense
Copy link
Owner

jquense commented Dec 5, 2017

thanks!

@eschreiner
Copy link
Contributor Author

Hi Jason,

thank you for the quick response.

Should we create a new release 0.17.1 for this? Please let me know if you want to do so, then I'll update ChangeLog.md and bump the version in package.json accordingly and push these changes to my fork.

Regards,
Erich

@jquense
Copy link
Owner

jquense commented Dec 5, 2017

feel free to PR a change to the Changelog, i will handle bumping the versions

@eschreiner eschreiner mentioned this pull request Dec 6, 2017
@kirkjensen18
Copy link

Any idea when you'll publish this to npm?

@rnnyrk
Copy link

rnnyrk commented Feb 5, 2018

Any documentation on the usage of this function? Can't find dayPropGetter anywhere in the docs?

I only see a reference in this source file, but it's not in my installed files? I just ran npm i -S react-big-calendar which installed v0.17.0?
https://github.com/intljusticemission/react-big-calendar/blob/master/src/Calendar.js#L360

Do I need to install something else? From a MR or commit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants