Reading mode: every page and section reads as text
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>
This commit is contained in:
parent
c79910ef8d
commit
27e5fbd690
24 changed files with 788 additions and 180 deletions
|
|
@ -18,6 +18,7 @@ import { isBadId, personHref } from "../lib/hrefs.ts";
|
|||
import { mediaUrl, initials } from "../lib/media.ts";
|
||||
import { useSmallImage } from "../lib/useSmallImage.ts";
|
||||
import { paletteFill } from "../lib/color.ts";
|
||||
import { useReadingMode } from "../lib/readingMode.ts";
|
||||
import "./PeopleTiles.css";
|
||||
|
||||
/**
|
||||
|
|
@ -71,6 +72,10 @@ import "./PeopleTiles.css";
|
|||
* with no photo gets their initials on a palette color
|
||||
* (paletteFill in color.ts).
|
||||
*
|
||||
* Reading mode (readingMode.ts) gets everyone, no "Show all", each
|
||||
* a heading (linked to their profile) and their title, facts and bio
|
||||
* as lines (ReadingPeople).
|
||||
*
|
||||
* Field names follow the API (is_owner, location_label), so a row
|
||||
* from /api/teams/:id/people drops in unchanged.
|
||||
*
|
||||
|
|
@ -122,7 +127,8 @@ export interface PeopleGroupInput extends Omit<PeopleGroup, "people"> {
|
|||
|
||||
export interface TeamSpec {
|
||||
id: string;
|
||||
/** Heading for the members group. Defaults to the team's name. */
|
||||
/** Heading for the members group beside a lead group, or among
|
||||
* several teams. Defaults to the team's name. */
|
||||
label?: string;
|
||||
/** Heading for the lead group. Defaults to the lead's own title. */
|
||||
leadLabel?: string;
|
||||
|
|
@ -146,6 +152,9 @@ export interface PeopleTilesProps
|
|||
align?: "start" | "center";
|
||||
accent?: string;
|
||||
tilt?: boolean;
|
||||
/** The group labels' heading level, by what they sit under (3 under
|
||||
* a section's h2). In reading mode the names are one level under. */
|
||||
headingLevel?: 3 | 4 | 5;
|
||||
/** How long a fetched team or person is reused, in ms. */
|
||||
ttl?: number;
|
||||
emptyMessage?: string;
|
||||
|
|
@ -372,8 +381,10 @@ function buildTeamGroups(
|
|||
return [
|
||||
{
|
||||
id: data.team.id,
|
||||
// One unlabeled team needs no heading; several always do.
|
||||
label: teamCount > 1 || spec.label ? name : undefined,
|
||||
// One team alone needs no heading (its page or section names
|
||||
// it); several always do. `label` names the members beside a
|
||||
// lead group.
|
||||
label: teamCount > 1 ? name : undefined,
|
||||
accent,
|
||||
people: data.people,
|
||||
},
|
||||
|
|
@ -408,6 +419,7 @@ export function PeopleTilesView({
|
|||
accent,
|
||||
tilt = false,
|
||||
emptyMessage = "No one listed yet.",
|
||||
headingLevel = 3,
|
||||
onExpand,
|
||||
className = "",
|
||||
style,
|
||||
|
|
@ -426,6 +438,7 @@ export function PeopleTilesView({
|
|||
const [clipped, setClipped] = useState<ReadonlySet<string>>(() => new Set());
|
||||
const rootRef = useRef<HTMLDivElement>(null);
|
||||
const probeRef = useRef<HTMLSpanElement>(null);
|
||||
const reading = useReadingMode();
|
||||
|
||||
const resolvedSize: PeopleTilesSize = SIZE_FEATURES[size] ? size : "md";
|
||||
const features = SIZE_FEATURES[resolvedSize];
|
||||
|
|
@ -532,6 +545,8 @@ export function PeopleTilesView({
|
|||
if (!resolvedGroups.length) {
|
||||
return emptyMessage ? <p className="pl__empty">{emptyMessage}</p> : null;
|
||||
}
|
||||
if (reading) return <ReadingPeople groups={resolvedGroups} level={headingLevel} />;
|
||||
const Label = `h${headingLevel}` as "h3";
|
||||
|
||||
const open = openKey ? findByKey(resolvedGroups, openKey) : null;
|
||||
const oneRow =
|
||||
|
|
@ -598,7 +613,7 @@ export function PeopleTilesView({
|
|||
>
|
||||
{(group.label || group.note) && (
|
||||
<header className="pl__group-head">
|
||||
{group.label && <h3 className="pl__group-label">{group.label}</h3>}
|
||||
{group.label && <Label className="pl__group-label">{group.label}</Label>}
|
||||
{group.note && <p className="pl__group-note">{group.note}</p>}
|
||||
</header>
|
||||
)}
|
||||
|
|
@ -883,6 +898,52 @@ function DetailPanel({
|
|||
);
|
||||
}
|
||||
|
||||
/* Reading mode: every person and what their details panel says. */
|
||||
function ReadingPeople({ groups, level }: { groups: PeopleGroup[]; level: 3 | 4 | 5 }) {
|
||||
const Label = `h${level}` as "h3";
|
||||
return (
|
||||
<div>
|
||||
{groups.map((group) => {
|
||||
// Names sit under the group's label, or take its place.
|
||||
const Name = `h${group.label ? level + 1 : level}` as "h4";
|
||||
return (
|
||||
<section key={group.id}>
|
||||
{group.label && <Label>{group.label}</Label>}
|
||||
{group.note && <p>{group.note}</p>}
|
||||
{group.people.map((person, index) => {
|
||||
const href = profileHref(person);
|
||||
const title = titleOf(person);
|
||||
const org = resolveOrg(person.org);
|
||||
const bio = Array.isArray(person.bio) ? person.bio : [person.bio];
|
||||
return (
|
||||
<div key={keyFor(group, person, index)}>
|
||||
<Name>{href ? <Link to={href}>{person.name}</Link> : person.name}</Name>
|
||||
{title && <p>{title}</p>}
|
||||
{person.pronouns && <p>Pronouns: {person.pronouns}</p>}
|
||||
{org && (
|
||||
<p>
|
||||
Home organization: {org.href ? <a href={org.href}>{org.name}</a> : org.name}
|
||||
</p>
|
||||
)}
|
||||
{person.location_label && <p>Based in: {person.location_label}</p>}
|
||||
{person.public_email && (
|
||||
<p>
|
||||
Email: <a href={`mailto:${person.public_email}`}>{person.public_email}</a>
|
||||
</p>
|
||||
)}
|
||||
{bio.filter(Boolean).map((paragraph, i) => (
|
||||
<p key={i}>{paragraph}</p>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</section>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Chevron() {
|
||||
return (
|
||||
<CaretDown size={12} weight="bold" aria-hidden="true" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue