/** * External dependencies */ import classNames from 'classnames'; import { __, sprintf } from '@wordpress/i18n'; /** * Internal dependencies */ const Rating = ( { className, rating, ratedProductsCount, }: RatingProps ): JSX.Element => { const ratingClassName = classNames( 'wc-block-components-product-rating', className ); const starStyle = { width: ( rating / 5 ) * 100 + '%', }; const ratingText = sprintf( /* translators: %f is referring to the average rating value */ __( 'Rated %f out of 5', 'woo-gutenberg-products-block' ), rating ); const ratingHTML = { __html: sprintf( /* translators: %s is the rating value wrapped in HTML strong tags. */ __( 'Rated %s out of 5', 'woo-gutenberg-products-block' ), sprintf( '%f', rating ) ), }; return (
{ ratedProductsCount !== null ? ( ({ ratedProductsCount }) ) : null }
); }; export type RatingValues = 0 | 1 | 2 | 3 | 4 | 5; interface RatingProps { className?: string; rating: RatingValues; ratedProductsCount?: number | null; } export default Rating;