2026-03-28 14:59:40 +00:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import { METRIC_EXPLANATIONS } from '@/lib/metrics';
|
2026-07-22 15:37:33 +01:00
|
|
|
import { InfoPopover } from './InfoPopover';
|
2026-03-28 14:59:40 +00:00
|
|
|
|
|
|
|
|
interface MetricTooltipProps {
|
|
|
|
|
metricKey?: string;
|
|
|
|
|
label?: string;
|
|
|
|
|
plain?: string;
|
|
|
|
|
detail?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function MetricTooltip({ metricKey, label, plain, detail }: MetricTooltipProps) {
|
|
|
|
|
const explanation = metricKey ? METRIC_EXPLANATIONS[metricKey] : undefined;
|
2026-07-22 15:37:33 +01:00
|
|
|
const resolvedLabel = label ?? explanation?.label;
|
2026-03-28 14:59:40 +00:00
|
|
|
return (
|
2026-07-22 15:37:33 +01:00
|
|
|
<InfoPopover
|
|
|
|
|
label={resolvedLabel}
|
|
|
|
|
plain={plain ?? explanation?.plain}
|
|
|
|
|
detail={detail ?? explanation?.detail}
|
|
|
|
|
ariaLabel={resolvedLabel ? `What does ${resolvedLabel} mean?` : undefined}
|
|
|
|
|
/>
|
2026-03-28 14:59:40 +00:00
|
|
|
);
|
|
|
|
|
}
|