spb/autoscholar
Public
1import { DISCIPLINE_LABELS } from "@autoscholar/schemas";2import Link from "next/link";34const GLYPH: Record<string, string> = {5 economics: "∂",6 finance: "σ",7 mathematics: "∀",8 statistics: "Σ",9 "computer-science": "λ",10 physics: "ℏ",11 chemistry: "⚛",12 biology: "𝔹",13 medicine: "℞",14 engineering: "⚙",15 "earth-sciences": "⊕",16 "social-sciences": "§",17 psychology: "ψ",18 humanities: "¶",19 law: "⚖",20 education: "∞",21 interdisciplinary: "⋈",22};2324/** DisciplineExplorer — subject navigation from real counts (zero is shown as zero). */25export function DisciplineExplorer({26 counts,27 topics,28 compact = false,29}: {30 counts: Array<{ discipline: string; n: number }>;31 topics: Array<{ slug: string }>;32 compact?: boolean;33}) {34 const entries = Object.entries(DISCIPLINE_LABELS).map(([slug, name]) => ({35 slug,36 name,37 n: counts.find((c) => c.discipline === slug)?.n ?? 0,38 href: topics.some((t) => t.slug === slug) ? `/topics/${slug}` : `/research?discipline=${slug}`,39 }));40 const sorted = [...entries].sort((a, b) => b.n - a.n || a.name.localeCompare(b.name));41 return (42 <ul43 className={`grid gap-2 ${compact ? "grid-cols-2 sm:grid-cols-3" : "grid-cols-2 sm:grid-cols-3 lg:grid-cols-4"}`}44 >45 {sorted.map((d) => (46 <li key={d.slug}>47 <Link48 href={d.href}49 className="surface card-link flex min-h-[4.25rem] items-center gap-3 px-3.5 py-3 text-sm no-underline"50 aria-label={`${d.name}: ${d.n} ${d.n === 1 ? "paper" : "papers"}`}51 >52 <span53 aria-hidden="true"54 className="grid h-9 w-9 flex-none place-items-center rounded-md text-base"55 style={{56 background: d.n > 0 ? "var(--sci-soft)" : "var(--bg-muted)",57 color: d.n > 0 ? "var(--sci)" : "var(--fg-subtle)",58 fontFamily: "var(--font-serif)",59 }}60 >61 {GLYPH[d.slug] ?? "·"}62 </span>63 <span className="min-w-0">64 <span className="block truncate font-medium">{d.name}</span>65 <span className="subtle block font-mono text-[11px]">66 {d.n} {d.n === 1 ? "paper" : "papers"}67 </span>68 </span>69 </Link>70 </li>71 ))}72 </ul>73 );74}75