// ----------------------------------------------------------------------------- // Rent-Ka — Rental listings aggregator (Canada, outside Québec) // Author: Simon-Pierre Boucher — contact@spboucher.ai // components/KaScoreBadge.tsx: KA Score badges (Groupe-KA design system). // · compact: "KA 78" on listing cards and mini-sheets; // · circle: circular gauge of a sub-score on the detail page. // ----------------------------------------------------------------------------- import { kaLabel } from "../api"; /** Tint class per bracket (styles in styles.css). */ export function kaTint(score: number | null | undefined): string { if (score == null) return "na"; if (score >= 70) return "haut"; if (score >= 55) return "bon"; if (score >= 40) return "moyen"; return "bas"; } /** Compact "KA 78" badge — list cards, carousel, mini-sheets. */ export default function KaScoreBadge({ score, title }: { score: number | null | undefined; title?: string; }) { if (score == null) return null; return ( KA {Math.round(score)} ); } /** Circular gauge of a sub-score (listing detail, methodology page). */ export function KaScoreCircle({ score, nom, note }: { score: number | null; nom: string; note?: string | null; }) { const r = 26; const c = 2 * Math.PI * r; const part = score == null ? 0 : Math.max(0, Math.min(1, score / 100)); return (
{nom}
{score == null ? (note ?? "Insufficient data") : kaLabel(score)}
); }