Skip to content
Open
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
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,32 @@ npm i input-moment --save
http://wangzuo.github.io/input-moment

### Usage

#### Default

``` javascript
<InputMoment
moment={this.state.moment}
onChange={this.handleChange}
onSave={this.handleSave}
/>
```

#### Custom Icon

``` javascript
<InputMoment
moment={this.state.moment}
onChange={this.handleChange}
onSave={this.handleSave}
prevMonthIcon="ion-ios-arrow-left" // default
nextMonthIcon="ion-ios-arrow-right" // default
prevMonthIcon="fa fa-angle-left"
nextMonthIcon="fa fa-angle-right"
dateIcon="fa fa-calendar-o"
timeIcon="fa fa-clock-o"
saveIcon="fa fa-check"
/>
```

Check [app.js](https://github.com/wangzuo/input-moment/blob/master/example/app.js) for a working example.

### Development
Expand Down
14 changes: 9 additions & 5 deletions src/input-moment.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,27 @@ module.exports = React.createClass({
getDefaultProps() {
return {
prevMonthIcon: 'ion-ios-arrow-left',
nextMonthIcon: 'ion-ios-arrow-right'
nextMonthIcon: 'ion-ios-arrow-right',
dateIcon: 'ion-calendar',
timeIcon: 'ion-clock',
saveIcon: 'ion-checkmark'
};
},

render() {
var tab = this.state.tab;
var m = this.props.moment;
var props = blacklist(this.props, 'className', 'moment', 'prevMonthIcon', 'nextMonthIcon', 'onSave');
var props = blacklist(this.props, 'className', 'moment', 'prevMonthIcon', 'nextMonthIcon', 'onSave', 'dateIcon', 'timeIcon', 'saveIcon');
props.className = cx('m-input-moment', this.props.className);


return (
<div {...props}>
<div className="options">
<button type="button" className={cx('ion-calendar im-btn', {'is-active': tab === 0})} onClick={this.handleClickTab.bind(null, 0)}>
<button type="button" className={cx(`${this.props.dateIcon} im-btn`, {'is-active': tab === 0})} onClick={this.handleClickTab.bind(null, 0)}>
Date
</button>
<button type="button" className={cx('ion-clock im-btn', {'is-active': tab === 1})} onClick={this.handleClickTab.bind(null, 1)}>
<button type="button" className={cx(`${this.props.timeIcon} im-btn`, {'is-active': tab === 1})} onClick={this.handleClickTab.bind(null, 1)}>
Time
</button>
</div>
Expand All @@ -53,7 +57,7 @@ module.exports = React.createClass({
/>
</div>

<button type="button" className="im-btn btn-save ion-checkmark"
<button type="button" className={`im-btn btn-save ${this.props.saveIcon}`}
onClick={this.handleSave}>
Save
</button>
Expand Down