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
|
|
@ -18,6 +18,7 @@
|
|||
in a row.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { useState, type ReactNode } from 'react'
|
||||
import { Link, useParams } from 'react-router-dom'
|
||||
|
||||
import PageShell, { type ShellSection } from '../components/PageShell.tsx'
|
||||
|
|
@ -39,6 +40,9 @@ import { accentText, BRAND } from '../lib/color.ts'
|
|||
|
||||
const BODY = 'var(--color-muted)'
|
||||
|
||||
/* Events and posts show this many, then "Show all". */
|
||||
const SHOW_FIRST = 6
|
||||
|
||||
/* affiliations.role, for a row with no title of its own. */
|
||||
const ROLE_LABEL: Record<string, string> = {
|
||||
lead: 'Lead',
|
||||
|
|
@ -127,13 +131,17 @@ export default function PersonDetail() {
|
|||
accent,
|
||||
content: (
|
||||
<div className="max-w-6xl mx-auto px-6">
|
||||
<ul className="space-y-5">
|
||||
{person.events.map((event) => (
|
||||
<li key={event.id}>
|
||||
<EventRow event={event} accent={accent} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<Capped items={person.events} accent={accent}>
|
||||
{(events) => (
|
||||
<ul className="space-y-5">
|
||||
{events.map((event) => (
|
||||
<li key={event.id}>
|
||||
<EventRow event={event} accent={accent} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</Capped>
|
||||
</div>
|
||||
),
|
||||
})
|
||||
|
|
@ -193,11 +201,15 @@ export default function PersonDetail() {
|
|||
accent,
|
||||
content: (
|
||||
<div className="max-w-6xl mx-auto px-6">
|
||||
<ul className="grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{person.posts.map((post) => (
|
||||
<PostCard key={post.id} post={post} accent={accent} />
|
||||
))}
|
||||
</ul>
|
||||
<Capped items={person.posts} accent={accent}>
|
||||
{(posts) => (
|
||||
<ul className="grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{posts.map((post) => (
|
||||
<PostCard key={post.id} post={post} accent={accent} />
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</Capped>
|
||||
</div>
|
||||
),
|
||||
})
|
||||
|
|
@ -208,6 +220,35 @@ export default function PersonDetail() {
|
|||
)
|
||||
}
|
||||
|
||||
/* The first SHOW_FIRST of a list, then a button for the rest. */
|
||||
function Capped<T>({
|
||||
items,
|
||||
accent,
|
||||
children,
|
||||
}: {
|
||||
items: T[]
|
||||
accent: string
|
||||
children: (shown: T[]) => ReactNode
|
||||
}) {
|
||||
const [all, setAll] = useState(false)
|
||||
const more = !all && items.length > SHOW_FIRST
|
||||
return (
|
||||
<>
|
||||
{children(more ? items.slice(0, SHOW_FIRST) : items)}
|
||||
{more && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setAll(true)}
|
||||
className="btn mt-6 px-5 py-2 text-sm"
|
||||
style={{ border: `1px solid ${accent}`, color: accentText(accent) }}
|
||||
>
|
||||
Show all {items.length}
|
||||
</button>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
/* ── The strip of facts under the heading ────────────────────── */
|
||||
|
||||
function Facts({ person, accent }: { person: PersonRecord; accent: string }) {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@ const PROGRAM_START_YEAR = 2000
|
|||
/* Each preset: the view it draws, its fixed props, its toggle (the
|
||||
section's own view picks the first one) and its Request button.
|
||||
The keys are the CHECK list on page_sections.preset. */
|
||||
/* Event sections in these scopes offer no Request button. */
|
||||
const NO_EVENT_REQUEST_SCOPES = ['national']
|
||||
|
||||
const PRESETS: Record<string, (section: SitePageSection) => Record<string, any>> = {
|
||||
community_blog: () => ({
|
||||
Component: CommunityBlog,
|
||||
|
|
@ -69,7 +72,10 @@ const PRESETS: Record<string, (section: SitePageSection) => Record<string, any>>
|
|||
}),
|
||||
events: (section) => ({
|
||||
Component: EventListCards,
|
||||
request: { type: 'event', label: 'Add or update an event' },
|
||||
// NGU's own national retreats aren't the public's to add.
|
||||
request: NO_EVENT_REQUEST_SCOPES.includes(section.scope_id ?? '')
|
||||
? undefined
|
||||
: { type: 'event', label: 'Add or update an event' },
|
||||
props: { scope: section.scope_id ?? undefined, type: section.event_type ?? undefined },
|
||||
views: {
|
||||
options: ['carousel', 'grid'],
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ import { get, post, patch, del, ApiError } from "../../lib/api.ts";
|
|||
import { isUnauthorized, useAuth } from "../../lib/auth.tsx";
|
||||
import { useAdminDetail } from "../../lib/adminTitle.tsx";
|
||||
import { useWideAdminPage } from "../../lib/adminWidth.tsx";
|
||||
import { ADMIN_ENTITIES, slugify } from "../../lib/adminSchema.ts";
|
||||
import { ADMIN_ENTITIES, optionsPath, slugify } from "../../lib/adminSchema.ts";
|
||||
import { atLeast } from "../../lib/roles.ts";
|
||||
import { Field, FieldGrid, Repeater, getPath, setPath } from "../../components/admin/fields.tsx";
|
||||
import {
|
||||
|
|
@ -164,7 +164,8 @@ export default function EntityEdit() {
|
|||
setLoading(true);
|
||||
setErrors({});
|
||||
try {
|
||||
const opts = await get("/admin/options", { ttl: 60_000 });
|
||||
const path = optionsPath(manifest);
|
||||
const opts = path ? await get(path, { ttl: 60_000 }) : { options: {} };
|
||||
setOptions(opts.options);
|
||||
|
||||
if (isNew) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import { Link, Navigate, useNavigate, useParams, useSearchParams } from "react-r
|
|||
|
||||
import { get, upload, ApiError } from "../../lib/api.ts";
|
||||
import { isUnauthorized, useAuth } from "../../lib/auth.tsx";
|
||||
import { ADMIN_ENTITIES } from "../../lib/adminSchema.ts";
|
||||
import { ADMIN_ENTITIES, optionsPath } from "../../lib/adminSchema.ts";
|
||||
import { atLeast } from "../../lib/roles.ts";
|
||||
|
||||
export default function EntityList() {
|
||||
|
|
@ -50,9 +50,10 @@ export default function EntityList() {
|
|||
setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const optsPath = optionsPath(manifest.list.filters);
|
||||
const [list, opts] = await Promise.all([
|
||||
get(`/admin/${manifest.key}?${params}`, { ttl: 0 }),
|
||||
get("/admin/options", { ttl: 60_000 }),
|
||||
optsPath ? get(optsPath, { ttl: 60_000 }) : { options: {} },
|
||||
]);
|
||||
setRows(list.rows);
|
||||
setTotal(list.total);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { EVENT_TYPES, eventTypeLabel } from "../../lib/eventTypes.ts";
|
|||
import { seriesLabel } from "../../lib/eventSeries.ts";
|
||||
import PlatformIcon from "../../components/PlatformIcon.tsx";
|
||||
import { mediaUrl } from "../../lib/media.ts";
|
||||
import { useSmallImage } from "../../lib/useSmallImage.ts";
|
||||
import Logo from "../../components/Logo.tsx";
|
||||
import { accentText, withAlpha, readableOn, BRAND } from '../../lib/color.ts'
|
||||
|
||||
|
|
@ -45,16 +46,24 @@ const CARD_BG = "var(--color-surface)"; // sits under every card, photo or not
|
|||
const CARD_IMAGE_VEIL =
|
||||
"linear-gradient(to bottom, color-mix(in srgb, var(--color-surface) 90%, transparent), color-mix(in srgb, var(--color-surface) 78%, transparent))";
|
||||
|
||||
/* The card's background layers, top first: the veil and photo if it
|
||||
has one, then the plain surface. */
|
||||
function cardBackground(ev) {
|
||||
const layers: string[] = [];
|
||||
const image = mediaUrl(ev.card_image);
|
||||
if (image) {
|
||||
layers.push(CARD_IMAGE_VEIL, `url(${JSON.stringify(image)}) center / cover no-repeat`);
|
||||
}
|
||||
layers.push(CARD_BG);
|
||||
return layers.join(", ");
|
||||
/* The card's photo, behind its veil: an <img> rather than a CSS
|
||||
background, so it loads lazily and takes the 640px copy first
|
||||
(useSmallImage), falling back to the full file. */
|
||||
function CardImage({ src }) {
|
||||
const img = useSmallImage(src);
|
||||
if (img.failed) return null;
|
||||
return (
|
||||
<>
|
||||
<img
|
||||
src={img.src}
|
||||
onError={img.onError}
|
||||
alt=""
|
||||
loading="lazy"
|
||||
className="absolute inset-0 -z-10 h-full w-full object-cover"
|
||||
/>
|
||||
<div aria-hidden="true" className="absolute inset-0 -z-10" style={{ background: CARD_IMAGE_VEIL }} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
/* ── Grid view ────────────────────────────────────────────────
|
||||
|
|
@ -71,8 +80,10 @@ const GRID_MAX = `calc(${MAX_COLS} * 38rem)`;
|
|||
const GRID_TEMPLATE = `repeat(auto-fill, minmax(min(${CARD_MIN}, 100%), 1fr))`;
|
||||
|
||||
/* Collapsed past-events strip: how much shows, and the downward
|
||||
fade applied while it's collapsed. */
|
||||
fade applied while it's collapsed. Collapsed, only a row's worth
|
||||
of cards is drawn; open, PAST_PAGE at a time, newest first. */
|
||||
const PAST_PEEK = "10rem";
|
||||
const PAST_PAGE = 12;
|
||||
const PAST_FADE = "linear-gradient(to bottom, black 0%, black 45%, transparent 100%)";
|
||||
|
||||
/* ── Carousel sizing ──────────────────────────────────────────
|
||||
|
|
@ -86,6 +97,14 @@ const SLIDE = `calc(${CARD} + ${GAP})`;
|
|||
const HALF_SLIDE = `calc(${CARD} / 2)`;
|
||||
const FADE_DIST = "18rem";
|
||||
|
||||
/* Slides this far either side of the current one are drawn; the
|
||||
rest are empty slots of the same width (past FADE_DIST they're
|
||||
invisible anyway). Two, so the card sliding in during a turn is
|
||||
already there. */
|
||||
const NEAR = 2;
|
||||
/* Above this many events, a "7 / 200" count instead of a dot each. */
|
||||
const MAX_DOTS = 12;
|
||||
|
||||
const EDGE_FADE = `linear-gradient(to right,
|
||||
transparent calc(50% - (${HALF_SLIDE} + ${FADE_DIST})),
|
||||
black calc(50% - ${HALF_SLIDE}),
|
||||
|
|
@ -177,12 +196,12 @@ export function Card({
|
|||
|
||||
return (
|
||||
<div
|
||||
className={`text-ink overflow-hidden shadow-2xl h-full flex flex-col ${
|
||||
className={`relative isolate text-ink overflow-hidden shadow-2xl h-full flex flex-col ${
|
||||
compact ? "ev-card" : ""
|
||||
}`}
|
||||
style={{
|
||||
border: `1px solid ${color}`,
|
||||
background: cardBackground(ev),
|
||||
background: CARD_BG,
|
||||
filter: past ? "saturate(0.75)" : "none",
|
||||
pointerEvents: interactive ? "auto" : "none",
|
||||
}}
|
||||
|
|
@ -190,6 +209,7 @@ export function Card({
|
|||
// past event) keeps its links out of the tab order too.
|
||||
inert={!interactive}
|
||||
>
|
||||
{ev.card_image && <CardImage src={mediaUrl(ev.card_image)} />}
|
||||
<div className={`flex-1 flex flex-col ${compact ? "p-6 sm:p-8" : "p-6 sm:p-10"}`}>
|
||||
{compact ? (
|
||||
/* ── GRID CARD: layout driven by .ev-grid container queries ── */
|
||||
|
|
@ -443,6 +463,7 @@ export default function EventListCards({
|
|||
|
||||
const [index, setIndex] = useState(0);
|
||||
const [showPast, setShowPast] = useState(false);
|
||||
const [pastShown, setPastShown] = useState(PAST_PAGE);
|
||||
const [activeType, setActiveType] = useState("all");
|
||||
|
||||
/* What this band holds, which is what the chips offer, not the
|
||||
|
|
@ -491,7 +512,10 @@ export default function EventListCards({
|
|||
}, [events]);
|
||||
|
||||
// Grid view splits the list; the carousel still shows everything.
|
||||
const { upcoming, past: pastEvents } = splitByStatus(events);
|
||||
// The list comes oldest first; the past grid reads newest first.
|
||||
const { upcoming, past } = splitByStatus(events);
|
||||
const pastEvents = past.reverse();
|
||||
const pastDrawn = pastEvents.slice(0, showPast ? pastShown : MAX_COLS);
|
||||
|
||||
const prev = () => setIndex(i => Math.max(0, i - 1));
|
||||
const next = () => setIndex(i => Math.min(events.length - 1, i + 1));
|
||||
|
|
@ -610,7 +634,7 @@ export default function EventListCards({
|
|||
style={{ gridTemplateColumns: GRID_TEMPLATE }}
|
||||
aria-hidden={!showPast}
|
||||
>
|
||||
{pastEvents.map(ev => (
|
||||
{pastDrawn.map(ev => (
|
||||
<Card
|
||||
key={ev.id}
|
||||
ev={ev}
|
||||
|
|
@ -624,7 +648,16 @@ export default function EventListCards({
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-center mt-6">
|
||||
<div className="flex flex-wrap justify-center gap-3 mt-6">
|
||||
{showPast && pastShown < pastEvents.length && (
|
||||
<button
|
||||
onClick={() => setPastShown(n => n + PAST_PAGE)}
|
||||
className="btn py-2.5 px-6 transition-all duration-200 hover:scale-105"
|
||||
style={{ border: `1px solid ${accent}`, color: accentText(accent) }}
|
||||
>
|
||||
Show more ({pastEvents.length - pastShown})
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
onClick={() => setShowPast(v => !v)}
|
||||
aria-expanded={showPast}
|
||||
|
|
@ -654,6 +687,9 @@ export default function EventListCards({
|
|||
>
|
||||
{events.map((ev, i) => {
|
||||
const active = i === index;
|
||||
if (Math.abs(i - index) > NEAR) {
|
||||
return <div key={ev.id} className="shrink-0" style={{ width: SLIDE }} aria-hidden="true" />;
|
||||
}
|
||||
return (
|
||||
<div
|
||||
key={ev.id}
|
||||
|
|
@ -716,7 +752,11 @@ export default function EventListCards({
|
|||
>
|
||||
<CaretLeft size={18} weight="bold" aria-hidden="true" />
|
||||
</button>
|
||||
{events.map((e, i) => (
|
||||
{events.length > MAX_DOTS ? (
|
||||
<p className="min-w-20 px-3 text-center text-sm font-bold" style={{ color: accentText(accent) }} aria-live="polite">
|
||||
{index + 1} / {events.length}
|
||||
</p>
|
||||
) : events.map((e, i) => (
|
||||
<button
|
||||
key={e.id}
|
||||
onClick={() => setIndex(i)}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { CaretRight, X } from '@phosphor-icons/react';
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { CaretRight, MagnifyingGlass, X } from '@phosphor-icons/react';
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useCommunity } from "../../lib/useCommunity.ts";
|
||||
import { useOrganization } from "../../lib/useContent.ts";
|
||||
import { Link } from "react-router-dom";
|
||||
|
|
@ -53,6 +53,9 @@ const FALLBACK_COLOR = "#3b5456";
|
|||
black, so an uncolored region takes the same fallback as a card. */
|
||||
const colorOf = (item) => item.color || FALLBACK_COLOR;
|
||||
|
||||
/* A region's grid shows this many cards until "Show all". */
|
||||
const GRID_CAP = 12;
|
||||
|
||||
const US_TITLE = "US Unity Regions";
|
||||
const INTL_TITLE = "International Unity Regions";
|
||||
|
||||
|
|
@ -461,6 +464,29 @@ function RegionBlock({
|
|||
);
|
||||
}
|
||||
|
||||
/* Narrows the list or grid to groups whose name or place has the text. */
|
||||
function GroupSearch({ query, setQuery }) {
|
||||
return (
|
||||
<label className="mb-4 flex items-center gap-2 border border-muted/25 bg-surface px-3 py-2 focus-within:border-brand">
|
||||
<MagnifyingGlass size={16} weight="bold" className="shrink-0 text-muted" aria-hidden="true" />
|
||||
<input
|
||||
type="search"
|
||||
value={query}
|
||||
onChange={e => setQuery(e.target.value)}
|
||||
placeholder="Search groups by name or place"
|
||||
aria-label="Search groups"
|
||||
className="min-w-0 flex-1 bg-transparent text-sm text-body outline-none"
|
||||
/>
|
||||
</label>
|
||||
);
|
||||
}
|
||||
|
||||
const matcher = query => {
|
||||
const q = query.trim().toLowerCase();
|
||||
if (!q) return null;
|
||||
return c => `${c.name ?? ""} ${c.location_label ?? ""}`.toLowerCase().includes(q);
|
||||
};
|
||||
|
||||
/* ═══════════════════════════════════════════════════════════════
|
||||
GRID VIEW
|
||||
One grid per region. Clicking a card's arrow opens a detail
|
||||
|
|
@ -620,17 +646,25 @@ function GroupDetail({ group, region, onClose }) {
|
|||
}
|
||||
|
||||
function GroupGrid({ regions, groups, groupsIn, subtextFor, openId, setOpenId }) {
|
||||
// Only regions that actually have groups get a grid.
|
||||
const [query, setQuery] = useState("");
|
||||
const [expanded, setExpanded] = useState(() => new Set());
|
||||
const match = matcher(query);
|
||||
|
||||
// Only regions that actually have groups (or matches) get a grid.
|
||||
const populated = regions
|
||||
.map(region => ({ region, list: groupsIn(region.id) }))
|
||||
.map(region => ({ region, list: match ? groupsIn(region.id).filter(match) : groupsIn(region.id) }))
|
||||
.filter(({ list }) => list.length > 0);
|
||||
const empty = regions.filter(region => groupsIn(region.id).length === 0);
|
||||
const empty = match ? [] : regions.filter(region => groupsIn(region.id).length === 0);
|
||||
const openGroup = groups.find(c => c.id === openId) || null;
|
||||
|
||||
return (
|
||||
<div className="mx-auto px-8 md:px-12" style={{ maxWidth: CONTENT_MAX }}>
|
||||
<GroupSearch query={query} setQuery={setQuery} />
|
||||
{match && populated.length === 0 && <p className="notice text-sm">No groups match that.</p>}
|
||||
{populated.map(({ region, list }) => {
|
||||
const subtext = subtextFor(region);
|
||||
const all = expanded.has(region.id);
|
||||
const shown = all ? list : list.slice(0, GRID_CAP);
|
||||
return (
|
||||
<section key={region.id} className="mb-12">
|
||||
<div className="flex items-baseline gap-3 mb-1">
|
||||
|
|
@ -667,7 +701,7 @@ function GroupGrid({ regions, groups, groupsIn, subtextFor, openId, setOpenId })
|
|||
gridTemplateColumns: "repeat(auto-fill, minmax(min(22rem, 100%), 1fr))",
|
||||
}}
|
||||
>
|
||||
{list.map(c => (
|
||||
{shown.map(c => (
|
||||
<GroupCard
|
||||
key={c.id}
|
||||
group={c}
|
||||
|
|
@ -677,6 +711,16 @@ function GroupGrid({ regions, groups, groupsIn, subtextFor, openId, setOpenId })
|
|||
/>
|
||||
))}
|
||||
</div>
|
||||
{!all && list.length > GRID_CAP && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setExpanded(prev => new Set(prev).add(region.id))}
|
||||
className="btn mt-4 py-2 px-5 text-sm"
|
||||
style={{ border: `1px solid ${colorOf(region)}`, color: accentText(colorOf(region)) }}
|
||||
>
|
||||
Show all {list.length}
|
||||
</button>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
})}
|
||||
|
|
@ -743,6 +787,7 @@ export default function OrgListMap({ view = "map", accent = FALLBACK_COLOR }) {
|
|||
const [selected, setSelected] = useState<any>(null);
|
||||
const [hovered, setHovered] = useState<any>(null);
|
||||
const [openId, setOpenId] = useState<any>(null); // no card open on arrival
|
||||
const [query, setQuery] = useState("");
|
||||
|
||||
// The list scrolls itself to whatever the map or legend points at.
|
||||
const listRef = useRef<any>(null);
|
||||
|
|
@ -765,9 +810,8 @@ export default function OrgListMap({ view = "map", accent = FALLBACK_COLOR }) {
|
|||
const scrollListTo = el => {
|
||||
const box = listRef.current;
|
||||
if (!box || !el) return;
|
||||
// Only when the list is its own scroll area (lg and up). Below
|
||||
// that it's stacked under the map and scrolling it would fight
|
||||
// the page.
|
||||
// Only when the list is long enough to scroll in its own box;
|
||||
// a short one has nowhere to go.
|
||||
if (box.scrollHeight <= box.clientHeight) return;
|
||||
box.scrollTo({ top: el.offsetTop - 8, behavior: scrollBehavior() });
|
||||
};
|
||||
|
|
@ -792,6 +836,68 @@ export default function OrgListMap({ view = "map", accent = FALLBACK_COLOR }) {
|
|||
if (region) scrollListTo(regionRefs.current[region.id]);
|
||||
};
|
||||
|
||||
/* The list column, built only when what it shows changes: hovering
|
||||
a map tile or legend entry changes `hovered`, which no row reads,
|
||||
so hundreds of groups aren't drawn again for every tile crossed.
|
||||
hoverInList only touches a ref and a state setter, both stable. */
|
||||
const list = useMemo(() => {
|
||||
const match = matcher(query);
|
||||
const block = (region, indent) => {
|
||||
const inRegion = match ? groupsIn(region.id).filter(match) : groupsIn(region.id);
|
||||
if (match && inRegion.length === 0) return null;
|
||||
return (
|
||||
<RegionBlock
|
||||
key={region.id}
|
||||
region={region}
|
||||
groups={inRegion}
|
||||
subtext={subtextFor(region)}
|
||||
indent={indent}
|
||||
regionRefs={regionRefs}
|
||||
groupRefs={groupRefs}
|
||||
selected={selected}
|
||||
setSelected={setSelected}
|
||||
setHovered={hoverInList}
|
||||
/>
|
||||
);
|
||||
};
|
||||
const us = domestic.map(r => block(r, true)).filter(Boolean);
|
||||
const intl = international.map(r => block(r, true)).filter(Boolean);
|
||||
const online = virtual.map(r => block(r, false)).filter(Boolean);
|
||||
return (
|
||||
<>
|
||||
{match && us.length + intl.length + online.length === 0 && (
|
||||
<p className="notice text-sm">No groups match that.</p>
|
||||
)}
|
||||
{us.length > 0 && (
|
||||
<>
|
||||
<h3 className="text-xl font-bold mb-1" style={{ color: FALLBACK_COLOR }}>
|
||||
{US_TITLE}
|
||||
</h3>
|
||||
{us}
|
||||
</>
|
||||
)}
|
||||
|
||||
{intl.length > 0 && (
|
||||
<>
|
||||
<h3
|
||||
className="text-xl font-display font-bold mt-6 mb-1 pt-4"
|
||||
style={{ color: FALLBACK_COLOR, borderTop: `1px solid ${RULE}` }}
|
||||
>
|
||||
{INTL_TITLE}
|
||||
</h3>
|
||||
{intl}
|
||||
</>
|
||||
)}
|
||||
|
||||
{online.length > 0 && (
|
||||
<div className="mt-6 pt-4" style={{ borderTop: `1px solid ${RULE}` }}>
|
||||
{online}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}, [domestic, international, virtual, groupsIn, subtextFor, selected, query]);
|
||||
|
||||
const shell = children => (
|
||||
<div className="mx-auto px-8 md:px-12" style={{ maxWidth: CONTENT_MAX }}>
|
||||
{children}
|
||||
|
|
@ -828,20 +934,6 @@ export default function OrgListMap({ view = "map", accent = FALLBACK_COLOR }) {
|
|||
const shared = { selected, setSelected, hovered, setHovered: hoverOnMap };
|
||||
const onMapIds = new Set(regionAreas.map(a => a.region_id));
|
||||
|
||||
const block = (region, indent) => (
|
||||
<RegionBlock
|
||||
key={region.id}
|
||||
region={region}
|
||||
groups={groupsIn(region.id)}
|
||||
subtext={subtextFor(region)}
|
||||
indent={indent}
|
||||
regionRefs={regionRefs}
|
||||
groupRefs={groupRefs}
|
||||
{...shared}
|
||||
setHovered={hoverInList}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
/* Wider than the section heading above it, the map needs the
|
||||
room. CONTENT_MAX is the knob; drop it toward 72rem to pull
|
||||
|
|
@ -877,26 +969,16 @@ export default function OrgListMap({ view = "map", accent = FALLBACK_COLOR }) {
|
|||
|
||||
{/* List, h-0 + min-h-full makes this column take its height
|
||||
from the map column rather than the other way round, so a
|
||||
long list scrolls instead of stretching the section. */}
|
||||
<div
|
||||
ref={listRef}
|
||||
className="relative lg:h-0 lg:min-h-full overflow-y-auto pr-2"
|
||||
>
|
||||
<h3 className="text-xl font-bold mb-1" style={{ color: FALLBACK_COLOR }}>
|
||||
{US_TITLE}
|
||||
</h3>
|
||||
{domestic.map(r => block(r, true))}
|
||||
|
||||
<h3
|
||||
className="text-xl font-display font-bold mt-6 mb-1 pt-4"
|
||||
style={{ color: FALLBACK_COLOR, borderTop: `1px solid ${RULE}` }}
|
||||
long list scrolls instead of stretching the section. Below
|
||||
lg, stacked under the map, it's capped at about a screenful
|
||||
instead, so hundreds of groups don't run down the page. */}
|
||||
<div className="flex min-h-0 flex-col lg:h-0 lg:min-h-full">
|
||||
<GroupSearch query={query} setQuery={setQuery} />
|
||||
<div
|
||||
ref={listRef}
|
||||
className="relative max-h-[36rem] min-h-0 flex-1 overflow-y-auto pr-2 lg:max-h-none"
|
||||
>
|
||||
{INTL_TITLE}
|
||||
</h3>
|
||||
{international.map(r => block(r, true))}
|
||||
|
||||
<div className="mt-6 pt-4" style={{ borderTop: `1px solid ${RULE}` }}>
|
||||
{virtual.map(r => block(r, false))}
|
||||
{list}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import { useNavSections } from '../../lib/navSections.ts'
|
|||
import { awardHref, blogHref, eventHref, orgHref, personHref, teamHref } from '../../lib/hrefs.ts'
|
||||
import { siteUrl } from '../../lib/site.ts'
|
||||
import { useDirectory, type Directory } from '../../lib/useContent.ts'
|
||||
import { FILTER_FROM, OptionFilter, narrow } from '../../components/OptionFilter.tsx'
|
||||
import { accentText, BRAND } from '../../lib/color.ts'
|
||||
|
||||
const MUTED = 'var(--color-muted)'
|
||||
|
|
@ -269,6 +270,16 @@ export default function QrCodeMaker() {
|
|||
|
||||
const groups = useMemo(() => groupsFor(kind, directory), [kind, directory])
|
||||
const choices = useMemo(() => groups.flatMap((group) => group.choices), [groups])
|
||||
// Past FILTER_FROM records, a box above the select narrows them;
|
||||
// the one chosen always stays.
|
||||
const [needle, setNeedle] = useState('')
|
||||
const shownGroups = useMemo(
|
||||
() =>
|
||||
groups
|
||||
.map((group) => ({ ...group, choices: narrow(group.choices, needle, (c) => c.label, (c) => c.path === path) }))
|
||||
.filter((group) => group.choices.length > 0),
|
||||
[groups, needle, path],
|
||||
)
|
||||
|
||||
// A new kind, or the directory arriving, can leave the current
|
||||
// path outside the list; fall back to its first entry.
|
||||
|
|
@ -308,7 +319,10 @@ export default function QrCodeMaker() {
|
|||
return (
|
||||
<div className="grid gap-10 lg:grid-cols-2 lg:items-start">
|
||||
<div className="space-y-5">
|
||||
<Select id="qr-kind" label="What to link to" value={kind} onChange={(v) => setKind(v as Kind)}>
|
||||
<Select id="qr-kind" label="What to link to" value={kind} onChange={(v) => {
|
||||
setKind(v as Kind)
|
||||
setNeedle('')
|
||||
}}>
|
||||
{KINDS.map(([value, label]) => (
|
||||
<option key={value} value={value}>
|
||||
{label}
|
||||
|
|
@ -343,33 +357,38 @@ export default function QrCodeMaker() {
|
|||
) : choices.length === 0 ? (
|
||||
<p style={{ color: MUTED }}>Nothing published here yet.</p>
|
||||
) : (
|
||||
<Select
|
||||
id="qr-target"
|
||||
label={kind === 'pages' ? 'Page' : 'Which one'}
|
||||
value={path}
|
||||
onChange={(v) => {
|
||||
setPath(v)
|
||||
setSection('')
|
||||
}}
|
||||
>
|
||||
{groups.map((group, i) =>
|
||||
group.label ? (
|
||||
<optgroup key={group.label} label={group.label}>
|
||||
{group.choices.map((c) => (
|
||||
<option key={c.path} value={c.path}>
|
||||
<div>
|
||||
<Select
|
||||
id="qr-target"
|
||||
label={kind === 'pages' ? 'Page' : 'Which one'}
|
||||
value={path}
|
||||
onChange={(v) => {
|
||||
setPath(v)
|
||||
setSection('')
|
||||
}}
|
||||
>
|
||||
{shownGroups.map((group, i) =>
|
||||
group.label ? (
|
||||
<optgroup key={group.label} label={group.label}>
|
||||
{group.choices.map((c) => (
|
||||
<option key={c.path} value={c.path}>
|
||||
{c.label}
|
||||
</option>
|
||||
))}
|
||||
</optgroup>
|
||||
) : (
|
||||
group.choices.map((c) => (
|
||||
<option key={`${i}-${c.path}`} value={c.path}>
|
||||
{c.label}
|
||||
</option>
|
||||
))}
|
||||
</optgroup>
|
||||
) : (
|
||||
group.choices.map((c) => (
|
||||
<option key={`${i}-${c.path}`} value={c.path}>
|
||||
{c.label}
|
||||
</option>
|
||||
))
|
||||
),
|
||||
))
|
||||
),
|
||||
)}
|
||||
</Select>
|
||||
{choices.length > FILTER_FROM && (
|
||||
<OptionFilter value={needle} onChange={setNeedle} label="Narrow the list" className="mt-2" />
|
||||
)}
|
||||
</Select>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{sections.length > 0 && (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue