SPB Git

Repository Public

charts.tsx 23.2 KB 569 lines tsx

1// Graphiques SVG et HTML faits main pour les pages marché, taux et vrai prix2// (aucune bibliothèque). Série principale à la couleur de la marque, contexte en3// pierre, accent réservé à la sélection. Axes fins, chiffres tabulaires, lecture4// au survol et au toucher. Chaque tracé se dessine une fois, à l'entrée dans la5// fenêtre ; les transitions sont posées en ligne (aucune classe CSS propre au6// socle n'est requise) et s'effacent quand les animations sont réduites.78import { useMemo, useRef, useState, type CSSProperties, type ReactNode } from "react";9import { cn } from "@/lib/cn";10import { fmtInt } from "@/lib/format";11import { useMotionAllowed, useSeenOnce } from "@/lib/motion";1213const EASE_OUT = "cubic-bezier(0.2, 0.7, 0.2, 1)";14const EASE_DOOR = "cubic-bezier(0.32, 0.08, 0.14, 1)";15const STONE = "color-mix(in srgb, var(--ink-3) 46%, transparent)";1617/** Couleurs des séries, dans un ordre fixe : la couleur suit la série, jamais son rang. */18export const SERIES_COLORS = ["var(--brand)", "var(--accent)", "var(--ink-2)", "var(--high)"] as const;1920/** Entrée dans la fenêtre + styles de tracé. */21function useDraw<T extends Element>() {22  const [ref, seen] = useSeenOnce<T>();23  const ok = useMotionAllowed();24  const bar = (i = 0): CSSProperties => ({25    transformOrigin: "0 50%",26    transform: seen ? "none" : "scaleX(0)",27    transition: ok ? `transform 0.7s ${EASE_OUT} ${Math.min(i, 14) * 40}ms` : "none",28  });29  const col = (i = 0, step = 18): CSSProperties => ({30    transformOrigin: "50% 100%",31    transform: seen ? "none" : "scaleY(0)",32    transition: ok ? `transform 0.6s ${EASE_OUT} ${Math.min(i * step, 700)}ms` : "none",33  });34  const fade = (delay = 250): CSSProperties => ({ opacity: seen ? 1 : 0, transition: ok ? `opacity 0.5s ease ${delay}ms` : "none" });35  // une courbe se révèle de gauche à droite (découpe du calque : indépendant de l'étirement du SVG)36  const reveal = (delay = 0): CSSProperties => ({37    clipPath: seen ? "inset(-8px 0% -8px 0)" : "inset(-8px 100% -8px 0)",38    transition: ok ? `clip-path 1.1s ${EASE_DOOR} ${delay}ms` : "none",39  });40  return { ref, seen, bar, col, fade, reveal };41}4243export const shortDate = (iso: string) => {44  const [y, m, d] = iso.split("-").map(Number);45  if (!y || !m) return iso;46  return new Date(y, m - 1, d || 1).toLocaleDateString("fr-CA", d ? { day: "numeric", month: "short" } : { month: "short", year: "2-digit" });47};4849// --- Barres horizontales classées ------------------------------------------------50export function BarList({51  items,52  format = fmtInt,53  color = "var(--brand)",54  max,55  className,56}: {57  items: { key: string; label: ReactNode; value: number; hint?: ReactNode }[];58  format?: (n: number) => string;59  color?: string;60  max?: number;61  className?: string;62}) {63  const top = max ?? Math.max(1, ...items.map((i) => i.value));64  const d = useDraw<HTMLUListElement>();65  return (66    <ul ref={d.ref} className={cn("space-y-2.5", className)}>67      {items.map((it, i) => (68        <li key={it.key}>69          <div className="flex items-baseline justify-between gap-3 text-sm">70            <span className="min-w-0 truncate text-ink">{it.label}</span>71            <span className="shrink-0 text-ink-3">72              {it.hint && <span className="mr-2.5 text-xs">{it.hint}</span>}73              <span className="num font-medium text-ink">{format(it.value)}</span>74            </span>75          </div>76          <div className="mt-1.5 h-1 overflow-hidden rounded-full bg-surface-3">77            <div className="h-full rounded-full" style={{ width: `${Math.max(1.5, (it.value / top) * 100)}%`, background: color, ...d.bar(i) }} />78          </div>79        </li>80      ))}81    </ul>82  );83}8485// --- Histogramme vertical ---------------------------------------------------------86export function Histogram({87  bins,88  marker,89  height = 220,90  unit = "inscriptions",91  every = 2,92}: {93  bins: { label: string; short: string; count: number }[];94  /** indice de la classe à mettre en évidence (ex. celle de la médiane) */95  marker?: number;96  height?: number;97  unit?: string;98  /** sur mobile, une étiquette sur `every` */99  every?: number;100}) {101  const [hover, setHover] = useState<number | null>(null);102  const max = Math.max(1, ...bins.map((b) => b.count));103  const active = hover ?? marker ?? null;104  const total = bins.reduce((s, b) => s + b.count, 0) || 1;105  const d = useDraw<HTMLDivElement>();106  return (107    <div ref={d.ref}>108      <div className="num mb-3 min-h-10 text-sm text-ink-2">109        {active != null && bins[active] ? (110          <>111            <span className="text-[1.35rem] font-semibold text-ink">{fmtInt(bins[active].count)}</span> {unit} · {bins[active].label}112            <span className="ml-2 text-ink-3">({Math.round((bins[active].count / total) * 100)} %)</span>113          </>114        ) : null}115      </div>116      <div className="flex items-end gap-[3px] border-b border-line-2 sm:gap-1.5" style={{ height }} onMouseLeave={() => setHover(null)}>117        {bins.map((b, i) => (118          <button119            key={b.label}120            type="button"121            aria-label={`${b.label} : ${fmtInt(b.count)} ${unit}`}122            onMouseEnter={() => setHover(i)}123            onFocus={() => setHover(i)}124            onBlur={() => setHover(null)}125            onPointerDown={() => setHover(i)}126            className="relative flex h-full min-w-0 flex-1 cursor-default items-end outline-none focus-visible:ring-2 focus-visible:ring-brand"127          >128            <span129              className="w-full rounded-t-[3px]"130              style={{131                height: `${Math.max(1.5, (b.count / max) * 100)}%`,132                background: i === hover ? "var(--accent)" : i === marker ? "var(--brand)" : STONE,133                ...d.col(i),134              }}135            />136          </button>137        ))}138      </div>139      <div className="mt-2 flex gap-[3px] sm:gap-1.5">140        {bins.map((b, i) => (141          <span key={b.label} className={cn("num min-w-0 flex-1 text-center text-[0.62rem] leading-tight text-ink-3", i % every !== 0 && "max-sm:invisible")}>142            {b.short}143          </span>144        ))}145      </div>146    </div>147  );148}149150// --- Colonnes dans le temps (comptes par jour) -------------------------------------151export function Columns({152  points,153  format = fmtInt,154  height = 190,155  label,156  color = "var(--brand)",157}: {158  points: { t: string; v: number }[];159  format?: (n: number) => string;160  height?: number;161  label: string;162  color?: string;163}) {164  const [hover, setHover] = useState<number | null>(null);165  const box = useRef<HTMLDivElement | null>(null);166  const d = useDraw<HTMLDivElement>();167  const max = Math.max(1, ...points.map((p) => p.v));168  if (points.length < 2) return <Empty height={height} />;169  const onMove = (e: React.PointerEvent) => {170    const r = box.current?.getBoundingClientRect();171    if (!r) return;172    setHover(Math.min(points.length - 1, Math.max(0, Math.floor(((e.clientX - r.left) / r.width) * points.length))));173  };174  const cur = points[hover ?? points.length - 1]!;175  const dense = points.length > 45;176  return (177    <div ref={d.ref}>178      <Readout value={format(cur.v)} when={shortDate(cur.t)} />179      <div180        ref={box}181        role="img"182        aria-label={label}183        className={cn("flex touch-pan-y items-end border-b border-line-2", dense ? "gap-px" : "gap-[3px]")}184        style={{ height }}185        onPointerMove={onMove}186        onPointerDown={onMove}187        onPointerLeave={() => setHover(null)}188      >189        {points.map((p, i) => (190          <span key={p.t} className="flex h-full min-w-0 flex-1 items-end">191            <span192              className={cn("w-full", dense ? "rounded-t-[1px]" : "rounded-t-[2px]")}193              style={{194                height: `${Math.max(1, (p.v / max) * 100)}%`,195                background: hover === i ? "var(--accent)" : color,196                opacity: hover == null || hover === i ? 1 : 0.55,197                ...d.col(i, dense ? 5 : 14),198              }}199            />200          </span>201        ))}202      </div>203      <AxisDates labels={[shortDate(points[0]!.t), shortDate(points[Math.floor(points.length / 2)]!.t), shortDate(points[points.length - 1]!.t)]} />204    </div>205  );206}207208function Empty({ height }: { height: number }) {209  return (210    <div className="grid place-items-center border-y border-line text-sm text-ink-3" style={{ height }}>211      Pas assez de données sur cette période.212    </div>213  );214}215216function Readout({ value, when, extra }: { value: ReactNode; when?: ReactNode; extra?: ReactNode }) {217  return (218    <div className="mb-2 flex min-h-8 flex-wrap items-baseline justify-between gap-x-4 gap-y-1">219      <div className="num">220        <span className="text-[1.35rem] font-semibold text-ink">{value}</span>221        {when && <span className="ml-2 text-sm text-ink-3">{when}</span>}222      </div>223      {extra}224    </div>225  );226}227228function AxisDates({ labels }: { labels: string[] }) {229  return (230    <div className="num mt-1.5 flex justify-between text-[0.68rem] text-ink-3">231      {labels.map((l, i) => (232        <span key={i}>{l}</span>233      ))}234    </div>235  );236}237238function LegendMark({ color, dashed }: { color: string; dashed?: boolean }) {239  return dashed ? (240    <span className="w-4 border-t-2 border-dashed" style={{ borderColor: color }} />241  ) : (242    <span className="h-0.5 w-4 rounded" style={{ background: color }} />243  );244}245246// --- Courbes (une ou plusieurs séries, droites ou en escalier) ------------------------247export interface LineSeries {248  key: string;249  label: string;250  color?: string;251  dashed?: boolean;252  /** tracé plus discret (contexte) */253  muted?: boolean;254  area?: boolean;255  points: { x: number; y: number }[];256}257258function niceTicks(min: number, max: number, count = 3): number[] {259  const span = max - min || 1;260  const raw = span / count;261  const mag = 10 ** Math.floor(Math.log10(raw));262  const step = [1, 2, 2.5, 5, 10].map((k) => k * mag).find((s) => s >= raw) ?? raw;263  const out: number[] = [];264  for (let v = Math.ceil(min / step) * step; v <= max + 1e-9; v += step) out.push(Number(v.toFixed(6)));265  return out;266}267268/**269 * Graphique à courbes : repère fin, graduations discrètes, lecture au survol270 * (filet vertical, valeur de chaque série). Une seule échelle verticale.271 */272export function Lines({273  series,274  step,275  height = 220,276  fmtX,277  fmtY = fmtInt,278  label,279  zero,280  xDomain,281  headline = true,282  idle,283}: {284  series: LineSeries[];285  step?: boolean;286  height?: number;287  fmtX: (x: number) => string;288  fmtY?: (y: number) => string;289  label: string;290  /** force l'axe à partir de zéro */291  zero?: boolean;292  xDomain?: [number, number];293  /** affiche la valeur de la première série en grand au-dessus */294  headline?: boolean;295  /** texte affiché au repos à la place de la dernière valeur */296  idle?: ReactNode;297}) {298  const box = useRef<HTMLDivElement | null>(null);299  const d = useDraw<HTMLDivElement>();300  const [hx, setHx] = useState<number | null>(null);301  const W = 720;302  const H = height;303  const pad = { l: 0, r: 0, t: 12, b: 6 };304  const live = series.filter((s) => s.points.length > 0);305306  const geo = useMemo(() => {307    const xs = live.flatMap((s) => s.points.map((p) => p.x));308    const ys = live.flatMap((s) => s.points.map((p) => p.y));309    const x0 = xDomain?.[0] ?? Math.min(...xs);310    const x1 = xDomain?.[1] ?? Math.max(...xs);311    let y0 = Math.min(...ys);312    let y1 = Math.max(...ys);313    const span = y1 - y0 || Math.abs(y1) * 0.1 || 1;314    y0 = zero ? 0 : y0 - span * 0.14;315    y1 = y1 + span * 0.12;316    const x = (v: number) => pad.l + ((v - x0) / (x1 - x0 || 1)) * (W - pad.l - pad.r);317    const y = (v: number) => pad.t + (1 - (v - y0) / (y1 - y0 || 1)) * (H - pad.t - pad.b);318    const path = (pts: { x: number; y: number }[]) => {319      let out = "";320      pts.forEach((p, i) => {321        if (i === 0) out = `M${x(p.x).toFixed(1)} ${y(p.y).toFixed(1)}`;322        else if (step) out += ` H${x(p.x).toFixed(1)} V${y(p.y).toFixed(1)}`;323        else out += ` L${x(p.x).toFixed(1)} ${y(p.y).toFixed(1)}`;324      });325      if (step && pts.length) out += ` H${x(x1).toFixed(1)}`;326      return out;327    };328    return { x, y, path, x0, x1, y0, y1, ticks: niceTicks(y0 + (y1 - y0) * 0.08, y1 - (y1 - y0) * 0.05, 3) };329    // eslint-disable-next-line react-hooks/exhaustive-deps330  }, [series, step, H, zero, xDomain?.[0], xDomain?.[1]]);331332  if (!live.length || live.every((s) => s.points.length < 2 && !step)) return <Empty height={height} />;333334  /** valeur d'une série à l'abscisse x (dernier point connu en escalier, plus proche sinon) */335  const at = (s: LineSeries, x: number): { x: number; y: number } | null => {336    if (!s.points.length) return null;337    if (step) {338      let cur: { x: number; y: number } | null = null;339      for (const p of s.points) if (p.x <= x) cur = p;340      return cur ? { x, y: cur.y } : null;341    }342    let best = s.points[0]!;343    for (const p of s.points) if (Math.abs(p.x - x) < Math.abs(best.x - x)) best = p;344    return best;345  };346347  const onMove = (e: React.PointerEvent) => {348    const r = box.current?.getBoundingClientRect();349    if (!r) return;350    const rel = Math.min(1, Math.max(0, (e.clientX - r.left) / r.width));351    const x = geo.x0 + rel * (geo.x1 - geo.x0);352    if (step) return setHx(x);353    // aimanté au point le plus proche de la première série354    const p = at(live[0]!, x);355    setHx(p ? p.x : x);356  };357358  const cx = hx ?? geo.x1;359  const reads = live.map((s) => ({ s, p: at(s, cx) }));360  const first = reads[0];361  const pctX = (x: number) => `${((geo.x(x) - pad.l) / (W - pad.l - pad.r)) * 100}%`;362  const pctY = (yv: number) => `${(geo.y(yv) / H) * 100}%`;363364  return (365    <div ref={d.ref}>366      {headline && idle != null && hx == null ? (367        <p className="mb-2 flex min-h-8 items-end text-[0.84rem] text-ink-3">{idle}</p>368      ) : headline ? (369        <Readout370          value={first?.p ? fmtY(first.p.y) : "—"}371          when={fmtX(first?.p?.x ?? cx)}372          extra={373            live.length > 1 ? (374              <ul className="flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-ink-2">375                {reads.map(({ s, p }, i) => (376                  <li key={s.key} className="inline-flex items-center gap-1.5">377                    <LegendMark color={s.color ?? SERIES_COLORS[i % SERIES_COLORS.length]!} dashed={s.dashed} />378                    {s.label}379                    {i > 0 && p && <span className="num font-medium text-ink">{fmtY(p.y)}</span>}380                  </li>381                ))}382              </ul>383            ) : undefined384          }385        />386      ) : null}387      <div ref={box} className="relative touch-pan-y" style={{ height }} role="img" aria-label={label} onPointerMove={onMove} onPointerDown={onMove} onPointerLeave={() => setHx(null)}>388        <svg viewBox={`0 0 ${W} ${H}`} preserveAspectRatio="none" className="absolute inset-0 size-full" aria-hidden>389          {geo.ticks.map((t) => (390            <line key={t} x1={0} x2={W} y1={geo.y(t)} y2={geo.y(t)} stroke="var(--line)" strokeWidth={1} vectorEffect="non-scaling-stroke" />391          ))}392        </svg>393        <div className="absolute inset-0" style={d.reveal()}>394          <svg viewBox={`0 0 ${W} ${H}`} preserveAspectRatio="none" className="absolute inset-0 size-full overflow-visible" aria-hidden>395            {live.map((s, i) => {396              const color = s.color ?? SERIES_COLORS[i % SERIES_COLORS.length]!;397              const dpath = geo.path(s.points);398              const last = s.points[s.points.length - 1]!;399              return (400                <g key={s.key}>401                  {s.area && (402                    <path d={`${dpath} ${step ? `V${H}` : `L${geo.x(last.x).toFixed(1)} ${H}`} L${geo.x(s.points[0]!.x).toFixed(1)} ${H} Z`} fill={color} fillOpacity={0.08} />403                  )}404                  <path405                    d={dpath}406                    fill="none"407                    stroke={color}408                    strokeOpacity={s.muted ? 0.6 : 1}409                    strokeWidth={s.muted || s.dashed ? 1.3 : 2}410                    strokeDasharray={s.dashed ? "4 4" : undefined}411                    strokeLinecap="round"412                    strokeLinejoin="round"413                    vectorEffect="non-scaling-stroke"414                  />415                </g>416              );417            })}418          </svg>419        </div>420        {hx != null && <span className="pointer-events-none absolute inset-y-0 w-px bg-accent" style={{ left: pctX(hx), top: pad.t }} />}421        {/* graduations et repères en HTML : le SVG est étiré, le texte ne doit pas l'être */}422        {geo.ticks.map((t) => (423          <span key={t} className="num pointer-events-none absolute left-0 -translate-y-full pb-0.5 text-[0.64rem] leading-none text-ink-3" style={{ top: pctY(t) }}>424            {fmtY(t)}425          </span>426        ))}427        {hx != null &&428          reads.map(({ s, p }, i) =>429            p && !s.muted ? (430              <span431                key={s.key}432                className="pointer-events-none absolute size-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-bg"433                style={{ left: pctX(hx), top: pctY(p.y), background: s.color ?? SERIES_COLORS[i % SERIES_COLORS.length] }}434              />435            ) : null,436          )}437      </div>438      <AxisDates labels={[fmtX(geo.x0), fmtX((geo.x0 + geo.x1) / 2), fmtX(geo.x1)]} />439    </div>440  );441}442443/** Série quotidienne (points { t, v }) : courbe pleine, période précédente en pointillé. */444export function TrendChart({445  points,446  compare,447  format = fmtInt,448  height = 220,449  label,450  area = true,451}: {452  points: { t: string; v: number }[];453  compare?: { t: string; v: number }[];454  format?: (n: number) => string;455  height?: number;456  label: string;457  area?: boolean;458}) {459  const series = useMemo<LineSeries[]>(() => {460    const out: LineSeries[] = [{ key: "p", label: "Période", area, points: points.map((p, i) => ({ x: i, y: p.v })) }];461    if (compare && compare.length === points.length)462      out.push({ key: "c", label: "Période précédente", dashed: true, muted: true, color: "var(--ink-3)", points: compare.map((p, i) => ({ x: i, y: p.v })) });463    return out;464  }, [points, compare, area]);465  if (points.length < 2) return <Empty height={height} />;466  return <Lines series={series} height={height} label={label} fmtY={format} fmtX={(x) => shortDate(points[Math.min(points.length - 1, Math.max(0, Math.round(x)))]!.t)} />;467}468469// --- Barre partagée (parts d'un tout, peu de catégories) -----------------------------470export function SplitBar({ items, label }: { items: { key: string; label: ReactNode; value: number; color: string; hint?: ReactNode }[]; label: string }) {471  const total = items.reduce((s, i) => s + i.value, 0) || 1;472  const d = useDraw<HTMLDivElement>();473  return (474    <div ref={d.ref}>475      <div role="img" aria-label={label} className="flex h-2.5 gap-0.5 overflow-hidden rounded-full" style={d.bar(0)}>476        {items.map((it) => (477          <span key={it.key} className="h-full first:rounded-l-full last:rounded-r-full" style={{ width: `${(it.value / total) * 100}%`, background: it.color }} />478        ))}479      </div>480      <ul className="num mt-4 text-[0.9rem]">481        {items.map((it) => (482          <li key={it.key} className="flex items-baseline justify-between gap-3 border-b border-line py-2.5 last:border-0">483            <span className="inline-flex min-w-0 items-baseline gap-2.5 font-sans text-ink-2">484              <span className="size-2 shrink-0 translate-y-[-1px] rounded-[2px]" style={{ background: it.color }} />485              <span>486                {it.label}487                {it.hint && <span className="block text-[0.78rem] text-ink-3">{it.hint}</span>}488              </span>489            </span>490            <span className="shrink-0 text-ink-3">491              <span className="mr-2.5 text-xs">{fmtInt(it.value)}</span>492              <span className="font-medium text-ink">{Math.round((it.value / total) * 100)} %</span>493            </span>494          </li>495        ))}496      </ul>497    </div>498  );499}500501// --- Écart à une référence : bande interquartile et médiane, par ligne ------------------502export function BandRows({503  rows,504  scale = 40,505  refLabel,506}: {507  rows: { key: string; label: ReactNode; hint?: ReactNode; low: number; high: number; median: number; strong?: boolean }[];508  /** l'échelle couvre −scale % … +scale % */509  scale?: number;510  refLabel: string;511}) {512  const d = useDraw<HTMLDivElement>();513  const pos = (v: number) => ((Math.max(-scale, Math.min(scale, v)) + scale) / (2 * scale)) * 100;514  const sign = (v: number) => `${v > 0 ? "+" : v < 0 ? "−" : ""}${Math.abs(v).toLocaleString("fr-CA", { maximumFractionDigits: 1 })} %`;515  return (516    <div ref={d.ref}>517      <div className="num mb-1 grid grid-cols-[minmax(0,1fr)_3.6rem] gap-x-3 text-[0.66rem] text-ink-3 sm:grid-cols-[minmax(0,17rem)_minmax(0,1fr)_3.6rem]">518        <span className="max-sm:hidden" />519        <span className="flex justify-between">520          <span>−{scale} %</span>521          <span>{refLabel}</span>522          <span>+{scale} %</span>523        </span>524        <span />525      </div>526      <ul>527        {rows.map((r, i) => (528          <li529            key={r.key}530            className={cn("grid grid-cols-[minmax(0,1fr)_3.6rem] items-center gap-x-3 gap-y-1.5 border-b border-line py-2.5 sm:grid-cols-[minmax(0,17rem)_minmax(0,1fr)_3.6rem]", r.strong && "border-line-2")}531          >532            <span className="col-span-2 min-w-0 sm:col-span-1">533              <span className={cn("block truncate text-[0.9rem]", r.strong ? "font-medium text-ink" : "text-ink")}>{r.label}</span>534              {r.hint && <span className="num block text-[0.74rem] text-ink-3">{r.hint}</span>}535            </span>536            <span className="relative block h-5" role="img" aria-label={`Médiane ${sign(r.median)}, moitié centrale de ${sign(r.low)} à ${sign(r.high)}`}>537              <span className="absolute inset-x-0 top-1/2 h-px bg-line-2" />538              <span className="absolute left-1/2 top-0.5 h-4 w-px bg-ink-3/60" />539              <span540                className="absolute top-1/2 h-1.5 -translate-y-1/2 rounded-full"541                style={{ left: `${pos(Math.min(r.low, r.high))}%`, width: `${Math.max(1, pos(Math.max(r.low, r.high)) - pos(Math.min(r.low, r.high)))}%`, background: STONE, ...d.bar(i) }}542              />543              <span className="absolute top-1/2 size-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-bg bg-brand" style={{ left: `${pos(r.median)}%`, ...d.fade(300 + Math.min(i, 14) * 40) }} />544            </span>545            <span className="num text-right text-[0.88rem] font-medium text-ink">{sign(r.median)}</span>546          </li>547        ))}548      </ul>549    </div>550  );551}552553// --- Jauge linéaire en pourcentage ------------------------------------------------554export function PctMeter({ label, value, hint, color = "var(--brand)" }: { label: ReactNode; value: number | null | undefined; hint?: ReactNode; color?: string }) {555  const d = useDraw<HTMLDivElement>();556  return (557    <div ref={d.ref}>558      <div className="flex items-baseline justify-between gap-3">559        <span className="text-[0.9rem] text-ink">{label}</span>560        <span className="num text-[0.95rem] font-medium text-ink">{value == null ? "—" : `${Math.round(value)} %`}</span>561      </div>562      <div className="mt-1.5 h-1 overflow-hidden rounded-full bg-surface-3">563        <div className="h-full rounded-full" style={{ width: `${Math.min(100, value ?? 0)}%`, background: color, ...d.bar(0) }} />564      </div>565      {hint && <div className="mt-1 text-xs text-ink-3">{hint}</div>}566    </div>567  );568}569
Files main
Menu

Theme