import { useState } from 'react'; import { Info } from 'lucide-react'; import { IconButton } from '@/components/ui/icon-button'; import { cn } from '@/lib/utils'; import { clampScore, getScoreStrokeColor } from '@/lib/score-colors'; import { __, sprintf } from '../lib/i18n'; const scoreInfoIconButtonClass = 'h-auto w-auto min-h-0 min-w-0 border-0 bg-transparent p-0 shadow-none hover:bg-transparent'; interface ScoreGaugeProps { score: number; label?: string; size?: 'hero' | 'compact'; infoText?: string; className?: string; } export function ScoreGauge({ score, label, size = 'compact', infoText, className, }: ScoreGaugeProps) { const [showTooltip, setShowTooltip] = useState(false); const clamped = clampScore(score); const stroke = getScoreStrokeColor(clamped); const isHero = size === 'hero'; const svgSize = isHero ? 120 : 64; const radius = isHero ? 46 : 26; const strokeWidth = isHero ? 10 : 6; const circumference = 2 * Math.PI * radius; const filled = (clamped / 100) * circumference; const center = svgSize / 2; return (
{clamped} {isHero && ( / 100 )}
{label && (
{label} {infoText && (
setShowTooltip(true)} onMouseLeave={() => setShowTooltip(false)} onFocus={() => setShowTooltip(true)} onBlur={() => setShowTooltip(false)} onClick={() => setShowTooltip((v) => !v)} aria-label={infoText} > {showTooltip && (
{infoText}
)}
)}
)}
); } interface ScoreBarProps { label: string; score: number; infoText?: string; } export function ScoreBar({ label, score, infoText }: ScoreBarProps) { const [showTooltip, setShowTooltip] = useState(false); const clamped = clampScore(score); const color = getScoreStrokeColor(clamped); return (
{label} {infoText && (
setShowTooltip(true)} onMouseLeave={() => setShowTooltip(false)} onFocus={() => setShowTooltip(true)} onBlur={() => setShowTooltip(false)} aria-label={infoText} > {showTooltip && (
{infoText}
)}
)}
{clamped}
); } export function ScoreScaleLegend({ className }: { className?: string }) { return (
{__('Score scale', 'llmagnet-llm-txt-generator')}
); }