From 8011590fca58b8020a201b6ded413c9b55c17b85 Mon Sep 17 00:00:00 2001 From: Salman Hasrat Date: Thu, 30 Mar 2017 16:41:20 +0400 Subject: [PATCH 1/8] Added tickinterval + proptypes --- src/Countdown.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Countdown.js b/src/Countdown.js index 46d0e9e..9433fcc 100644 --- a/src/Countdown.js +++ b/src/Countdown.js @@ -14,7 +14,7 @@ export default class Countdown extends Component { componentDidMount() { this.tick() - this.interval = setInterval(this.tick.bind(this), 1000) + this.interval = setInterval(this.tick.bind(this), this.props.tickInterval) } componentWillUnmount() { @@ -45,3 +45,11 @@ export default class Countdown extends Component { ) }; } + +Countdown.defaultProps = { + tickInterval: 1000 +} + +Countdown.propTypes = { + tickInterval: PropTypes.number /* millisecond */ +}; \ No newline at end of file From 09118c2f3173e16837a13d7590017c95361bf47a Mon Sep 17 00:00:00 2001 From: Salman Hasrat Date: Thu, 30 Mar 2017 16:45:19 +0400 Subject: [PATCH 2/8] Added div for days,hours etc --- src/DateBetween.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/DateBetween.js b/src/DateBetween.js index f62c818..5d640d2 100644 --- a/src/DateBetween.js +++ b/src/DateBetween.js @@ -17,10 +17,10 @@ let DateBetween = function(startDate, endDate) { let between = []; - days > 0 ? between.push(`${days} day${days > 1 ? 's' : ''}`) : false; - hours > 0 ? between.push(`${hours} hour${hours > 1 ? 's' : ''}`) : false; - minutes > 0 ? between.push(`${minutes} minute${minutes > 1 ? 's' : ''}`) : false; - seconds > 0 ? between.push(`${seconds} second${seconds > 1 ? 's' : ''}`) : false; + days > 0 ? between.push(`
${days} day${days > 1 ? 's' : ''}
`) : false; + hours > 0 ? between.push(`
${hours} hour${hours > 1 ? 's' : ''}
`) : false; + minutes > 0 ? between.push(`
${minutes} minute${minutes > 1 ? 's' : ''}
`) : false; + seconds > 0 ? between.push(`
${seconds} second${seconds > 1 ? 's' : ''}
`) : false; return between.join(' '); } From 4c4145edd7713fee43d84f538a212b8aa72c2645 Mon Sep 17 00:00:00 2001 From: Salman Hasrat Date: Thu, 30 Mar 2017 16:56:25 +0400 Subject: [PATCH 3/8] added building before start --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 02a00a9..c9f7f84 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "build": "babel src --out-dir lib", "example": "webpack --config ./example/webpack.config.js", "serve": "node ./example/server.js", - "start": "npm run example && npm run serve", + "start": "npm run build && npm run example && npm run serve", "test": "tape test/index.js" }, "keywords": [ From 781eae6b55c22b466861da07c0b8d8d4358b86ad Mon Sep 17 00:00:00 2001 From: Salman Hasrat Date: Thu, 30 Mar 2017 16:57:08 +0400 Subject: [PATCH 4/8] added dangerously set to set the string --- lib/Countdown.js | 21 +++++++++++++-------- src/Countdown.js | 5 +++-- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/Countdown.js b/lib/Countdown.js index 1c15504..2acc7b5 100644 --- a/lib/Countdown.js +++ b/lib/Countdown.js @@ -42,7 +42,7 @@ var Countdown = function (_Component) { key: 'componentDidMount', value: function componentDidMount() { this.tick(); - this.interval = setInterval(this.tick.bind(this), 1000); + this.interval = setInterval(this.tick.bind(this), this.props.tickInterval); } }, { key: 'componentWillUnmount', @@ -68,15 +68,11 @@ var Countdown = function (_Component) { }, { key: 'render', value: function render() { + var html = { __html: this.state.remaining }; return _react2.default.createElement( 'div', { className: 'react-count-down' }, - _react2.default.createElement( - 'span', - { className: 'date' }, - ' ', - this.state.remaining - ), + _react2.default.createElement('span', { className: 'date', dangerouslySetInnerHTML: html }), _react2.default.createElement( 'span', { className: 'prefix' }, @@ -90,4 +86,13 @@ var Countdown = function (_Component) { return Countdown; }(_react.Component); -exports.default = Countdown; \ No newline at end of file +exports.default = Countdown; + + +Countdown.defaultProps = { + tickInterval: 60000 +}; + +Countdown.propTypes = { + tickInterval: _react.PropTypes.number /* millisecond */ +}; \ No newline at end of file diff --git a/src/Countdown.js b/src/Countdown.js index 9433fcc..386e45c 100644 --- a/src/Countdown.js +++ b/src/Countdown.js @@ -37,9 +37,10 @@ export default class Countdown extends Component { } render() { + const html = { __html: this.state.remaining }; return (
- {this.state.remaining} + {this.props.options.prefix}
) @@ -47,7 +48,7 @@ export default class Countdown extends Component { } Countdown.defaultProps = { - tickInterval: 1000 + tickInterval: 60000 } Countdown.propTypes = { From 67e026b5b076d37350367f854eeace4498921a43 Mon Sep 17 00:00:00 2001 From: Salman Hasrat Date: Thu, 30 Mar 2017 16:57:26 +0400 Subject: [PATCH 5/8] final version --- example/public/bundle.js | 43 +++++++++++++++++++++++++++------------- lib/DateBetween.js | 8 ++++---- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/example/public/bundle.js b/example/public/bundle.js index 5f9b19c..af019da 100644 --- a/example/public/bundle.js +++ b/example/public/bundle.js @@ -149,7 +149,7 @@ key: 'componentDidMount', value: function componentDidMount() { this.tick(); - this.interval = setInterval(this.tick.bind(this), 1000); + this.interval = setInterval(this.tick.bind(this), this.props.tickInterval); } }, { key: 'componentWillUnmount', @@ -175,7 +175,8 @@ }, { key: 'render', value: function render() { - return _react2.default.createElement('div', { className: 'react-count-down' }, _react2.default.createElement('span', { className: 'date' }, ' ', this.state.remaining), _react2.default.createElement('span', { className: 'prefix' }, ' ', this.props.options.prefix)); + var html = { __html: this.state.remaining }; + return _react2.default.createElement('div', { className: 'react-count-down' }, _react2.default.createElement('span', { className: 'date', dangerouslySetInnerHTML: html }), _react2.default.createElement('span', { className: 'prefix' }, ' ', this.props.options.prefix)); } }]); @@ -184,6 +185,14 @@ exports.default = Countdown; + Countdown.defaultProps = { + tickInterval: 60000 + }; + + Countdown.propTypes = { + tickInterval: _react.PropTypes.number /* millisecond */ + }; + /***/ }, /* 2 */ /***/ function(module, exports) { @@ -208,10 +217,10 @@ var between = []; - days > 0 ? between.push(days + ' day' + (days > 1 ? 's' : '')) : false; - hours > 0 ? between.push(hours + ' hour' + (hours > 1 ? 's' : '')) : false; - minutes > 0 ? between.push(minutes + ' minute' + (minutes > 1 ? 's' : '')) : false; - seconds > 0 ? between.push(seconds + ' second' + (seconds > 1 ? 's' : '')) : false; + days > 0 ? between.push('
' + days + ' day' + (days > 1 ? 's' : '') + '
') : false; + hours > 0 ? between.push('
' + hours + ' hour' + (hours > 1 ? 's' : '') + '
') : false; + minutes > 0 ? between.push('
' + minutes + ' minute' + (minutes > 1 ? 's' : '') + '
') : false; + seconds > 0 ? between.push('
' + seconds + ' second' + (seconds > 1 ? 's' : '') + '
') : false; return between.join(' '); }; @@ -18453,10 +18462,10 @@ */ function getUnboundedScrollPosition(scrollable) { - if (scrollable === window) { + if (scrollable.Window && scrollable instanceof scrollable.Window) { return { - x: window.pageXOffset || document.documentElement.scrollLeft, - y: window.pageYOffset || document.documentElement.scrollTop + x: scrollable.pageXOffset || scrollable.document.documentElement.scrollLeft, + y: scrollable.pageYOffset || scrollable.document.documentElement.scrollTop }; } return { @@ -19205,7 +19214,9 @@ * @return {boolean} Whether or not the object is a DOM node. */ function isNode(object) { - return !!(object && (typeof Node === 'function' ? object instanceof Node : typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string')); + var doc = object ? object.ownerDocument || object : document; + var defaultView = doc.defaultView || window; + return !!(object && (typeof defaultView.Node === 'function' ? object instanceof defaultView.Node : typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string')); } module.exports = isNode; @@ -19235,15 +19246,19 @@ * * The activeElement will be null only if the document or document body is not * yet defined. + * + * @param {?DOMDocument} doc Defaults to current document. + * @return {?DOMElement} */ - function getActiveElement() /*?DOMElement*/{ - if (typeof document === 'undefined') { + function getActiveElement(doc) /*?DOMElement*/{ + doc = doc || (typeof document !== 'undefined' ? document : undefined); + if (typeof doc === 'undefined') { return null; } try { - return document.activeElement || document.body; + return doc.activeElement || doc.body; } catch (e) { - return document.body; + return doc.body; } } diff --git a/lib/DateBetween.js b/lib/DateBetween.js index adc0332..e359af2 100644 --- a/lib/DateBetween.js +++ b/lib/DateBetween.js @@ -18,10 +18,10 @@ var DateBetween = function DateBetween(startDate, endDate) { var between = []; - days > 0 ? between.push(days + ' day' + (days > 1 ? 's' : '')) : false; - hours > 0 ? between.push(hours + ' hour' + (hours > 1 ? 's' : '')) : false; - minutes > 0 ? between.push(minutes + ' minute' + (minutes > 1 ? 's' : '')) : false; - seconds > 0 ? between.push(seconds + ' second' + (seconds > 1 ? 's' : '')) : false; + days > 0 ? between.push('
' + days + ' day' + (days > 1 ? 's' : '') + '
') : false; + hours > 0 ? between.push('
' + hours + ' hour' + (hours > 1 ? 's' : '') + '
') : false; + minutes > 0 ? between.push('
' + minutes + ' minute' + (minutes > 1 ? 's' : '') + '
') : false; + seconds > 0 ? between.push('
' + seconds + ' second' + (seconds > 1 ? 's' : '') + '
') : false; return between.join(' '); }; From 2501e89c9f9775975732a853cbceba1bf3822d9b Mon Sep 17 00:00:00 2001 From: Salman Hasrat Date: Thu, 30 Mar 2017 16:57:39 +0400 Subject: [PATCH 6/8] bumped version number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c9f7f84..65160c3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-count-down", - "version": "1.1.0", + "version": "1.2.0", "description": "a simple count down clock component", "main": "lib/Countdown.js", "repository": { From 913b64803bb253b13a073695a3fae5cc926df45a Mon Sep 17 00:00:00 2001 From: Salman Hasrat Khan Date: Mon, 3 Apr 2017 11:55:38 +0400 Subject: [PATCH 7/8] Added stage-2 to babelrc --- .babelrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.babelrc b/.babelrc index 32d6bcf..3c168bf 100644 --- a/.babelrc +++ b/.babelrc @@ -1 +1 @@ -{ "presets": ["es2015", "react", "stage-0"] } +{ "presets": ["es2015", "react", "stage-2"] } From 72c52791eaacde792f8f8d34183991fc06dc4d66 Mon Sep 17 00:00:00 2001 From: Salman Hasrat Khan Date: Mon, 3 Apr 2017 11:56:13 +0400 Subject: [PATCH 8/8] New Version number for stage-2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 65160c3..daaaafa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-count-down", - "version": "1.2.0", + "version": "1.2.1", "description": "a simple count down clock component", "main": "lib/Countdown.js", "repository": {