Third audit, UI half; side nav on top; request button colors
- Event cards: lazy -640 photo, only nearby slides drawn, a counter past 12 events, past grid paged with Show more - Community map: search over list and grid, 12 per region then Show all, list no longer redrawn on hover - People tiles: one clip check for the list, Show all past 30 - Person pages: 6 events and posts then Show all; excerpts load only the first paragraph - Admin: filter box on long pickers and the QR select, options sent per form, Media thumbnails from the small copy, debounced searches that drop stale answers - Pages show their last data while refreshing after the cache TTL - Side nav stacks above page content (the carousel arrows) - No event request button on National Retreats; request buttons take their section's accent - Version v1.11.1-audit Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
11a4555683
commit
222c9e69a2
22 changed files with 686 additions and 259 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { ArrowRight, CaretDown, X } from "@phosphor-icons/react";
|
||||
import {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useId,
|
||||
useLayoutEffect,
|
||||
|
|
@ -153,6 +154,9 @@ export interface PeopleTilesProps
|
|||
onExpand?: (person: Person | null, group: PeopleGroup | null) => void;
|
||||
}
|
||||
|
||||
/* A list longer than this shows this many tiles, then "Show all". */
|
||||
const SHOW_FIRST = 30;
|
||||
|
||||
const SIZE_FEATURES: Record<PeopleTilesSize, { title: boolean; details: boolean }> = {
|
||||
sm: { title: false, details: false },
|
||||
md: { title: true, details: false },
|
||||
|
|
@ -444,6 +448,21 @@ export function PeopleTilesView({
|
|||
|
||||
const hasPeople = resolvedGroups.length > 0;
|
||||
|
||||
// A long list shows its first SHOW_FIRST tiles until "Show all".
|
||||
const [showAll, setShowAll] = useState(false);
|
||||
const total = resolvedGroups.reduce((sum, group) => sum + group.people.length, 0);
|
||||
const shownGroups = useMemo<PeopleGroup[]>(() => {
|
||||
if (showAll || total <= SHOW_FIRST) return resolvedGroups;
|
||||
let left = SHOW_FIRST;
|
||||
const out: PeopleGroup[] = [];
|
||||
for (const group of resolvedGroups) {
|
||||
if (left <= 0) break;
|
||||
out.push({ ...group, people: group.people.slice(0, left) });
|
||||
left -= group.people.length;
|
||||
}
|
||||
return out;
|
||||
}, [resolvedGroups, showAll, total]);
|
||||
|
||||
// How much room a row has, and one tile's width and gap there, in
|
||||
// px: the probe carries --pl-w and --pl-gap, so the CSS stays the
|
||||
// one place that sizes tiles.
|
||||
|
|
@ -463,6 +482,34 @@ export function PeopleTilesView({
|
|||
return () => observer.disconnect();
|
||||
}, [overflow, hasPeople]);
|
||||
|
||||
// Which captions are cut off, every tile in one pass: after each
|
||||
// render that can change it (the room, the people, the title line)
|
||||
// and once the web font has arrived, since it changes text widths
|
||||
// without resizing anything.
|
||||
const checkClips = useCallback(() => {
|
||||
const root = rootRef.current;
|
||||
if (!root) return;
|
||||
const next = new Set<string>();
|
||||
for (const caption of root.querySelectorAll<HTMLElement>("[data-clip-key]")) {
|
||||
if (Array.from(caption.children).some((line) => line.scrollHeight > line.clientHeight + 1)) {
|
||||
next.add(caption.dataset.clipKey!);
|
||||
}
|
||||
}
|
||||
setClipped((current) =>
|
||||
current.size === next.size && [...next].every((key) => current.has(key)) ? current : next,
|
||||
);
|
||||
}, []);
|
||||
|
||||
useLayoutEffect(checkClips, [checkClips, room, shownGroups, features.title]);
|
||||
|
||||
useEffect(() => {
|
||||
let live = true;
|
||||
document.fonts?.ready.then(() => live && checkClips());
|
||||
return () => {
|
||||
live = false;
|
||||
};
|
||||
}, [checkClips]);
|
||||
|
||||
// A click anywhere outside the list closes the panel.
|
||||
useEffect(() => {
|
||||
if (!openKey) return undefined;
|
||||
|
|
@ -489,23 +536,13 @@ export function PeopleTilesView({
|
|||
const open = openKey ? findByKey(resolvedGroups, openKey) : null;
|
||||
const oneRow =
|
||||
room !== null && overflow !== "scroll" &&
|
||||
fitsOneRow(resolvedGroups.map((group) => group.people.length), room.width, room.tile, room.gap);
|
||||
fitsOneRow(shownGroups.map((group) => group.people.length), room.width, room.tile, room.gap);
|
||||
const anchored = overflow !== "scroll";
|
||||
const closePanel = () => {
|
||||
setOpenKey(null);
|
||||
onExpand?.(null, null);
|
||||
};
|
||||
|
||||
function markClipped(key: string, isClipped: boolean) {
|
||||
setClipped((current) => {
|
||||
if (current.has(key) === isClipped) return current;
|
||||
const next = new Set(current);
|
||||
if (isClipped) next.add(key);
|
||||
else next.delete(key);
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
||||
function toggle(group: PeopleGroup, person: Person, index: number) {
|
||||
const key = keyFor(group, person, index);
|
||||
const next = openKey === key ? null : key;
|
||||
|
|
@ -544,7 +581,7 @@ export function PeopleTilesView({
|
|||
>
|
||||
<span ref={probeRef} className="pl__probe" aria-hidden="true" />
|
||||
<div className="pl__groups" data-row={oneRow ? "one" : undefined}>
|
||||
{resolvedGroups.map((group) => (
|
||||
{shownGroups.map((group) => (
|
||||
<section
|
||||
key={group.id}
|
||||
className="pl__group"
|
||||
|
|
@ -598,7 +635,7 @@ export function PeopleTilesView({
|
|||
isOpen={isOpen}
|
||||
panelId={`${baseId}-bio`}
|
||||
onToggle={() => toggle(group, person, index)}
|
||||
onClip={(isClipped) => markClipped(key, isClipped)}
|
||||
clipKey={key}
|
||||
/>
|
||||
{isOpen && anchored && open && (
|
||||
<DetailPanel
|
||||
|
|
@ -617,6 +654,16 @@ export function PeopleTilesView({
|
|||
))}
|
||||
</div>
|
||||
|
||||
{!showAll && total > SHOW_FIRST && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowAll(true)}
|
||||
className="btn mt-4 border border-brand/40 px-5 py-2 text-sm text-link hover:border-brand"
|
||||
>
|
||||
Show all {total}
|
||||
</button>
|
||||
)}
|
||||
|
||||
{open && !anchored && (
|
||||
<DetailPanel
|
||||
id={`${baseId}-bio`}
|
||||
|
|
@ -636,7 +683,7 @@ function Tile({
|
|||
isOpen,
|
||||
panelId,
|
||||
onToggle,
|
||||
onClip,
|
||||
clipKey,
|
||||
}: {
|
||||
person: Person;
|
||||
showTitle: boolean;
|
||||
|
|
@ -644,36 +691,20 @@ function Tile({
|
|||
isOpen: boolean;
|
||||
panelId: string;
|
||||
onToggle: () => void;
|
||||
onClip: (isClipped: boolean) => void;
|
||||
clipKey: string;
|
||||
}) {
|
||||
const title = titleOf(person);
|
||||
const captionRef = useRef<HTMLSpanElement>(null);
|
||||
|
||||
// Every caption is the same height (two lines of name, two of
|
||||
// title), so the row stays even; a name or title that needs more
|
||||
// is cut with an ellipsis. Checked again whenever the tile resizes,
|
||||
// which is also when the web font arrives.
|
||||
useLayoutEffect(() => {
|
||||
const caption = captionRef.current;
|
||||
if (!caption) return undefined;
|
||||
const check = () =>
|
||||
onClip(
|
||||
Array.from(caption.children).some((line) => line.scrollHeight > line.clientHeight + 1),
|
||||
);
|
||||
check();
|
||||
const observer = new ResizeObserver(check);
|
||||
observer.observe(caption);
|
||||
return () => observer.disconnect();
|
||||
// onClip is a fresh closure each render; the name and title are
|
||||
// what can change the answer.
|
||||
}, [person.name, title, showTitle]);
|
||||
|
||||
// is cut with an ellipsis, and the list (checkClips) gives it the
|
||||
// down arrow.
|
||||
const content = (
|
||||
<span className="pl__frame">
|
||||
<span className="pl__photo">
|
||||
<Photo src={mediaUrl(person.photo)} name={person.name} />
|
||||
</span>
|
||||
<span ref={captionRef} className="pl__caption" data-title={showTitle ? "on" : "off"}>
|
||||
<span className="pl__caption" data-clip-key={clipKey} data-title={showTitle ? "on" : "off"}>
|
||||
<span className="pl__name">{person.name}</span>
|
||||
{showTitle && title && <span className="pl__title">{title}</span>}
|
||||
</span>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue