Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove fillId property #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions build/star-ratings.js
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ var StarRatings = function (_React$Component) {

return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = StarRatings.__proto__ || Object.getPrototypeOf(StarRatings)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
highestStarHovered: -Infinity
}, _this.fillId = 'starGrad' + Math.random().toFixed(15).slice(2), _this.hoverOverStar = function (starRating) {
}, _this.hoverOverStar = function (starRating) {
return function () {
_this.setState({
highestStarHovered: starRating
@@ -90,7 +90,7 @@ var StarRatings = function (_React$Component) {
null,
_react2.default.createElement(
'linearGradient',
{ id: this.fillId, x1: '0%', y1: '0%', x2: '100%', y2: '0%' },
{ x1: '0%', y1: '0%', x2: '100%', y2: '0%' },
_react2.default.createElement('stop', { offset: '0%', className: 'stop-color-first', style: this.stopColorStyle(starRatedColor) }),
_react2.default.createElement('stop', { offset: this.offsetValue, className: 'stop-color-first', style: this.stopColorStyle(starRatedColor) }),
_react2.default.createElement('stop', { offset: this.offsetValue, className: 'stop-color-final', style: this.stopColorStyle(starEmptyColor) }),
@@ -197,7 +197,6 @@ var StarRatings = function (_React$Component) {

return _react2.default.createElement(_star2.default, {
key: starRating,
fillId: _this2.fillId,
changeRating: changeRating ? function () {
return changeRating(starRating, name);
} : null,
4 changes: 1 addition & 3 deletions build/star.js
Original file line number Diff line number Diff line change
@@ -119,15 +119,14 @@ var Star = function (_React$Component) {
starRatedColor = _props4.starRatedColor,
starHoverColor = _props4.starHoverColor,
gradientPathName = _props4.gradientPathName,
fillId = _props4.fillId,
ignoreInlineStyles = _props4.ignoreInlineStyles;


var fill = void 0;
if (hoverMode) {
if (isHovered) fill = starHoverColor;else fill = starEmptyColor;
} else {
if (isPartiallyFullStar) fill = 'url(\'' + gradientPathName + '#' + fillId + '\')';else if (isStarred) fill = starRatedColor;else fill = starEmptyColor;
if (isPartiallyFullStar) fill = 'url(\'' + gradientPathName + '\')';else if (isStarred) fill = starRatedColor;else fill = starEmptyColor;
}

var pathStyle = {
@@ -164,7 +163,6 @@ var Star = function (_React$Component) {
}(_react2.default.Component);

Star.propTypes = {
fillId: _propTypes2.default.string.isRequired,
changeRating: _propTypes2.default.func,
hoverOverStar: _propTypes2.default.func,
unHoverOverStar: _propTypes2.default.func,
5,513 changes: 3,478 additions & 2,035 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/star-ratings.js
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@ class StarRatings extends React.Component {
state = {
highestStarHovered: -Infinity
}
fillId = `starGrad${Math.random().toFixed(15).slice(2)}`;

get starRatingsStyle() {
const starRatingsStyle = {
@@ -120,7 +119,6 @@ class StarRatings extends React.Component {
return (
<Star
key={starRating}
fillId={this.fillId}
changeRating={changeRating ? () => changeRating(starRating, name) : null}
hoverOverStar={changeRating ? this.hoverOverStar(starRating) : null}
unHoverOverStar={changeRating ? this.unHoverOverStar : null}
@@ -162,7 +160,7 @@ class StarRatings extends React.Component {
style={this.starGradientStyle}
>
<defs>
<linearGradient id={this.fillId} x1="0%" y1="0%" x2="100%" y2="0%">
<linearGradient x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" className="stop-color-first" style={this.stopColorStyle(starRatedColor)} />
<stop offset={this.offsetValue} className="stop-color-first" style={this.stopColorStyle(starRatedColor)} />
<stop offset={this.offsetValue} className="stop-color-final" style={this.stopColorStyle(starEmptyColor)} />
4 changes: 1 addition & 3 deletions src/star.js
Original file line number Diff line number Diff line change
@@ -50,7 +50,6 @@ class Star extends React.Component {
starRatedColor,
starHoverColor,
gradientPathName,
fillId,
ignoreInlineStyles
} = this.props;

@@ -59,7 +58,7 @@ class Star extends React.Component {
if (isHovered) fill = starHoverColor;
else fill = starEmptyColor;
} else {
if (isPartiallyFullStar) fill = `url('${gradientPathName}#${fillId}')`;
if (isPartiallyFullStar) fill = `url('${gradientPathName}')`;
else if (isStarred) fill = starRatedColor;
else fill = starEmptyColor;
}
@@ -125,7 +124,6 @@ class Star extends React.Component {
}

Star.propTypes = {
fillId: PropTypes.string.isRequired,
changeRating: PropTypes.func,
hoverOverStar: PropTypes.func,
unHoverOverStar: PropTypes.func,
4 changes: 1 addition & 3 deletions test/src/star-ratings.js
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@ class StarRatings extends React.Component {
state = {
highestStarHovered: -Infinity
}
fillId = `starGrad${Math.random().toFixed(15).slice(2)}`;

get starRatingsStyle() {
const starRatingsStyle = {
@@ -120,7 +119,6 @@ class StarRatings extends React.Component {
return (
<Star
key={starRating}
fillId={this.fillId}
changeRating={changeRating ? () => changeRating(starRating, name) : null}
hoverOverStar={changeRating ? this.hoverOverStar(starRating) : null}
unHoverOverStar={changeRating ? this.unHoverOverStar : null}
@@ -162,7 +160,7 @@ class StarRatings extends React.Component {
style={this.starGradientStyle}
>
<defs>
<linearGradient id={this.fillId} x1="0%" y1="0%" x2="100%" y2="0%">
<linearGradient x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" className="stop-color-first" style={this.stopColorStyle(starRatedColor)} />
<stop offset={this.offsetValue} className="stop-color-first" style={this.stopColorStyle(starRatedColor)} />
<stop offset={this.offsetValue} className="stop-color-final" style={this.stopColorStyle(starEmptyColor)} />
4 changes: 1 addition & 3 deletions test/src/star.js
Original file line number Diff line number Diff line change
@@ -50,7 +50,6 @@ class Star extends React.Component {
starRatedColor,
starHoverColor,
gradientPathName,
fillId,
ignoreInlineStyles
} = this.props;

@@ -59,7 +58,7 @@ class Star extends React.Component {
if (isHovered) fill = starHoverColor;
else fill = starEmptyColor;
} else {
if (isPartiallyFullStar) fill = `url('${gradientPathName}#${fillId}')`;
if (isPartiallyFullStar) fill = `url('${gradientPathName}')`;
else if (isStarred) fill = starRatedColor;
else fill = starEmptyColor;
}
@@ -125,7 +124,6 @@ class Star extends React.Component {
}

Star.propTypes = {
fillId: PropTypes.string.isRequired,
changeRating: PropTypes.func,
hoverOverStar: PropTypes.func,
unHoverOverStar: PropTypes.func,