Download code/web/src/components/release-rail.tsx from MiniMaxAI/oss-ecosystem-data: direct link, hf CLI and curl.
- Browser
- Download file 4.08 kB
-
https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/3c96cf2d04fca65e12deedeeed8b1e3e1a6fb6df/code/web/src/components/release-rail.tsx
- Command line
-
hf download hf://datasets/MiniMaxAI/oss-ecosystem-data@3c96cf2d04fca65e12deedeeed8b1e3e1a6fb6df/code/web/src/components/release-rail.tsx
-
curl -L -o release-rail.tsx https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/3c96cf2d04fca65e12deedeeed8b1e3e1a6fb6df/code/web/src/components/release-rail.tsx
4.08 kB
| import { useEffect, useRef, useState } from "react" | |
| import { ArrowLeft, ArrowRight, ArrowUpRight } from "lucide-react" | |
| import type { Release, Site } from "@/lib/types" | |
| import { full, hfUrl, mdy, num } from "@/lib/format" | |
| import { href } from "@/lib/route" | |
| import { Tile } from "@/components/media" | |
| /** Every release in order, as minimax.io shows its flagship models: a card with the model's | |
| * picture, its name and date, and the community it has today. */ | |
| export function ReleaseRail({ site }: { site: Site }) { | |
| const rail = useRef<HTMLOListElement>(null) | |
| const [edge, setEdge] = useState({ start: true, end: false }) | |
| const rels = [...site.releases].sort((a, b) => a.date.localeCompare(b.date)) | |
| const sync = () => { | |
| const el = rail.current | |
| if (!el) return | |
| setEdge({ start: el.scrollLeft < 8, end: el.scrollLeft + el.clientWidth > el.scrollWidth - 8 }) | |
| } | |
| useEffect(() => { | |
| const el = rail.current | |
| if (!el) return | |
| el.scrollLeft = el.scrollWidth // newest in view; history is a scroll away | |
| sync() | |
| }, []) | |
| const page = (dir: number) => rail.current?.scrollBy({ left: dir * rail.current.clientWidth * 0.8, behavior: "smooth" }) | |
| return ( | |
| <section className="relative mx-auto w-full max-w-[1200px] px-4 sm:px-8"> | |
| <div className="relative mb-8 flex items-center justify-center"> | |
| <h2 className="text-center font-display text-[30px] leading-tight font-semibold tracking-[-0.01em] sm:text-[36px]">Every release</h2> | |
| <div className="absolute right-0 hidden gap-2 sm:flex"> | |
| {[-1, 1].map((d) => ( | |
| <button key={d} type="button" onClick={() => page(d)} disabled={d < 0 ? edge.start : edge.end} | |
| aria-label={d < 0 ? "Earlier releases" : "Later releases"} | |
| className="grid size-10 place-items-center rounded-full border border-border bg-white text-foreground transition-colors hover:bg-muted disabled:opacity-35"> | |
| {d < 0 ? <ArrowLeft className="size-4" /> : <ArrowRight className="size-4" />} | |
| </button> | |
| ))} | |
| </div> | |
| </div> | |
| <ol ref={rail} onScroll={sync} | |
| className="-mx-4 flex snap-x snap-mandatory scroll-px-4 gap-4 overflow-x-auto scroll-smooth px-4 pt-1 pb-6 [scrollbar-width:none] sm:-mx-8 sm:scroll-px-8 sm:px-8 [&::-webkit-scrollbar]:hidden"> | |
| {rels.map((r) => <Card key={r.key} r={r} />)} | |
| </ol> | |
| </section> | |
| ) | |
| } | |
| function Card({ r }: { r: Release }) { | |
| const external = !r.page | |
| return ( | |
| <li className="w-[256px] shrink-0 snap-start sm:w-[272px]"> | |
| <a href={external ? hfUrl(r.base) : href(r.cat, r.key)} target={external ? "_blank" : undefined} rel={external ? "noopener" : undefined} | |
| className="group flex h-full flex-col rounded-[20px] border border-border bg-white p-2 shadow-[var(--shadow-card)] transition-[transform,box-shadow] duration-300 ease-[cubic-bezier(.22,.61,.36,1)] hover:-translate-y-1 hover:shadow-[0_24px_48px_-20px_rgba(23,23,23,0.28)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring"> | |
| <Tile name={r.name} cat={r.cat} /> | |
| <div className="px-3 pt-4 pb-3"> | |
| <div className="flex items-start justify-between gap-2"> | |
| <span className="font-display text-[19px] leading-snug font-semibold">{r.name.replace(/-/g, " ")}</span> | |
| {external && <ArrowUpRight className="mt-1 size-4 shrink-0 text-muted-foreground" />} | |
| </div> | |
| <div className="mt-1 text-[15px] text-muted-foreground">{mdy(r.date)}</div> | |
| <div className="mt-5 grid grid-cols-2 gap-3"> | |
| <div> | |
| <div className="font-serif text-[24px] leading-none">{full(r.n)}</div> | |
| <div className="mt-2 text-[15px] text-muted-foreground">community</div> | |
| </div> | |
| <div> | |
| <div className="font-serif text-[24px] leading-none">{num(r.official.dlall)}</div> | |
| <div className="mt-2 text-[15px] text-muted-foreground">downloads</div> | |
| </div> | |
| </div> | |
| </div> | |
| </a> | |
| </li> | |
| ) | |
| } | |