import { useId, useState, type AnchorHTMLAttributes, type ButtonHTMLAttributes, type ReactNode, } from "react"; import ArrowLink from "../../components/ArrowLink.tsx"; import type { OrgKind } from "../../lib/hrefs.ts"; import type { OrganizationListItem } from "../../lib/useContent.ts"; import { areasSentence, initialsFor, orgPath, useOrganizations, } from "../../data/organizations.js"; /* ═══════════════════════════════════════════════════════════════ ORGANIZATION LIST — VERTICAL A stack of organizations, each collapsed to a line and expandable for the rest. Every row carries two ways out: an arrow through to that organization's page on this site, and a labelled button out to its own site when it has one. Nothing here is region-specific. It asks for a kind and renders what comes back, so the same section lists partners or chapters by changing one prop: org.details?.scope} /> Kind-specific extras (the areas a region covers, the chapters inside it) come from `details` and render only when present, so a partner row simply doesn't have them. ═══════════════════════════════════════════════════════════════ */ const LOGO_BASE = "/org-logos/"; const MUTED = "#7a9299"; const RULE = "#cfe3e7"; const INK = "#2c4a50"; const FALLBACK_COLOR = "#4a6b72"; /* ── Row button ─────────────────────────────────────────────── Deliberately a sibling of the summary button rather than inside it — a link nested in a button is invalid, and a screen reader announces the whole row as one confused control. ───────────────────────────────────────────────────────────── */ type RowButtonProps = { as?: "a" | "button"; color: string; children: ReactNode; } & AnchorHTMLAttributes & ButtonHTMLAttributes; function RowButton({ as: As = "button", color, children, ...rest }: RowButtonProps) { return ( {children} ); } function OrgMark({ org, color, }: { org: Pick; color: string; }) { const [failed, setFailed] = useState(false); if (org.logo && !failed) { return ( setFailed(true)} className="h-8 w-8 object-contain shrink-0" /> ); } if (org.color) { return (