'use client' import React from 'react' interface StarRatingProps { stars: number // 0-3 total?: number // total stars earned (shown as badge) size?: 'sm' | 'md' | 'lg' animated?: boolean showLabel?: boolean } const sizeMap = { sm: 'text-lg', md: 'text-2xl', lg: 'text-4xl' } export function StarRating({ stars, total, size = 'md', animated = false, showLabel = false }: StarRatingProps) { return (
{[1, 2, 3].map((i) => ( {i <= stars ? '\u2B50' : '\u2606'} ))} {total != null && showLabel && ( {total} )}
) } /** Calculate stars from accuracy percentage */ export function accuracyToStars(correct: number, total: number): number { if (total === 0) return 0 const pct = (correct / total) * 100 if (pct >= 100) return 3 if (pct >= 70) return 2 return 1 }