import { useEffect, useRef, useState } from "react" import { ArrowLeft, ArrowRight, ArrowUpRight } from "lucide-react" import type { Release, Site } from "@/lib/types" import { catColor } from "@/lib/category" import { full, hfUrl, mdy, num } from "@/lib/format" import { href } from "@/lib/route" import { Spark } from "@/components/sparkline" /** Every open release in order, as cards: when, what, and the community it has today. */ export function ReleaseRail({ site }: { site: Site }) { const rail = useRef(null) const [edge, setEdge] = useState({ start: true, end: false }) const rels = [...site.releases].sort((a, b) => a.date.localeCompare(b.date)) const catName = (k: string) => site.categories.find((c) => c.key === k)?.name ?? k 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 (

Every release

{[-1, 1].map((d) => ( ))}
    {rels.map((r, i) => )}
) } function Card({ r, cat, today, i }: { r: Release; cat: string; today: string; i: number }) { const external = !r.page return (
  • {mdy(r.date)} {cat}
    {r.name} {external && }
    {full(r.n)}
    community
    {num(r.official.dlall)}
    downloads
  • ) }