Skip to content

Commit

Permalink
expose props.contentRender method
Browse files Browse the repository at this point in the history
  • Loading branch information
hujianming committed Oct 31, 2016
1 parent ab0d546 commit c3405c4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
19 changes: 19 additions & 0 deletions examples/antd-month-calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,24 @@ function disabledDate(value) {
value.year() === now.year() && value.month() > now.month();
}

// usage: monthCellRender={onMonthCellRender}
function onMonthCellRender(value, locale){
const content = value.month() + 1;
const prefixCls = 'rc-calendar-month-panel';
const cellEl = (
<a className={`${prefixCls}-month`}>
{content}
</a>
);
console.log('month-calendar onMonthCellRender', (value && value.format(format)));
return cellEl;
}

function onMonthCellContentRender(value, locale){
console.log('month-calendar onMonthCellContentRender', (value && value.format(format)));
return value.month() + 1;
}

ReactDOM.render(
(<div
style={{
Expand All @@ -135,6 +153,7 @@ ReactDOM.render(
disabledDate={disabledDate}
onSelect={onStandaloneSelect}
onChange={onStandaloneChange}
monthCellContentRender={onMonthCellContentRender}
defaultValue={defaultCalendarValue}
/>

Expand Down
9 changes: 7 additions & 2 deletions src/MonthCalendar.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import React from 'react';
import React, { PropTypes }from 'react';
import MonthPanel from './month/MonthPanel';
import CalendarMixin from './mixin/CalendarMixin';
import CommonMixin from './mixin/CommonMixin';
import KeyCode from 'rc-util/lib/KeyCode';

const MonthCalendar = React.createClass({
propTypes: {
monthCellRender: PropTypes.func,
dateCellRender: PropTypes.func,
},
mixins: [CommonMixin, CalendarMixin],

onKeyDown(event) {
Expand Down Expand Up @@ -58,7 +62,8 @@ const MonthCalendar = React.createClass({
disabledDate={props.disabledDate}
style={{ position: 'relative' }}
value={this.state.value}
contentRender={props.contentRender}
cellRender={props.monthCellRender}
contentRender={props.monthCellContentRender}
rootPrefixCls={props.prefixCls}
onChange={this.setValue}
onSelect={this.onSelect}
Expand Down
2 changes: 2 additions & 0 deletions src/month/MonthPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const MonthPanel = React.createClass({
render() {
const props = this.props;
const value = this.state.value;
const cellRender = props.cellRender;
const contentRender = props.contentRender;
const locale = props.locale;
const year = value.year();
Expand Down Expand Up @@ -127,6 +128,7 @@ const MonthPanel = React.createClass({
onSelect={this.setAndSelectValue}
locale={locale}
value={value}
cellRender={cellRender}
contentRender={contentRender}
prefixCls={prefixCls}
/>
Expand Down

0 comments on commit c3405c4

Please sign in to comment.