Download code/web/src/components/category-blocks.tsx from MiniMaxAI/oss-ecosystem-data: direct link, hf CLI and curl.
- Browser
- Download file 5.14 kB
-
https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/3c96cf2d04fca65e12deedeeed8b1e3e1a6fb6df/code/web/src/components/category-blocks.tsx
- Command line
-
hf download hf://datasets/MiniMaxAI/oss-ecosystem-data@3c96cf2d04fca65e12deedeeed8b1e3e1a6fb6df/code/web/src/components/category-blocks.tsx
-
curl -L -o category-blocks.tsx https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/3c96cf2d04fca65e12deedeeed8b1e3e1a6fb6df/code/web/src/components/category-blocks.tsx
5.14 kB
| import { ArrowUpRight } from "lucide-react" | |
| import type { Site } from "@/lib/types" | |
| import { catFrom, catTo } from "@/lib/category" | |
| import { DAY, full, isoDay, num, toTime } from "@/lib/format" | |
| import { href } from "@/lib/route" | |
| import { Spark } from "@/components/sparkline" | |
| /** One block per modality: how big its community is, which releases it holds, who builds on it. */ | |
| export function CategoryBlocks({ site }: { site: Site }) { | |
| return ( | |
| <div className="grid gap-5 lg:grid-cols-2"> | |
| {site.categories.map((c, i) => <Block key={c.key} site={site} cat={c.key} wide={i < 2 || site.categories.length % 2 === 1 && i === site.categories.length - 1} />)} | |
| </div> | |
| ) | |
| } | |
| function Block({ site, cat, wide }: { site: Site; cat: string; wide: boolean }) { | |
| const c = site.categories.find((x) => x.key === cat)! | |
| const rels = c.releases.map((k) => site.releases.find((r) => r.key === k)!) | |
| const n = rels.reduce((a, r) => a + r.n, 0) | |
| const dl = rels.reduce((a, r) => a + r.dlall, 0) | |
| const off = rels.reduce((a, r) => a + (r.official.dlall ?? 0), 0) | |
| const events = rels.flatMap((r) => r.growth) | |
| // The curve starts a week before the first community model, so a modality whose community | |
| // is new still gets a readable curve rather than a flat line and a cliff. | |
| const firstEvent = events.reduce((a, [d]) => (d < a ? d : a), "9999") | |
| const first = firstEvent < "9999" ? isoDay(toTime(firstEvent) - 7 * DAY) : rels.reduce((a, r) => (r.date < a ? r.date : a), rels[0].date) | |
| const repoCount = rels.reduce((a, r) => a + r.models.length, 0) | |
| const stats: [string, string][] = [ | |
| [num(dl), "community downloads"], | |
| [full(c.builders), "builders"], | |
| [num(off), "MiniMax downloads"], | |
| [full(repoCount), repoCount === 1 ? "open model" : "open models"], | |
| ] | |
| return ( | |
| <a href={href(cat)} | |
| className={`group relative flex flex-col overflow-hidden rounded-[24px] border border-border bg-white shadow-[var(--shadow-card)] transition-[transform,box-shadow] duration-300 ease-[cubic-bezier(.22,.61,.36,1)] hover:-translate-y-1 hover:shadow-[0_28px_56px_-24px_rgba(23,23,23,0.28)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring ${wide ? "lg:col-span-2" : ""}`}> | |
| <div className="flex-1 p-7 sm:p-10"> | |
| <div className="flex items-start justify-between gap-4"> | |
| <h2 className="font-display text-[30px] leading-none font-semibold tracking-[-0.01em] sm:text-[36px]">{c.name}</h2> | |
| <span className="grid size-11 shrink-0 place-items-center rounded-full border border-border transition-[background-color,color,border-color,transform] duration-200 group-hover:rotate-45 group-hover:border-[#171717] group-hover:bg-[#171717] group-hover:text-white"> | |
| <ArrowUpRight className="size-5" /> | |
| </span> | |
| </div> | |
| <div className={`mt-8 ${wide ? "lg:flex lg:items-end lg:justify-between lg:gap-10" : ""}`}> | |
| <div> | |
| <div className="gradient-text w-fit pb-1 font-display text-[72px] leading-[0.9] font-semibold tracking-[-0.04em] tabular-nums sm:text-[96px]" | |
| style={{ "--from": catFrom(cat), "--to": catTo(cat) } as React.CSSProperties}>{full(n)}</div> | |
| <div className="mt-2 text-lg text-muted-foreground">community models</div> | |
| </div> | |
| <dl className={`mt-8 grid grid-cols-2 gap-x-8 gap-y-6 ${wide ? "sm:grid-cols-4 lg:mt-0 lg:gap-x-12" : ""}`}> | |
| {stats.map(([v, l]) => ( | |
| <div key={l}> | |
| <dt className="sr-only">{l}</dt> | |
| <dd className="font-serif text-[26px] leading-none">{v}</dd> | |
| <dd className="mt-2.5 text-[15px] text-muted-foreground">{l}</dd> | |
| </div> | |
| ))} | |
| </dl> | |
| </div> | |
| <div className="mt-8 flex flex-wrap items-center gap-2"> | |
| {rels.map((r) => ( | |
| <span key={r.key} className="inline-flex h-9 items-center gap-2 rounded-full bg-muted px-3.5 text-[15px]"> | |
| <span className="font-medium">{r.name}</span> | |
| {r.n > 0 && <span className="text-muted-foreground tabular-nums">{full(r.n)}</span>} | |
| </span> | |
| ))} | |
| </div> | |
| {c.top_authors.length > 0 && ( | |
| <div className="mt-6 flex items-center gap-3"> | |
| <div className="flex -space-x-2.5"> | |
| {c.top_authors.map((a) => ( | |
| <span key={a.id} title={a.n} className="grid size-9 place-items-center overflow-hidden rounded-full bg-muted text-sm font-medium ring-[3px] ring-white"> | |
| {a.a ? <img src={a.a} alt="" loading="lazy" className="size-full object-cover" /> : a.id.slice(0, 1).toUpperCase()} | |
| </span> | |
| ))} | |
| </div> | |
| {c.builders > c.top_authors.length && ( | |
| <span className="text-[15px] text-muted-foreground">+{full(c.builders - c.top_authors.length)} more builders</span> | |
| )} | |
| </div> | |
| )} | |
| </div> | |
| <Spark events={events} from={first} to={site.today} cat={cat} height={wide ? 120 : 100} | |
| dots={rels.map((r) => r.date)} ring="#fff" /> | |
| </a> | |
| ) | |
| } | |