Skip to content

Commit 36f9005

Browse files
committed
support id props;
1 parent d2d729c commit 36f9005

File tree

1 file changed

+47
-45
lines changed

1 file changed

+47
-45
lines changed

src/lib/index.jsx

+47-45
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,10 @@ import React, { Component } from "react";
22
import PropTypes from 'prop-types';
33

44
export default class CountdownTimer extends Component {
5-
static propTypes = {
6-
className: PropTypes.string,
7-
count: PropTypes.number,
8-
border: PropTypes.bool,
9-
showTitle: PropTypes.bool,
10-
direction: PropTypes.oneOf(['right', 'left']),
11-
noPoints: PropTypes.bool,
12-
responsive: PropTypes.bool,
13-
color: PropTypes.string,
14-
backgroundColor: PropTypes.string,
15-
size: PropTypes.number,
16-
labelSize: PropTypes.number,
17-
hideDay: PropTypes.bool,
18-
hideHours: PropTypes.bool,
19-
dayTitle: PropTypes.string,
20-
hourTitle: PropTypes.string,
21-
minuteTitle: PropTypes.string,
22-
secondTitle: PropTypes.string,
23-
onEnd: PropTypes.func,
24-
};
25-
26-
static defaultProps = {
27-
count: 0,
28-
border: false,
29-
showTitle: false,
30-
direction: 'left',
31-
noPoints: false,
32-
color: '#000',
33-
backgroundColor: '#fff',
34-
responsive: false,
35-
size: 18,
36-
labelSize: 12,
37-
hideDay: false,
38-
hideHours: false,
39-
dayTitle: 'Day',
40-
hourTitle: 'Hour',
41-
minuteTitle: 'Min',
42-
secondTitle: 'Sec',
43-
className: '',
44-
onEnd: () => {},
45-
};
46-
475
constructor(props) {
486
super(props);
497
this.state = {
50-
count: props.count,
8+
count: parseInt(props.count, 10),
519
};
5210
}
5311

@@ -173,11 +131,55 @@ export default class CountdownTimer extends Component {
173131

174132
render() {
175133
const { count } = this.state;
176-
const { className } = this.props;
134+
const { className, id } = this.props;
177135
return (
178-
<div className={`root-react-component-countdown-timer ${className}`}>
136+
<div className={`root-react-component-countdown-timer ${className}`} id={id}>
179137
<div className="displayedTime">{this.format(count)}</div>
180138
</div>
181139
);
182140
}
183141
}
142+
143+
CountdownTimer.propTypes = {
144+
className: PropTypes.string,
145+
id: PropTypes.string,
146+
count: PropTypes.number,
147+
border: PropTypes.bool,
148+
showTitle: PropTypes.bool,
149+
direction: PropTypes.oneOf(['right', 'left']),
150+
noPoints: PropTypes.bool,
151+
responsive: PropTypes.bool,
152+
color: PropTypes.string,
153+
backgroundColor: PropTypes.string,
154+
size: PropTypes.number,
155+
labelSize: PropTypes.number,
156+
hideDay: PropTypes.bool,
157+
hideHours: PropTypes.bool,
158+
dayTitle: PropTypes.string,
159+
hourTitle: PropTypes.string,
160+
minuteTitle: PropTypes.string,
161+
secondTitle: PropTypes.string,
162+
onEnd: PropTypes.func,
163+
};
164+
165+
CountdownTimer.defaultProps = {
166+
count: 0,
167+
border: false,
168+
showTitle: false,
169+
direction: 'left',
170+
noPoints: false,
171+
color: '#000',
172+
backgroundColor: '#fff',
173+
responsive: false,
174+
size: 18,
175+
labelSize: 12,
176+
hideDay: false,
177+
hideHours: false,
178+
dayTitle: 'Day',
179+
hourTitle: 'Hour',
180+
minuteTitle: 'Min',
181+
secondTitle: 'Sec',
182+
className: '',
183+
id: '',
184+
onEnd: () => {},
185+
};

0 commit comments

Comments
 (0)