File size: 6,390 Bytes
2471af3 61db3dc 2471af3 0953253 2471af3 6cd0e79 2471af3 61db3dc 2471af3 61db3dc 6cd0e79 61db3dc 0953253 61db3dc 0953253 61db3dc 0953253 61db3dc 6cd0e79 0953253 2471af3 61db3dc 2471af3 61db3dc 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 | import { useRef, useState } from "react"
import type { Site } from "@/lib/types"
import { CAT_ORDER, catColor } from "@/lib/category"
import { full, hfUrl, num } from "@/lib/format"
import { href } from "@/lib/route"
import { SiteHeader } from "@/components/site-header"
import { CommunityChart, type Metric, useDownloadSeries, useSeries } from "@/components/community-chart"
import { Segmented } from "@/components/segmented"
import { ReleaseRail } from "@/components/release-rail"
import { CategoryBlocks } from "@/components/category-blocks"
import { CountUp, Stat } from "@/components/layout"
import { HeroVideo } from "@/components/media"
import { DownloadButton } from "@/components/download-button"
import { catName, T } from "@/lib/i18n"
export function Home({ site }: { site: Site }) {
const [hidden, setHidden] = useState<Set<string>>(new Set())
const chartRef = useRef<HTMLDivElement>(null)
const models = useSeries(site)
const downloads = useDownloadSeries(site, models)
const [metric, setMetric] = useState<Metric>(downloads ? "downloads" : "models") // the headline is the end of this curve
const series = metric === "downloads" && downloads ? downloads : models
const { cats } = models
const now = series.rows.at(-1)!
const total = site.releases.reduce((a, r) => a + r.n, 0)
const commDl = site.releases.reduce((a, r) => a + r.dlall, 0)
const offDl = site.releases.reduce((a, r) => a + (r.official.dlall ?? 0), 0)
const repos = site.releases.reduce((a, r) => a + r.models.length, 0)
const toggle = (c: string) => setHidden((h) => {
const n = new Set(h)
if (n.has(c)) n.delete(c)
else if (n.size < cats.length - 1) n.add(c)
return n
})
return (
<>
{/* As on minimax.io: the M3.1 footage behind the top of the page, white type on it, and
everything with small text in white cards. */}
<div className="relative isolate">
<HeroVideo cat="language" />
<SiteHeader site={site} />
<section className="mx-auto w-full max-w-[1200px] px-4 pt-6 sm:px-8 sm:pt-8">
<h1 className="anim-rise text-center text-white">
<span className="block font-display text-[clamp(44px,13.5vw,84px)] leading-[0.95] font-semibold tracking-[-0.03em] sm:text-[104px]">
<CountUp value={commDl + offDl} format={(v) => full(Math.round(v))} />
</span>
<span className="mt-3 block font-serif text-[22px] leading-snug [word-break:keep-all] sm:mt-4 sm:text-[28px]">
{T.dlTagline}
</span>
</h1>
<div className="mt-10 rounded-[24px] border border-white/60 bg-white p-4 shadow-[0_30px_80px_-30px_rgba(60,10,20,0.35)] sm:mt-12 sm:p-8"
style={{ animation: "rise 800ms cubic-bezier(.22,.61,.36,1) 150ms both" }}>
<div ref={chartRef} className="bg-white">
{/* phones: the switch and the download button on a row of their own, above the chips */}
<div className="flex flex-wrap items-center justify-between gap-3">
<div className="order-2 flex flex-wrap gap-2 sm:order-1">
{CAT_ORDER.filter((c) => cats.includes(c)).reverse().map((c) => {
const off = hidden.has(c)
const name = catName(site.categories.find((x) => x.key === c)!)
return (
<button key={c} type="button" aria-pressed={!off} onClick={() => toggle(c)}
className={`inline-flex h-10 items-center gap-2 rounded-full border px-3.5 text-[15px] transition-colors sm:gap-2.5 sm:px-4 ${off ? "border-border text-muted-foreground" : "border-border bg-white text-foreground hover:bg-muted"}`}>
<span className="size-2.5 rounded-full" style={off ? { boxShadow: "inset 0 0 0 1.5px var(--muted-foreground)" } : { background: catColor(c) }} />
<span className={off ? "line-through" : ""}>{name}</span>
<span className="text-muted-foreground tabular-nums">{metric === "models" ? full(now[c]) : num(now[c])}</span>
</button>
)
})}
</div>
<div className="order-1 flex w-full items-center justify-between gap-2 sm:order-2 sm:w-auto">
{downloads && (
<Segmented label={T.chart} value={metric} onChange={setMetric}
options={[{ value: "models", label: T.metricModels }, { value: "downloads", label: T.metricDownloads }]} />
)}
<DownloadButton target={chartRef} name={metric === "models" ? "MiniMax community models" : "MiniMax downloads"}
pad={32} big />
</div>
</div>
<CommunityChart site={site} series={series} metric={metric} hidden={hidden}
className="mt-4 h-[340px] sm:h-[clamp(360px,calc(100svh-500px),520px)]"
onPick={(r) => {
if (r.page) location.hash = href(r.cat, r.key)
else window.open(hfUrl(r.base), "_blank", "noopener")
}} />
</div>
<div className="mt-8 grid grid-cols-2 gap-x-8 gap-y-7 border-t border-border pt-7 sm:grid-cols-3 lg:grid-cols-5">
<Stat value={<CountUp value={total} format={(v) => full(Math.round(v))} />} label={T.communityModels} />
<Stat value={<CountUp value={commDl} format={num} />} label={T.communityDownloads} />
<Stat value={<CountUp value={offDl} format={num} />} label={T.minimaxModelDownloads} />
<Stat value={<CountUp value={site.builders} format={(v) => full(Math.round(v))} />} label={T.builders} />
<Stat value={full(repos)} label={T.openModels(repos)} />
</div>
</div>
</section>
<div className="mt-24 sm:mt-28">
<ReleaseRail site={site} />
</div>
</div>
<main className="relative mx-auto w-full max-w-[1200px] px-4 pt-20 pb-28 sm:px-8 sm:pt-24">
<h2 className="mb-10 text-center font-display text-[30px] leading-tight font-semibold tracking-[-0.01em] sm:text-[36px]">{T.byModality}</h2>
<CategoryBlocks site={site} />
</main>
</>
)
}
|