Skip to content

Commit

Permalink
[fixed] 取消isOpen, onCancel属性
Browse files Browse the repository at this point in the history
  • Loading branch information
lanjingling0510 committed Jun 24, 2016
1 parent fac8324 commit 1687e8e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 30 deletions.
22 changes: 4 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,13 @@ import 'react-mobile-datepicker/dist/react-mobile-datepicker.css'; // only needs
var today = new Date();
var minDate = Number(new Date()) - (24*60*60*1000) * 7; // One week before today

class Wrap extends Component {
state = {
isOpen: true,
}
render() {
return (
<DatePicker
isOpen={this.state.isOpen}
startDate={today}
minDate={minDate}
onCancel={() => { this.state.isOpen = false; }}
onSelect={(time) => { console.log(time); }} />
);
}
}


render(
<Wrap />,
<DatePicker
startDate={today}
minDate={minDate}
onSelect={(time) => { console.log(time); }} />,
document.getElementById('root')
);
```
Expand All @@ -70,12 +58,10 @@ Prop Types
| btnColor | String | #fff | 完成按钮颜色 |
| dateColor | String | #fff | 日期文字颜色 |
| layerBackground | String | #ffa70b | 背景颜色 |
| isOpen | Boolean | true | 是否显示 |
| startDate | Date | new Date() | 初始日期 |
| minDate | Date | 前一周 | 最小日期 |
| maxDate | Date | new Date() | 最小日期 |
| onSelect | Function | () => {} | 点击完成后的回调函数, Date对象作为参数 |
| onCancel | Function | () => {} | 隐藏时间选择器的回调函数 |

Changelog
-------------
Expand Down
3 changes: 0 additions & 3 deletions examples/basic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ import ReactDOM from 'react-dom';
import DatePicker from '../../lib/index';
import { nextTime } from '../../lib/time.js';
(function main() {
let isOpen = true;
const datePicker = (
<DatePicker
isOpen={isOpen}
startDate={nextTime(new Date(), -1)}
minDate={nextTime(new Date(), -3)}
onCancel={() => { isOpen = false; }}
onSelect={(time) => { console.log(time); }} />
);
ReactDOM.render(datePicker, document.getElementById('react-box'));
Expand Down
6 changes: 0 additions & 6 deletions lib/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class DatePicker extends Component {
handleFinishBtnClick() {
const date = this.state.dates.find(value => value.angle + this.state.angle === 0);
this.props.onSelect(date.value);
this.props.onCancel();
}

handleContentTouch(event) {
Expand Down Expand Up @@ -149,7 +148,6 @@ class DatePicker extends Component {
};

const datePickerStyle = {
display: this.props.isOpen ? '' : 'none',
backgroundColor: layerBackground,
};

Expand Down Expand Up @@ -189,25 +187,21 @@ DatePicker.propTypes = {
btnColor: PropTypes.string,
dateColor: PropTypes.string,
layerBackground: PropTypes.string,
isOpen: PropTypes.bool,
startDate: PropTypes.object,
minDate: PropTypes.object,
maxDate: PropTypes.object,
onSelect: PropTypes.func,
onCancel: PropTypes.func,
};

DatePicker.defaultProps = {
touchLen: 40,
dateColor: '#fff',
btnColor: '#fff',
isOpen: true,
layerBackground: '#ffa70b',
startDate: nextTime(new Date(), 0),
minDate: nextTime(new Date(), -30),
maxDate: nextTime(new Date(), 0),
onSelect: () => {},
onCancel: () => {},
};

export default DatePicker;
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "1.0.9",
"description": "一个移动端时间选择器react组件",
"main": "./dist/mobile-datepicker.js",
"repository": "lanjingling0510/react-mobile-date-picker",
"homepage": "https://github.com/lanjingling0510/react-mobile-date-picker#readme",
"repository": "lanjingling0510/react-mobile-datepicker",
"homepage": "https://github.com/lanjingling0510/react-mobile-datepicker#readme",
"scripts": {
"build": "webpack",
"start": "webpack-dev-server",
Expand Down Expand Up @@ -52,4 +52,4 @@
"react-dom": "^15.1.0"
},
"license": "ISC"
}
}

0 comments on commit 1687e8e

Please sign in to comment.