spb/market-atlas
Public
TypeScript 96.7%
SQL 1.6%
CSS 0.8%
JavaScript 0.5%
1import { cx } from "@/lib/format";23/** Sources + confidence meter. Confidence is Market Atlas' consensus confidence (0–1), never a market prediction. */4export function ConfidenceMeter({ confidence, sources, proxies, validators, className, compact }: { confidence: number | null | undefined; sources: number | null | undefined; proxies?: number | null; validators?: number | null; className?: string; compact?: boolean }) {5 const c = confidence ?? 0;6 const pct = Math.round(c * 100);7 const tone = c >= 0.85 ? "bg-positive" : c >= 0.6 ? "bg-accent" : c > 0 ? "bg-warning" : "bg-stale";8 const extra = (proxies ?? 0) + (validators ?? 0);9 const extraTitle = extra ? ` · confirmed by ${proxies ?? 0} prox${proxies === 1 ? "y" : "ies"} and ${validators ?? 0} validator${validators === 1 ? "" : "s"}` : "";10 return (11 <span className={cx("inline-flex items-center gap-1.5 whitespace-nowrap text-xs text-ink-2", className)} title={`Consensus confidence ${pct}% · ${sources ?? 0} independent source${sources === 1 ? "" : "s"}${extraTitle}`}>12 <span className="inline-block h-1.5 w-10 overflow-hidden rounded-full bg-surface-3">13 <span className={cx("block h-full rounded-full", tone)} style={{ width: `${pct}%` }} />14 </span>15 {!compact && (16 <span className="mono tnum">17 {pct}% · {sources ?? 0} src18 {extra > 0 && <span className="text-accent" aria-label={`plus ${extra} confirmations`}>{`+${extra}`}</span>}19 </span>20 )}21 </span>22 );23}24