Skip to content

Commit

Permalink
GH-54 refactor(stars): re-use star props
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo committed Jul 14, 2020
1 parent 0355445 commit aca2403
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions components/blog-post/Recipe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ const Recipe: React.FC<RecipeProps> = ({ recipe, className }) => {
className="flex"
>
{[1, 2, 3, 4, 5].map((i) => {
const starClassName = 'w-6 h-6 xl:w-8 xl:h-8';
if (reviewsState.data.ratingValue >= i) {
return <StarFullIcon className={starClassName} />;
} else if (reviewsState.data.ratingValue >= i - 0.5) {
return <StarHalfIcon className={starClassName} />;
} else {
return <StarEmptyIcon className={starClassName} />;
}
const StarIcon =
reviewsState.data.ratingValue >= i
? StarFullIcon
: reviewsState.data.ratingValue >= i - 0.5
? StarHalfIcon
: StarEmptyIcon;

return <StarIcon key={`star-icon-${i}`} className="w-6 h-6 xl:w-8 xl:h-8" />;
})}
</span>
<span className="type-footnote italic">
Expand Down

0 comments on commit aca2403

Please sign in to comment.