The reader (ReaderView.tsx) now reads an icon-only link's label, puts a card's link on its first line or picture when it has no heading, gives each item of a row of facts or links its own line, keeps line breaks, skips what CSS hides, turns a form into one line saying it can't be used there, shows empty table cells as "-", keeps section and heading ids so #links land, and opens file links as files. What it can't read draws its own text version (useReadingMode()): the hero, pathfinder, front page history, event lists (every event, past ones too), org lists and groups map (every region and group, linked), history timeline (every year open), schedules (every day, fold-outs included), people tiles (everyone, with details) and videos. Also: org names are linked headings, heading levels fixed where cards repeated their section's, Team pages lose the doubled "Members", Giving links the treasurer's email and names Church Center. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
221 lines
6.7 KiB
TypeScript
221 lines
6.7 KiB
TypeScript
import { ArrowUpRight } from '@phosphor-icons/react';
|
|
import { Link } from "react-router-dom";
|
|
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'
|
|
import { useReadingMode } from '../../lib/readingMode.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.
|
|
|
|
<OrgListCards kind="partner" pageLabel="Partner page" />
|
|
|
|
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";
|
|
|
|
/* Under a block title the card names are a level below it. */
|
|
function OrgCard({ org, accent, pageLabel, siteLabel, titled }) {
|
|
const color = org.color || accent;
|
|
const path = orgPath(org);
|
|
const reading = useReadingMode();
|
|
const Name = titled ? "h4" : "h3";
|
|
|
|
// 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 (
|
|
<div
|
|
className="p-4 sm:p-6 h-full flex flex-col transition-transform duration-200 hover:scale-[1.01]"
|
|
style={{ border: `1px solid ${color}`, background: "var(--color-surface)" }}
|
|
>
|
|
<div className="flex items-start gap-3 sm:gap-4">
|
|
<OrgLogo org={org} color={color} size="h-10 w-10 sm:h-14 sm:w-14" />
|
|
|
|
<div className="min-w-0 flex-1">
|
|
<Name className="text-lg sm:text-xl font-bold leading-tight [overflow-wrap:anywhere]" style={{ color }}>
|
|
{path ? <Link to={path}>{org.name}</Link> : org.name}
|
|
</Name>
|
|
{subtitle && (
|
|
<p className="text-sm mt-0.5" style={{ color: MUTED }}>
|
|
{subtitle}
|
|
</p>
|
|
)}
|
|
</div>
|
|
|
|
{/* Top-right rather than in the footer: the footer holds
|
|
outbound links, and the arrow goes somewhere different
|
|
in kind, deeper into this site. Reading mode has the
|
|
name's link and leaves it out. */}
|
|
{path && !reading && (
|
|
<ArrowLink
|
|
to={path}
|
|
label={`${org.name}: ${pageLabel}`}
|
|
color={color}
|
|
/>
|
|
)}
|
|
</div>
|
|
|
|
{org.description?.length > 0 && (
|
|
<p
|
|
className="mt-4 text-sm leading-relaxed line-clamp-4"
|
|
style={{ color: INK }}
|
|
>
|
|
{org.description[0]}
|
|
</p>
|
|
)}
|
|
|
|
{/* mt-auto pins the footer so buttons line up across a row
|
|
however much text each card carries. */}
|
|
<div className="mt-auto pt-5 flex flex-wrap gap-2">
|
|
{org.website && (
|
|
<a
|
|
href={org.website}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
className="py-2 px-4 font-bold text-sm transition-transform duration-200 hover:scale-105"
|
|
style={{ border: `1px solid ${color}`, color }}
|
|
>
|
|
{siteLabel} <ArrowUpRight size="1em" weight="bold" className="inline align-[-0.125em]" aria-hidden="true" />
|
|
</a>
|
|
)}
|
|
|
|
{org.email && (
|
|
<a
|
|
href={`mailto:${org.email}`}
|
|
className="py-2 px-4 font-bold text-sm transition-transform duration-200 hover:scale-105"
|
|
style={{ border: `1px solid ${color}`, color }}
|
|
>
|
|
Contact
|
|
</a>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function Block({ title, orgs, accent, pageLabel, siteLabel }) {
|
|
if (orgs.length === 0) return null;
|
|
|
|
return (
|
|
<section className="mb-12">
|
|
{title && (
|
|
<h3 className="text-xl font-bold mb-5" style={{ color: FALLBACK_COLOR }}>
|
|
{title}
|
|
</h3>
|
|
)}
|
|
|
|
<div
|
|
className="grid gap-5 items-stretch"
|
|
style={{
|
|
gridTemplateColumns: `repeat(auto-fill, minmax(min(${CARD_MIN}, 100%), 1fr))`,
|
|
}}
|
|
>
|
|
{orgs.map(org => (
|
|
<OrgCard
|
|
key={org.id}
|
|
org={org}
|
|
accent={accent}
|
|
pageLabel={pageLabel}
|
|
siteLabel={siteLabel}
|
|
titled={!!title}
|
|
/>
|
|
))}
|
|
</div>
|
|
</section>
|
|
);
|
|
}
|
|
|
|
|
|
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 => (
|
|
<div className="mx-auto px-8 md:px-12" style={{ maxWidth: GRID_MAX }}>
|
|
{children}
|
|
</div>
|
|
);
|
|
|
|
if (loading && organizations.length === 0) {
|
|
return shell(
|
|
<div className="skeleton" role="status" aria-label="Loading organizations" />
|
|
);
|
|
}
|
|
|
|
if (error && organizations.length === 0) {
|
|
return shell(
|
|
<p className="font-semibold" style={{ color: accentText(accent) }}>
|
|
· This list couldn't be loaded just now, please try again shortly ·
|
|
</p>
|
|
);
|
|
}
|
|
|
|
if (organizations.length === 0) {
|
|
return shell(
|
|
<p className="font-semibold" style={{ color: accentText(accent) }}>
|
|
{empty}
|
|
</p>
|
|
);
|
|
}
|
|
|
|
const sorted = sort ? [...organizations].sort(sort) : organizations;
|
|
|
|
// No groups given means one undivided grid.
|
|
if (!groups || !groupBy) {
|
|
return shell(
|
|
<Block
|
|
title={title}
|
|
orgs={sorted}
|
|
accent={accent}
|
|
pageLabel={pageLabel}
|
|
siteLabel={siteLabel}
|
|
/>
|
|
);
|
|
}
|
|
|
|
return shell(
|
|
groups.map(group => (
|
|
<Block
|
|
key={group.key}
|
|
title={group.title}
|
|
orgs={sorted.filter(org => groupBy(org) === group.key)}
|
|
accent={accent}
|
|
pageLabel={group.pageLabel ?? pageLabel}
|
|
siteLabel={group.siteLabel ?? siteLabel}
|
|
/>
|
|
))
|
|
);
|
|
}
|