import { FC } from 'react'; import { resolveColor } from '@/utils/colorPalette'; import { cn } from '@/utils/styling'; import { RatingProps } from '.'; export const Rating: FC = ({ rating, showReviewLabel, starsColor, activeStarsColor }) => { const inactive = resolveColor(starsColor, 'fill'); const active = resolveColor(activeStarsColor, 'fill'); return (
{Array.from({ length: 5 }, (_, starIndex) => { const selectedRating = rating && rating >= starIndex + 1; const star = selectedRating ? active : inactive; return ( ); })} {showReviewLabel &&
({rating}/5)
}
); };