Download code/web/src/pages/home.tsx from MiniMaxAI/oss-ecosystem-data: direct link, hf CLI and curl.
- Browser
- Download file 6.39 kB
-
https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/main/code/web/src/pages/home.tsx
- Command line
-
hf download hf://datasets/MiniMaxAI/oss-ecosystem-data/code/web/src/pages/home.tsx
-
curl -L -o home.tsx https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/main/code/web/src/pages/home.tsx
6.39 kB
| 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> | |
| </> | |
| ) | |
| } | |