react-stars
Advanced tools
Comparing version 2.0.5 to 2.0.6
@@ -44,4 +44,20 @@ 'use strict'; | ||
// set defaults | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(ReactStars).call(this, props)); | ||
props = Object.assign({}, props); | ||
if (typeof props.edit === 'undefined') { | ||
props.edit = true; | ||
} else { | ||
props.edit = false; | ||
} | ||
if (typeof props.half === 'undefined') { | ||
props.half = true; | ||
} else { | ||
props.half = false; | ||
} | ||
_this.state = { | ||
@@ -63,19 +79,7 @@ value: props.value || 0, | ||
// color of an active star | ||
color2: props.color2 || '#ffd700' | ||
color2: props.color2 || '#ffd700', | ||
half: props.half, | ||
edit: props.edit | ||
}; | ||
// validation of props that are true / false | ||
if (typeof props.edit === 'undefined') { | ||
_this.state.config.edit = true; | ||
} else { | ||
_this.state.config.edit = props.edit; | ||
} | ||
if (typeof props.half === 'undefined') { | ||
_this.state.config.half = true; | ||
} else { | ||
_this.state.config.half = props.half; | ||
} | ||
return _this; | ||
@@ -92,2 +96,14 @@ } | ||
}, { | ||
key: 'componentWillReceiveProps', | ||
value: function componentWillReceiveProps(props) { | ||
this.setState({ | ||
stars: this.getStars(props.value), | ||
value: props.value, | ||
halfStar: { | ||
at: Math.floor(props.value), | ||
hidden: this.state.config.half && props.value % 1 < 0.5 | ||
} | ||
}); | ||
} | ||
}, { | ||
key: 'isDecimal', | ||
@@ -94,0 +110,0 @@ value: function isDecimal(value) { |
{ | ||
"name": "react-stars", | ||
"version": "2.0.5", | ||
"version": "2.0.6", | ||
"description": "Simple star rating component for your React projects", | ||
@@ -5,0 +5,0 @@ "main": "dist/react-stars.js", |
@@ -53,1 +53,2 @@ # react-stars :star: | ||
* Make better docs | ||
* Better state management |
@@ -36,2 +36,18 @@ import React, { Component } from 'react' | ||
// set defaults | ||
props = Object.assign({}, props) | ||
if(typeof props.edit === 'undefined') { | ||
props.edit = true | ||
} else { | ||
props.edit = false | ||
} | ||
if(typeof props.half === 'undefined') { | ||
props.half = true | ||
} else { | ||
props.half = false | ||
} | ||
this.state = { | ||
@@ -53,19 +69,7 @@ value: props.value || 0, | ||
// color of an active star | ||
color2: props.color2 || '#ffd700' | ||
color2: props.color2 || '#ffd700', | ||
half: props.half, | ||
edit: props.edit | ||
} | ||
// validation of props that are true / false | ||
if(typeof props.edit === 'undefined') { | ||
this.state.config.edit = true | ||
} else { | ||
this.state.config.edit = props.edit | ||
} | ||
if(typeof props.half === 'undefined') { | ||
this.state.config.half = true | ||
} else { | ||
this.state.config.half = props.half | ||
} | ||
} | ||
@@ -79,2 +83,13 @@ | ||
componentWillReceiveProps(props) { | ||
this.setState({ | ||
stars: this.getStars(props.value), | ||
value: props.value, | ||
halfStar: { | ||
at: Math.floor(props.value), | ||
hidden: this.state.config.half && props.value % 1 < 0.5 | ||
} | ||
}) | ||
} | ||
isDecimal(value) { | ||
@@ -81,0 +96,0 @@ return value % 1 !== 0 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15965
438
54