Download code/web/src/pages/category.tsx from MiniMaxAI/oss-ecosystem-data: direct link, hf CLI and curl.
- Browser
- Download file 7.84 kB
-
https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/main/code/web/src/pages/category.tsx
- Command line
-
hf download hf://datasets/MiniMaxAI/oss-ecosystem-data/code/web/src/pages/category.tsx
-
curl -L -o category.tsx https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/main/code/web/src/pages/category.tsx
7.84 kB
| import { useEffect, useMemo, useState } from "react" | |
| import { ArrowUpRight } from "lucide-react" | |
| import type { Data, Site } from "@/lib/types" | |
| import { catColor } from "@/lib/category" | |
| import { full, hfUrl, num } from "@/lib/format" | |
| import { href } from "@/lib/route" | |
| import { SiteHeader } from "@/components/site-header" | |
| import { CountUp, Panel, Section, Stat } from "@/components/layout" | |
| import { TitleLockup } from "@/components/lockup" | |
| import { HeroVideo } from "@/components/media" | |
| import { officialPage } from "@/lib/links" | |
| import { GrowthLines, WeeklyBars } from "@/components/growth" | |
| import { DailyLines } from "@/components/daily" | |
| import { DownloadHistory } from "@/components/downloads" | |
| import { RelationTable } from "@/components/relation-table" | |
| import { TopAuthors, TopModels } from "@/components/top-lists" | |
| import { ModelTable } from "@/components/model-table" | |
| import { Galaxy } from "@/components/galaxy" | |
| import { T } from "@/lib/i18n" | |
| export function CategoryPage({ site, cat, rel }: { site: Site; cat: string; rel: string | null }) { | |
| const [data, setData] = useState<Data | null>(null) | |
| const [failed, setFailed] = useState(false) | |
| const c = site.categories.find((x) => x.key === cat) | |
| useEffect(() => { | |
| if (!c) { | |
| location.hash = href() | |
| return | |
| } | |
| fetch(`data/${encodeURIComponent(cat)}.json`) | |
| .then((r) => (r.ok ? r.json() : Promise.reject(r.status))) | |
| .then(setData) | |
| .catch(() => setFailed(true)) | |
| }, [cat, c]) | |
| const lineage = data && (data.family.members.some((m) => m.lineage === rel) ? rel! : data.family.members[0].lineage) | |
| const repos = useMemo(() => (data && lineage ? data.repos.filter((r) => r.lin === lineage) : []), [data, lineage]) | |
| const release = site.releases.find((r) => r.key === lineage) | |
| // Builders are counted over the repos the page lists, as on the landing page's blocks. | |
| const builders = useMemo(() => new Set(repos.map((r) => r.id.split("/")[0])).size, [repos]) | |
| useEffect(() => { | |
| // as minimax.io titles its pages ("MiniMax H3 · H3 Family") | |
| document.title = release ? T.pageTitle(release.name.replace(/-/g, " ")) : T.site | |
| }, [release]) | |
| if (!c) return null | |
| const L = data && lineage ? data.lineages[lineage] : null | |
| const tabs = c.releases.map((k) => site.releases.find((r) => r.key === k)!) | |
| const official = officialPage(cat) | |
| return ( | |
| <> | |
| {/* As a model page on minimax.io: the modality's footage behind the top, the model's name | |
| in white on it, then white cards. */} | |
| <div className="relative isolate"> | |
| <HeroVideo cat={cat} /> | |
| <SiteHeader site={site} /> | |
| <section className="mx-auto w-full max-w-[1200px] px-4 pt-6 pb-4 text-center text-white sm:px-8 sm:pt-10"> | |
| {L && release && ( | |
| <h1 key={lineage} className="anim-rise"> | |
| <span className="block font-display text-[56px] leading-[1.02] font-semibold tracking-[-0.03em] sm:text-[104px]"> | |
| <TitleLockup name={release.name} /> | |
| </span> | |
| <span className="mt-3 block font-serif text-[22px] leading-snug sm:mt-4 sm:text-[28px]"> | |
| <CountUp value={L.n_models} format={(v) => full(Math.round(v))} ms={1200} /> {T.heroCount} | |
| </span> | |
| </h1> | |
| )} | |
| {/* the official page for this modality, set like the buttons under the hero on minimax.io */} | |
| {L && official && ( | |
| <a href={official.href} target="_blank" rel="noopener" | |
| className="mt-7 inline-flex h-11 items-center gap-1.5 rounded-[10px] bg-white/20 px-6 text-[16px] font-medium text-white backdrop-blur-sm transition-colors hover:bg-white/30 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white" | |
| style={{ animation: "rise 700ms cubic-bezier(.22,.61,.36,1) 120ms both" }}> | |
| {official.label}<ArrowUpRight className="size-4" /> | |
| </a> | |
| )} | |
| {tabs.length > 1 && ( | |
| <nav className="-mx-4 mt-8 flex gap-2 overflow-x-auto px-4 pb-1 [scrollbar-width:none] sm:mx-0 sm:flex-wrap sm:justify-center sm:px-0 [&::-webkit-scrollbar]:hidden"> | |
| {tabs.map((r) => { | |
| const on = r.key === lineage | |
| const cls = `inline-flex h-10 shrink-0 items-center gap-1.5 rounded-full px-4 text-[15px] font-medium transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white ${on ? "bg-white text-[#171717]" : "bg-white/20 text-white backdrop-blur-sm hover:bg-white/30"}` | |
| return r.page ? ( | |
| <a key={r.key} href={href(cat, r.key)} aria-current={on ? "page" : undefined} className={cls}>{r.name}</a> | |
| ) : ( | |
| <a key={r.key} href={hfUrl(r.base)} target="_blank" rel="noopener" className={cls}> | |
| {r.name}<ArrowUpRight className="size-4 opacity-75" /> | |
| </a> | |
| ) | |
| })} | |
| </nav> | |
| )} | |
| </section> | |
| <div className="mx-auto w-full max-w-[1200px] px-4 sm:px-8"> | |
| {L && release && ( | |
| <div key={lineage} className="mt-10 grid grid-cols-2 gap-x-8 gap-y-8 rounded-[24px] border border-white/60 bg-white p-6 shadow-[0_30px_80px_-30px_rgba(40,10,80,0.35)] sm:mt-14 sm:p-10 lg:grid-cols-4" | |
| style={{ animation: "rise 800ms cubic-bezier(.22,.61,.36,1) 150ms both" }}> | |
| <Stat value={full(builders)} label={T.builders} /> | |
| <Stat value={num(L.dlall)} label={T.communityDownloads} /> | |
| <Stat value={num(L.dl30)} label={T.communityDownloads30} /> | |
| <Stat value={num(L.official.dlall)} label={T.releaseDownloads(release.name)} /> | |
| </div> | |
| )} | |
| </div> | |
| </div> | |
| <main className="relative mx-auto w-full max-w-[1200px] px-4 pb-28 sm:px-8"> | |
| {failed && <p className="mt-20 text-lg">{T.noData}</p>} | |
| {data && L && lineage && release && ( | |
| <div key={lineage}> | |
| <Section title={T.growth}> | |
| <div className="grid gap-6 lg:grid-cols-[1.4fr_1fr]"> | |
| <Panel title={T.byTypeOverTime} download={`${release.name} community models by type`}><GrowthLines L={L} rel={data.rel_order} today={data.today} /></Panel> | |
| <Panel title={T.newEachWeek} download={`${release.name} new community models each week`}><WeeklyBars L={L} today={data.today} color={catColor(cat)} /></Panel> | |
| </div> | |
| </Section> | |
| {L.history && L.history.length > 1 && ( | |
| <Section title={T.downloadsOverTime}> | |
| <Panel download={`${release.name} downloads over time`}><DownloadHistory history={L.history} name={release.name} color={catColor(cat)} /></Panel> | |
| </Section> | |
| )} | |
| <DailyLines L={L} rel={data.rel_order} download={`${release.name} daily downloads`} /> | |
| <Section title={T.byType}> | |
| <Panel><RelationTable L={L} order={data.rel_order} /></Panel> | |
| </Section> | |
| <Section title={T.whoBuilds}> | |
| <div className="grid gap-6 lg:grid-cols-2"> | |
| <Panel title={T.topModels}><TopModels repos={repos} authors={data.authors} /></Panel> | |
| <Panel title={T.topBuilders}><TopAuthors L={L} authors={data.authors} /></Panel> | |
| </div> | |
| </Section> | |
| <Section title={T.allModels}> | |
| <Panel><ModelTable repos={repos} authors={data.authors} hasDaily={data.snapshot_days.length > 1} /></Panel> | |
| </Section> | |
| <Section title={T.galaxy}> | |
| <Galaxy key={lineage} lineageKey={lineage} repos={repos} L={L} authors={data.authors} name={release.name} cat={cat} /> | |
| </Section> | |
| </div> | |
| )} | |
| </main> | |
| </> | |
| ) | |
| } | |