Download code/web/src/components/top-lists.tsx from MiniMaxAI/oss-ecosystem-data: direct link, hf CLI and curl.
- Browser
- Download file 2.79 kB
-
https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/784350ab9058691de6b5dfd2e4cc31dbb85799fc/code/web/src/components/top-lists.tsx
- Command line
-
hf download hf://datasets/MiniMaxAI/oss-ecosystem-data@784350ab9058691de6b5dfd2e4cc31dbb85799fc/code/web/src/components/top-lists.tsx
-
curl -L -o top-lists.tsx https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/784350ab9058691de6b5dfd2e4cc31dbb85799fc/code/web/src/components/top-lists.tsx
2.79 kB
| import { useMemo } from "react" | |
| import type { Author, Lineage, Repo } from "@/lib/types" | |
| import { relName, T } from "@/lib/i18n" | |
| import { num as fmt, hfUrl } from "@/lib/format" | |
| import { relColor } from "@/components/rel" | |
| import { Who } from "@/components/who" | |
| export function TopModels({ repos, authors }: { repos: Repo[]; authors: Record<string, Author> }) { | |
| const top = useMemo(() => [...repos].sort((a, b) => (b.dl30 ?? 0) - (a.dl30 ?? 0)).slice(0, 10), [repos]) | |
| const max = Math.max(1, ...top.map((r) => r.dl30 ?? 0)) | |
| return ( | |
| <ol className="space-y-4"> | |
| {top.map((r) => { | |
| const [owner, name] = r.id.split("/") | |
| return ( | |
| <li key={r.id} className="flex items-center gap-3"> | |
| <Who name={owner} authors={authors} /> | |
| <div className="min-w-0 flex-1"> | |
| <div className="flex items-baseline justify-between gap-3"> | |
| <a href={hfUrl(r.id)} target="_blank" rel="noopener" className="truncate text-[15px] hover:underline" title={r.id}> | |
| <span className="text-muted-foreground">{owner}/</span>{name} | |
| </a> | |
| <span className="shrink-0 font-display text-[15px] font-semibold tabular-nums">{fmt(r.dl30)}</span> | |
| </div> | |
| <div className="mt-1.5 flex items-center gap-3"> | |
| <div className="h-1.5 rounded-full" style={{ width: `${Math.max(2, ((r.dl30 ?? 0) / max) * 78)}%`, background: relColor(r.rel) }} /> | |
| <span className="shrink-0 text-sm text-muted-foreground">{relName(r.rel)}</span> | |
| </div> | |
| </div> | |
| </li> | |
| ) | |
| })} | |
| </ol> | |
| ) | |
| } | |
| export function TopAuthors({ L, authors }: { L: Lineage; authors: Record<string, Author> }) { | |
| const top = (L.top_authors ?? []).slice(0, 10) | |
| const max = Math.max(1, ...top.map((a) => a.n)) | |
| return ( | |
| <ol className="space-y-4"> | |
| {top.map((t) => ( | |
| <li key={t.a} className="flex items-center gap-3"> | |
| <Who name={t.a} authors={authors} /> | |
| <div className="min-w-0 flex-1"> | |
| <div className="flex items-baseline justify-between gap-3"> | |
| <a href={hfUrl(t.a)} target="_blank" rel="noopener" className="truncate text-[15px] hover:underline"> | |
| {authors[t.a]?.n ?? t.a} | |
| {authors[t.a]?.n && authors[t.a].n !== t.a && <span className="ml-2 text-muted-foreground">{t.a}</span>} | |
| </a> | |
| <span className="shrink-0 text-[15px]"><span className="font-display font-semibold tabular-nums">{t.n}</span> {T.modelsUnit(t.n)}</span> | |
| </div> | |
| <div className="mt-1.5 h-1.5 rounded-full bg-[var(--neutral-series)]" style={{ width: `${(t.n / max) * 100}%` }} /> | |
| </div> | |
| </li> | |
| ))} | |
| </ol> | |
| ) | |
| } | |