Download code/web/src/components/layout.tsx from MiniMaxAI/oss-ecosystem-data: direct link, hf CLI and curl.
- Browser
- Download file 3.8 kB
-
https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/3b3de8f867c1a5b0226caaab71cd73ccbec72dd8/code/web/src/components/layout.tsx
- Command line
-
hf download hf://datasets/MiniMaxAI/oss-ecosystem-data@3b3de8f867c1a5b0226caaab71cd73ccbec72dd8/code/web/src/components/layout.tsx
-
curl -L -o layout.tsx https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/3b3de8f867c1a5b0226caaab71cd73ccbec72dd8/code/web/src/components/layout.tsx
3.8 kB
| import { useEffect, useRef, useState } from "react" | |
| import { catColor } from "@/lib/category" | |
| import { DownloadButton } from "@/components/download-button" | |
| export function Section({ title, children, className = "" }: { title?: string; children: React.ReactNode; className?: string }) { | |
| return ( | |
| <section className={`mt-24 ${className}`}> | |
| {title && <h2 className="mb-8 font-display text-[30px] leading-tight font-semibold tracking-[-0.01em] sm:text-[34px]">{title}</h2>} | |
| {children} | |
| </section> | |
| ) | |
| } | |
| /** A card. With `download` (the file name) it gets a download button in its top right corner. */ | |
| export function Panel({ title, download, children }: { title?: string; download?: string; children: React.ReactNode }) { | |
| const ref = useRef<HTMLDivElement>(null) | |
| if (!download) | |
| return ( | |
| <div className="min-w-0 rounded-[20px] border border-border bg-card p-5 sm:p-8"> | |
| {title && <h3 className="mb-6 text-lg font-medium">{title}</h3>} | |
| {children} | |
| </div> | |
| ) | |
| return ( | |
| <div ref={ref} className="relative min-w-0 rounded-[20px] border border-border bg-card p-5 sm:p-8"> | |
| {title ? ( | |
| <div className="mb-6 flex items-center justify-between gap-4"> | |
| <h3 className="text-lg font-medium">{title}</h3> | |
| <DownloadButton target={ref} name={download} /> | |
| </div> | |
| ) : ( | |
| // level with the legend row; the legend leaves room for it | |
| <DownloadButton target={ref} name={download} className="absolute top-3.5 right-5 sm:top-[26px] sm:right-8" /> | |
| )} | |
| <div className={title ? undefined : "[&>:first-child]:pr-12"}>{children}</div> | |
| </div> | |
| ) | |
| } | |
| /** Soft colour light behind the dark stage; `cats` picks the hues. */ | |
| export function Glow({ cats }: { cats: string[] }) { | |
| const spots = [ | |
| { left: "62%", top: "-18%", size: 620, o: 0.42 }, | |
| { left: "-12%", top: "8%", size: 520, o: 0.3 }, | |
| { left: "30%", top: "46%", size: 560, o: 0.22 }, | |
| { left: "84%", top: "52%", size: 420, o: 0.2 }, | |
| ] | |
| return ( | |
| <div aria-hidden className="pointer-events-none absolute inset-0 -z-10 overflow-hidden"> | |
| {spots.map((s, i) => ( | |
| <div key={i} className="absolute rounded-full blur-[120px]" | |
| style={{ left: s.left, top: s.top, width: s.size, height: s.size, opacity: s.o, | |
| background: catColor(cats[i % cats.length]) }} /> | |
| ))} | |
| <div className="absolute inset-0 bg-[radial-gradient(rgba(255,255,255,0.07)_1px,transparent_1px)] [background-size:28px_28px] [mask-image:linear-gradient(180deg,#000,transparent_85%)]" /> | |
| </div> | |
| ) | |
| } | |
| /** 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]) | |
| return <>{format(v)}</> | |
| } | |
| /** Big value over its label, for the stat rows on the stage. */ | |
| export function Stat({ value, label }: { value: React.ReactNode; label: string }) { | |
| return ( | |
| <div className="min-w-0"> | |
| <div className="font-display text-[34px] leading-none font-semibold tracking-[-0.02em] text-white tabular-nums sm:text-[44px]">{value}</div> | |
| <div className="mt-2.5 text-[15px] text-white/60 sm:text-base">{label}</div> | |
| </div> | |
| ) | |
| } | |