Skip to content

Commit 5a57144

Browse files
soorajbalaJeevan-Kishore
authored andcommitted
fix(review-rating): canShowEmptyRating option added (#71)
* fix(review-rating): canShowEmptyRating option added * fix(review-rating): canShowEmptyRating option added
1 parent 0bc3914 commit 5a57144

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/components/review-rating/review-rating.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import PropTypes from "prop-types";
44

55
const ReviewRating = ({
66
value,
7+
canShowEmptyRating = false,
78
size=20,
89
activeColor="gold",
910
inActiveColor="gray",
@@ -15,7 +16,9 @@ const ReviewRating = ({
1516
halfActiveSymbol=null
1617
}) => {
1718

18-
if(value < 0.1) return null;
19+
20+
if(!canShowEmptyRating && value < 0.1) return null;
21+
1922

2023
const activeComponent = index => activeSymbol ? React.cloneElement(activeSymbol, {size, activeColor, inActiveColor,className:`${className}-symbol active`, key: `review-${index}`}) : <StarIcon size={size} foregroundColor={activeColor} backgroundColor={activeColor} className={`${className}-symbol active`} key={`review-${index}`} data-test-id = "star-icon"/>;
2124

@@ -50,6 +53,8 @@ export { ReviewRating };
5053
ReviewRating.propTypes = {
5154
// Rating value to be displayed
5255
value: PropTypes.number.isRequired,
56+
// Can show Empty rating
57+
canShowEmptyRating: PropTypes.bool,
5358
// Size of the icon (star)
5459
size: PropTypes.number,
5560
// Active color

0 commit comments

Comments
 (0)