Spaces:
Sleeping
Sleeping
Download web/src/components/evals/Section.tsx from TBM99/CoverageCheck: direct link, hf CLI and curl.
- Browser
- Download file 2.82 kB
-
https://huggingface.co/spaces/TBM99/CoverageCheck/resolve/main/web/src/components/evals/Section.tsx
- Command line
-
hf download hf://spaces/TBM99/CoverageCheck/web/src/components/evals/Section.tsx
-
curl -L -o Section.tsx https://huggingface.co/spaces/TBM99/CoverageCheck/resolve/main/web/src/components/evals/Section.tsx
2.82 kB
| import { type ReactNode, useState } from 'react' | |
| import { SERIES, ORDER } from '@/lib/chart' | |
| import type { SystemId } from '@/lib/types' | |
| /** One claim of the Evals story: a title that states it, one sentence of takeaway, the | |
| * chart, and the numbers behind it as a table on demand (every chart has a table view: | |
| * the dataviz relief rule, and the honest way to read exact values). */ | |
| export function Section({ | |
| id, | |
| title, | |
| takeaway, | |
| children, | |
| table, | |
| }: { | |
| id: string | |
| title: string | |
| takeaway: ReactNode | |
| children: ReactNode | |
| table?: ReactNode | |
| }) { | |
| const [showTable, setShowTable] = useState(false) | |
| return ( | |
| <section id={id} className="scroll-mt-20 space-y-3"> | |
| <h2 className="text-xl font-semibold tracking-tight">{title}</h2> | |
| <p className="max-w-3xl text-sm leading-relaxed text-muted-foreground">{takeaway}</p> | |
| <div className="rounded-2xl border bg-background p-4 sm:p-5"> | |
| {children} | |
| {table && ( | |
| <div className="mt-3 border-t pt-3"> | |
| <button | |
| type="button" | |
| className="text-xs font-medium text-primary hover:underline" | |
| onClick={() => setShowTable(!showTable)} | |
| aria-expanded={showTable} | |
| > | |
| {showTable ? 'Hide the numbers' : 'Show the numbers'} | |
| </button> | |
| {showTable && <div className="mt-2 overflow-x-auto">{table}</div>} | |
| </div> | |
| )} | |
| </div> | |
| </section> | |
| ) | |
| } | |
| /** The A / B / C legend: a colour swatch beside each name (identity never by colour | |
| * alone; text stays in ink colours). */ | |
| export function Legend({ names }: { names: Record<SystemId, string> }) { | |
| return ( | |
| <ul className="flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground"> | |
| {ORDER.map((s) => ( | |
| <li key={s} className="flex items-center gap-1.5"> | |
| <span className="size-2.5 rounded-sm" style={{ background: SERIES[s] }} aria-hidden /> | |
| System {s.toUpperCase()} · {names[s]} | |
| </li> | |
| ))} | |
| </ul> | |
| ) | |
| } | |
| /** A plain numbers table (the "Show the numbers" view). */ | |
| export function NumbersTable({ head, rows }: { head: string[]; rows: (string | number)[][] }) { | |
| return ( | |
| <table className="w-full min-w-[28rem] text-left text-xs tabular-nums"> | |
| <thead> | |
| <tr className="border-b text-muted-foreground"> | |
| {head.map((h) => ( | |
| <th key={h} className="py-1.5 pr-3 font-medium"> | |
| {h} | |
| </th> | |
| ))} | |
| </tr> | |
| </thead> | |
| <tbody> | |
| {rows.map((row, i) => ( | |
| <tr key={i} className="border-b last:border-0"> | |
| {row.map((cell, j) => ( | |
| <td key={j} className="py-1.5 pr-3"> | |
| {cell} | |
| </td> | |
| ))} | |
| </tr> | |
| ))} | |
| </tbody> | |
| </table> | |
| ) | |
| } | |