Skip to content

Commit

Permalink
Fixes #30; Updated eslintrc so it wouldn't be angry.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Brito committed Mar 4, 2016
1 parent 0f3230f commit d3743bc
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 49 deletions.
6 changes: 1 addition & 5 deletions .eslintrc
Expand Up @@ -50,10 +50,7 @@
2,
"single"
],
"space-after-keywords": [
2,
"always"
],
"keyword-spacing": 2,
"space-before-blocks": [
2,
"always"
Expand All @@ -62,7 +59,6 @@
2,
"always"
],
"space-return-throw-case": 2,
"strict": 0,
"vars-on-top": 2,
"indent": [
Expand Down
65 changes: 31 additions & 34 deletions demo.js
Expand Up @@ -29,10 +29,6 @@ const PagingCalendar = React.createClass({
});
},

handleClick: function (scope, m, e) {
alert('handleClick: ' + scope + ' ' + m.format());
},

render: function () {
return (
<div>
Expand All @@ -44,39 +40,40 @@ const PagingCalendar = React.createClass({
</a>
<Calendar weekNumbers={ true }
startDate={ this.state.date }
date={ this.state.date }
endDate={ this.state.date.clone().endOf('year') }
mods={
[
{
date: moment(),
classNames: [ 'current' ],
component: [ 'day', 'month', 'week' ]
},
{
date: moment().add(3, 'days'),
classNames: [ 'event' ],
component: [ 'day' ]
},
{
date: moment().add(4, 'days'),
classNames: [ 'event', 'warning' ],
component: [ 'day' ],
events: {
onClick: (date, e) => alert(`${date.format('dddd')}'s event!`)
}
},
{
date: moment().add(5, 'days'),
classNames: [ 'event' ],
component: [ 'day' ]
},
{
component: 'day',
events: {
onClick: (date, e) => alert(date.format())
}
[
{
date: moment(),
classNames: [ 'current' ],
component: [ 'day', 'month', 'week' ]
},
{
date: moment().add(3, 'days'),
classNames: [ 'event' ],
component: [ 'day' ]
},
{
date: moment().add(4, 'days'),
classNames: [ 'event', 'warning' ],
component: [ 'day' ],
events: {
onClick: (date, e) => alert(`${date.format('dddd')}'s event!`)
}
},
{
date: moment().add(5, 'days'),
classNames: [ 'event' ],
component: [ 'day' ]
},
{
component: 'day',
events: {
onClick: (date, e) => alert(date.format())
}
]
}
]
} />
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions index.html
Expand Up @@ -22,8 +22,8 @@
<div class="container-fluid">
<div id="app"></div>
</div>
<script src="https://fb.me/react-0.14.3.js"></script>
<script src="https://fb.me/react-dom-0.14.3.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/react/0.14.3/react.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/react/0.14.3/react-dom.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment-with-locales.min.js"></script>
<script src="react-calendar.js"></script>
</body>
19 changes: 11 additions & 8 deletions src/Calendar.js
Expand Up @@ -53,21 +53,24 @@ export default class Calendar extends Component {
render () {
const { mods } = this.props;
const monthMods = getModsByCompType('month', mods);
const weekMods = getModsByCompType('week', mods);
const dayMods = getModsByCompType('day', mods);
let weekMods = getModsByCompType('week', mods);
let dayMods = getModsByCompType('day', mods);

return (
<div>
{ this.renderHeader() }
{
this.getMonthRange().map((date, i) =>
<Month key={ `month-${i}` }
this.getMonthRange().map((date, i) => {
let fWeekMods = weekMods.filter((mod, j) => mod.date ? mod.date.get('month') === i : true);
let fDayMods = dayMods.filter((mod, k) => mod.date ? mod.date.get('month') === i : true);

return <Month key={ `month-${i}` }
date={ date }
weekNumbers={ true }
weekNumbers={ this.props.weekNumbers }
mods={ monthMods }
week={ weekMods }
day={ dayMods } />
)
week={ fWeekMods }
day={ fDayMods } />
})
}
</div>
);
Expand Down

0 comments on commit d3743bc

Please sign in to comment.