Skip to content

Commit

Permalink
Fix CustomView (#658)
Browse files Browse the repository at this point in the history
  • Loading branch information
arkgast authored and jquense committed Mar 23, 2018
1 parent a744517 commit 79b1ee0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
6 changes: 3 additions & 3 deletions examples/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ class Example extends React.Component {
Custom rendering
</a>
</li>
{/* temporary hide link to documentation
<li className={cn({active: selected === 'customView' })}>
<a href='#' onClick={this.select.bind(null, 'customView')}>Custom View</a>
<a href='#' onClick={this.select.bind(null, 'customView')}>
Custom View
</a>
</li>
*/}
<li className={cn({ active: selected === 'Resource' })}>
<a href="#" onClick={this.select.bind(null, 'resource')}>
Resource columns
Expand Down
18 changes: 13 additions & 5 deletions examples/demos/customView.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,18 @@ const getRange = (date, culture) => {
if (firstOfWeek === 1) {
end = dates.subtract(end, 2, 'day')
} else {
start = dates.add(start, 1, 'day')
end = dates.subtract(end, 1, 'day')
start = dates.add(start, 1, 'day');
}

return dates.range(start, end)
let dateInRange = start;
let range = [];

while (dates.inRange(dateInRange, start, end, 'day')) {
range.push(dateInRange);
dateInRange = dates.add(dateInRange, 1, 'day');
}

return range;
}

class MyWeek extends React.Component {
Expand All @@ -44,14 +51,15 @@ MyWeek.navigate = (date, action) => {
}

MyWeek.title = (date, { formats, culture }) => {
return `My awesome week: ${Date.toLocaleString()}`
return `My awesome week: ${date.toLocaleString()}`
}


let CustomView = () => (
<BigCalendar
events={events}
defaultDate={new Date(2015, 3, 1)}
views={{ month: true, week: MyWeek }}
views={{ month: true, week: MyWeek, work_week: true }}
test="io"
/>
)
Expand Down

0 comments on commit 79b1ee0

Please sign in to comment.