File size: 7,836 Bytes
2471af3 61db3dc 2471af3 61db3dc 24477c9 2471af3 0953253 2471af3 3c90ca7 0953253 2471af3 24477c9 2471af3 61db3dc 2471af3 61db3dc 0953253 61db3dc 24477c9 3c90ca7 24477c9 3c90ca7 2471af3 61db3dc 2471af3 61db3dc 2471af3 61db3dc 2471af3 61db3dc 2471af3 61db3dc 0953253 2471af3 61db3dc 2471af3 61db3dc 0953253 2471af3 0953253 2471af3 0953253 2471af3 0953253 2471af3 0953253 2471af3 0953253 2471af3 0953253 2471af3 0953253 2471af3 0953253 2471af3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | 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>
</>
)
}
|