import { ArrowUpRight } from '@phosphor-icons/react';
import ArrowLink from "../../components/ArrowLink.tsx";
import OrgLogo from "../../components/OrgLogo.tsx";
import {
orgPath,
useOrganizations,
byName,
} from "../../lib/organizations.ts";
import { accentText } from '../../lib/color.ts'
/* ═══════════════════════════════════════════════════════════════
ORGANIZATION LIST: CARDS
A grid of organization cards. No toggle: this view is the grid,
which is why the section that uses it declares no `views` in the
page manifest and gets no control in its heading.
Where the vertical list expands in place, a card links out. The
card carries as much as fits at a glance and the organization's
own page carries the rest, so nothing here reads a `blocks`
array, only the short card description.
═══════════════════════════════════════════════════════════════ */
const MUTED = "var(--color-muted)";
const INK = "var(--color-body)";
const FALLBACK_COLOR = "#3b5456";
/* Wide enough for a logo beside two lines of text, narrow enough
that three fit on a laptop. The grid drops a column rather than
squeezing below this. */
const CARD_MIN = "20rem";
const GRID_MAX = "88rem";
function OrgCard({ org, accent, pageLabel, siteLabel }) {
const color = org.color || accent;
const path = orgPath(org);
// Tagline first, then where they are. Partners often have one and
// not the other, so this is the line that's most likely to say
// something useful.
const subtitle = org.tagline || org.location_label;
return (
{org.name}
{subtitle && (
{subtitle}
)}
{/* Top-right rather than in the footer: the footer holds
outbound links, and the arrow goes somewhere different
in kind, deeper into this site. */}
{path && (
)}
{org.description?.length > 0 && (
{org.description[0]}
)}
{/* mt-auto pins the footer so buttons line up across a row
however much text each card carries. */}
);
}
function Block({ title, orgs, accent, pageLabel, siteLabel }) {
if (orgs.length === 0) return null;
return (
{title && (
{title}
)}
{orgs.map(org => (
))}
);
}
export default function OrgListCards({
kind,
title,
groups,
groupBy,
accent = FALLBACK_COLOR,
pageLabel = "Learn more",
siteLabel = "Visit site",
sort = byName,
empty = "Nothing to show here yet.",
}) {
const { organizations, loading, error } = useOrganizations(kind);
const shell = children => (
{children}
);
if (loading && organizations.length === 0) {
return shell(
);
}
if (error && organizations.length === 0) {
return shell(
· This list couldn't be loaded just now, please try again shortly ·
);
}
if (organizations.length === 0) {
return shell(
{empty}
);
}
const sorted = sort ? [...organizations].sort(sort) : organizations;
// No groups given means one undivided grid.
if (!groups || !groupBy) {
return shell(
);
}
return shell(
groups.map(group => (
groupBy(org) === group.key)}
accent={accent}
pageLabel={group.pageLabel ?? pageLabel}
siteLabel={group.siteLabel ?? siteLabel}
/>
))
);
}