import { fmt } from '../../utils/units.js'; import type { VFPoint } from '../../types.js'; interface Props { point: VFPoint; /** Pending delta in kHz (from store), if any */ pendingDeltaKhz?: number; /** True if this point is being held up by monotonicity enforcement */ isClamped?: boolean; } /** * HTML tooltip rendered as an absolutely-positioned overlay on top of the * SVG so it's never clipped by the SVG viewport. */ export function CurveTooltip({ point, pendingDeltaKhz, isClamped }: Props) { const hasPending = pendingDeltaKhz !== undefined; const pendingMhz = hasPending ? pendingDeltaKhz! / 1000 : 0; const deltaChange = hasPending ? pendingDeltaKhz! - point.delta_khz : 0; const pendingEffMhz = hasPending ? point.freq_mhz + deltaChange / 1000 : null; return (
Point {point.index}
Volt: {fmt.mv(point.volt_mv, 1)}
Offset: 0 ? 'text-emerald-400' : point.delta_khz < 0 ? 'text-red-400' : 'text-zinc-400'}> {point.delta_khz > 0 ? '+' : ''}{fmt.mhz(point.delta_mhz, 1)}
Eff.: {fmt.mhz(point.freq_mhz, 0)} {isClamped && ⇡}
{isClamped && (
Clamped by lower-voltage point
)} {hasPending && ( <>
Pending: 0 ? 'text-cyan-400' : pendingMhz < 0 ? 'text-orange-400' : 'text-zinc-400'}> {pendingMhz > 0 ? '+' : ''}{pendingMhz.toFixed(1)} MHz
→ Eff.: {fmt.mhz(pendingEffMhz, 0)}
)}
); }