forked from storybookjs/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
53 lines (46 loc) · 1.01 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import PropTypes from 'prop-types';
import React from 'react';
import Datetime from 'react-datetime';
import insertCss from 'insert-css';
import style from './styles';
const customStyle = `
.rdt input {
outline: 0;
width: 100%;
border: 1px solid #f7f4f4;
border-radius: 2px;
font-size: 11px;
padding: 5px;
color: #555;
display: table-cell;
box-sizing: border-box;
}
`;
insertCss(style);
insertCss(customStyle);
class DateType extends React.Component {
render() {
const { knob, onChange } = this.props;
return (
<div>
<Datetime
id={knob.name}
value={knob.value ? new Date(knob.value) : null}
type="date"
onChange={date => onChange(date.valueOf())}
/>
</div>
);
}
}
DateType.propTypes = {
knob: PropTypes.object,
onChange: PropTypes.func,
};
DateType.serialize = function(value) {
return String(value);
};
DateType.deserialize = function(value) {
return parseFloat(value);
};
export default DateType;