import React from 'react'; interface StarRatingProps { rating: number; size?: 'small' | 'medium' | 'large'; className?: string; } const StarRating: React.FC = ({ rating, size = 'small', className = '' }) => { const getSizeStyle = () => { switch (size) { case 'large': return { fontSize: '1.5rem' }; case 'medium': return { fontSize: '1.2rem' }; case 'small': default: return { fontSize: '1rem' }; } }; const renderStars = () => { const stars = []; const fullStars = Math.floor(rating); const hasHalfStar = rating % 1 !== 0; // Render filled stars for (let i = 0; i < fullStars; i++) { stars.push( ); } // Render half star if needed if (hasHalfStar) { stars.push( ); } // Render empty stars const emptyStars = 5 - Math.ceil(rating); for (let i = 0; i < emptyStars; i++) { stars.push( ); } return stars; }; return (
{renderStars()}
); }; export default StarRating;