import { useEffect, useRef, useState } from "react" import { DownloadButton } from "@/components/download-button" /** A part of a page under a centred heading, as minimax.io sets its sections. */ export function Section({ title, children, className = "" }: { title?: string; children: React.ReactNode; className?: string }) { return (
{title &&

{title}

} {children}
) } /** A white card with a hairline border. With `download` (the file name) it gets a download button * on its title row (or top right, level with the legend, when untitled). */ export function Panel({ title, download, children }: { title?: string; download?: string; children: React.ReactNode }) { const ref = useRef(null) const head = title &&

{title}

const card = "relative min-w-0 rounded-[20px] border border-border bg-card p-5 shadow-[var(--shadow-card)] sm:p-8" if (!download) return (
{head &&
{head}
} {children}
) return (
{title ? (
{head}
) : ( )}
:first-child]:pr-12"}>{children}
) } /** A number that counts up once when it first appears. */ export function CountUp({ value, format, ms = 1600 }: { value: number; format: (n: number) => string; ms?: number }) { const [v, setV] = useState(0) const done = useRef(false) useEffect(() => { if (done.current || matchMedia("(prefers-reduced-motion: reduce)").matches) { setV(value) return } done.current = true let raf = 0 const t0 = performance.now() const tick = (t: number) => { const p = Math.min(1, (t - t0) / ms) setV(value * (1 - Math.pow(1 - p, 3))) if (p < 1) raf = requestAnimationFrame(tick) } raf = requestAnimationFrame(tick) return () => cancelAnimationFrame(raf) }, [value, ms]) // Serif figures are proportional: the final value, hidden, holds the width while it counts. return ( {format(value)} {format(v)} ) } /** A number over what it counts: serif figures, as minimax.io sets its company numbers. */ export function Stat({ value, label }: { value: React.ReactNode; label: string }) { return (
{value}
{label}
) }