Add datetime widget

This commit is contained in:
Mathias Biilmann Christensen 2016-09-11 23:07:48 +02:00
parent 8d63ff0a88
commit bbbf3c5621
3 changed files with 32 additions and 0 deletions

View File

@ -76,6 +76,7 @@
"markup-it": "git+https://github.com/cassiozen/markup-it.git",
"pluralize": "^3.0.0",
"prismjs": "^1.5.1",
"react-datetime": "^2.6.0",
"react-portal": "^2.2.1",
"selection-position": "^1.0.0",
"semaphore": "^1.0.5",

View File

@ -0,0 +1,22 @@
import React, { PropTypes } from 'react';
import DateTime from 'react-datetime';
export default class DateTimeControl extends React.Component {
constructor(props) {
super(props);
this.handleChange = this.handleChange.bind(this);
}
handleChange(datetime) {
this.props.onChange(datetime);
}
render() {
return <DateTime value={this.props.value || new Date()} onChange={this.handleChange}/>;
}
}
DateTimeControl.propTypes = {
onChange: PropTypes.func.isRequired,
value: PropTypes.node,
};

View File

@ -0,0 +1,9 @@
import React, { PropTypes } from 'react';
export default function StringPreview({ value }) {
return <span>{value}</span>;
}
StringPreview.propTypes = {
value: PropTypes.node,
};