Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-stars

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-stars - npm Package Compare versions

Comparing version 2.0.5 to 2.0.6

46

dist/react-stars.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc