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

Fixed bug with dayWrapper not applying #1196

Merged
merged 2 commits into from
May 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions examples/demos/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import dates from '../../src/utils/dates'

let allViews = Object.keys(BigCalendar.Views).map(k => BigCalendar.Views[k])

const ColoredDateCellWrapper = ({ children }) =>
React.cloneElement(React.Children.only(children), {
style: {
backgroundColor: 'lightblue',
},
})

let Basic = ({ localizer }) => (
<BigCalendar
events={events}
Expand All @@ -13,6 +20,9 @@ let Basic = ({ localizer }) => (
showMultiDayTimes
max={dates.add(dates.endOf(new Date(2015, 17, 1), 'day'), -1, 'hours')}
defaultDate={new Date(2015, 3, 1)}
components={{
timeSlotWrapper: ColoredDateCellWrapper,
}}
localizer={localizer}
/>
)
Expand Down
3 changes: 0 additions & 3 deletions src/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,6 @@ class Calendar extends React.Component {
* event: MyEvent, // used by each view (Month, Day, Week)
* eventWrapper: MyEventWrapper,
* eventContainerWrapper: MyEventContainerWrapper,
* dayWrapper: MyDayWrapper,
* dateCellWrapper: MyDateCellWrapper,
* timeSlotWrapper: MyTimeSlotWrapper,
* timeGutterHeader: MyTimeGutterWrapper,
Expand Down Expand Up @@ -665,7 +664,6 @@ class Calendar extends React.Component {
event: elementType,
eventWrapper: elementType,
eventContainerWrapper: elementType,
dayWrapper: elementType,
dateCellWrapper: elementType,
timeSlotWrapper: elementType,
timeGutterHeader: elementType,
Expand Down Expand Up @@ -783,7 +781,6 @@ class Calendar extends React.Component {
components: defaults(components[view] || {}, omit(components, names), {
eventWrapper: NoopWrapper,
eventContainerWrapper: NoopWrapper,
dayWrapper: NoopWrapper,
dateCellWrapper: NoopWrapper,
weekWrapper: NoopWrapper,
timeSlotWrapper: NoopWrapper,
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Object.assign(Calendar, {
move,
components: {
eventWrapper: EventWrapper,
dayWrapper: BackgroundWrapper,
timeSlotWrapper: BackgroundWrapper,
dateCellWrapper: BackgroundWrapper,
},
})
Expand Down
4 changes: 2 additions & 2 deletions stories/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ storiesOf('Big Calendar', module)
/>
)
})
.add('add custom dayWrapper', () => {
.add('add custom timeSlotWrapper', () => {
return (
<Calendar
defaultView={Calendar.Views.DAY}
events={events}
components={{
dayWrapper: customComponents.dayWrapper,
timeSlotWrapper: customComponents.timeSlotWrapper,
}}
/>
)
Expand Down
4 changes: 2 additions & 2 deletions stories/DragAndDrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ storiesOf('Drag and Drop')
/>
)
})
.add('draggable and resizable with custom dayWrapper', () => {
.add('draggable and resizable with custom timeSlotWrapper', () => {
return (
<DragAndDropCalendar
components={{
dayWrapper: customComponents.dayWrapper,
timeSlotWrapper: customComponents.timeSlotWrapper,
}}
defaultDate={new Date()}
defaultView={Calendar.Views.WEEK}
Expand Down
8 changes: 4 additions & 4 deletions stories/helpers/customComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ const customComponents = {
</div>
)
},
dayWrapper: dayWrapperProps => {
timeSlotWrapper: timeSlotWrapperProps => {
// Show different styles at arbitrary time
const hasCustomInfo = dayWrapperProps.value
? dayWrapperProps.value.getHours() === 4
const hasCustomInfo = timeSlotWrapperProps.value
? timeSlotWrapperProps.value.getHours() === 4
: false
const style = {
display: 'flex',
Expand All @@ -40,7 +40,7 @@ const customComponents = {
return (
<div style={style}>
{hasCustomInfo && 'Custom Day Wrapper'}
{dayWrapperProps.children}
{timeSlotWrapperProps.children}
</div>
)
},
Expand Down