Download code/web/src/components/rel.tsx from MiniMaxAI/oss-ecosystem-data: direct link, hf CLI and curl.
- Browser
- Download file 1.96 kB
-
https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/854565e734c6f46e004eaebb06bf6447648a25e4/code/web/src/components/rel.tsx
- Command line
-
hf download hf://datasets/MiniMaxAI/oss-ecosystem-data@854565e734c6f46e004eaebb06bf6447648a25e4/code/web/src/components/rel.tsx
-
curl -L -o rel.tsx https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/854565e734c6f46e004eaebb06bf6447648a25e4/code/web/src/components/rel.tsx
1.96 kB
| import type { ChartConfig } from "@/components/ui/chart" | |
| import { REL_NAME, type Rel } from "@/lib/types" | |
| /** Each relation keeps one colour everywhere on the page (defined in index.css). */ | |
| export const relColor = (r: Rel | "official") => (r === "official" ? "var(--foreground)" : `var(--rel-${r})`) | |
| export const relConfig = (rels: Rel[]): ChartConfig => | |
| Object.fromEntries(rels.map((r) => [r, { label: REL_NAME[r], color: relColor(r) }])) | |
| export const axisTick = { fontSize: 14, fill: "var(--muted-foreground)" } | |
| export function RelDot({ rel, className = "" }: { rel: Rel | "official"; className?: string }) { | |
| return <span className={`inline-block size-2.5 shrink-0 rounded-full ${className}`} style={{ background: relColor(rel) }} /> | |
| } | |
| /** Legend; pass `hidden` and `onToggle` to let people switch series off (the axis rescales). */ | |
| export function RelLegend({ rels, hidden, onToggle, className = "text-muted-foreground" }: { | |
| rels: Rel[]; hidden?: Set<Rel>; onToggle?: (r: Rel) => void; className?: string | |
| }) { | |
| return ( | |
| <div className={`mb-4 flex flex-wrap gap-x-5 gap-y-2 text-[15px] ${className}`}> | |
| {rels.map((r) => { | |
| const off = hidden?.has(r) | |
| const body = ( | |
| <> | |
| <span className={`inline-block size-2.5 shrink-0 rounded-full ${off ? "border border-muted-foreground" : ""}`} | |
| style={{ background: off ? "transparent" : relColor(r) }} /> | |
| <span className={off ? "line-through opacity-60" : ""}>{REL_NAME[r]}</span> | |
| </> | |
| ) | |
| return onToggle ? ( | |
| <button key={r} type="button" aria-pressed={!off} onClick={() => onToggle(r)} | |
| className="inline-flex items-center gap-2 rounded-md hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring"> | |
| {body} | |
| </button> | |
| ) : ( | |
| <span key={r} className="inline-flex items-center gap-2">{body}</span> | |
| ) | |
| })} | |
| </div> | |
| ) | |
| } | |