Revert the implicit-any typing of src/

Reverts 2428f44. The .d.ts files beside the JS modules and the
annotations threaded through src/ to satisfy noImplicitAny go;
tsconfig turns noImplicitAny off instead. The JS modules become
TypeScript in the next commit, so their types come from inference.

Kept from that commit, since they're runtime fixes rather than types:
- OrganizationDetail's website and email pills get an href and label
  (they arrive as bare strings, not link objects).
- The chapter map falls back to FALLBACK_COLOR for a region with no
  colour instead of painting its tiles black.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-26 15:32:28 -05:00
parent 4618ad8e67
commit 5cedc68fd7
38 changed files with 340 additions and 1302 deletions

View file

@ -1,16 +1,9 @@
import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";
import { useEffect, useMemo, useRef, useState } from "react";
import { Link } from "react-router-dom";
import {
splitByStatus,
typesPresent,
useEvents,
type EventFilter,
} from "../../data/eventData.js";
import { splitByStatus, typesPresent, useEvents } from "../../data/eventData.js";
import { eventHref } from "../../lib/hrefs.ts";
import { EVENT_TYPES, eventTypeLabel, type EventType } from "../../lib/eventTypes.ts";
import { EVENT_TYPES, eventTypeLabel } from "../../lib/eventTypes.ts";
import { seriesLabel } from "../../lib/eventSeries.ts";
import type { EventListItem } from "../../lib/useContent.ts";
import type { SectionToggleProps } from "../../lib/sections.tsx";
/* ═══════════════════════════════════════════════════════════════
EVENT LIST — CARDS
@ -32,7 +25,7 @@ import type { SectionToggleProps } from "../../lib/sections.tsx";
nothing but retreats shows no control at all.
═══════════════════════════════════════════════════════════════ */
const LOGO_FILES = import.meta.glob<string>("../../assets/event-logos/*.svg", {
const LOGO_FILES = import.meta.glob("../../assets/event-logos/*.svg", {
eager: true,
import: "default",
});
@ -41,7 +34,7 @@ const LOGOS = Object.fromEntries(
Object.entries(LOGO_FILES).map(([path, src]) => [path.split("/").pop(), src])
);
const logoSrc = (file: string | null | undefined) => (file && LOGOS[file]) || null;
const logoSrc = file => (file && LOGOS[file]) || null;
/* Last resort only. The API already falls back to the host
organization's logo when an event doesn't name its own, so this
@ -49,15 +42,7 @@ const logoSrc = (file: string | null | undefined) => (file && LOGOS[file]) || nu
const DEFAULT_ORG_LOGO = null;
/* An <img> that removes itself if the file 404s. */
function Logo({
file,
alt = "",
className,
}: {
file: string | null | undefined;
alt?: string;
className?: string;
}) {
function Logo({ file, alt = "", className }) {
const [failed, setFailed] = useState(false);
const src = logoSrc(file);
if (!src || failed) return null;
@ -138,15 +123,7 @@ const InstagramIcon = ({ id = "ig-gradient" }) => (
carousel has the same constraint — it needs the card's click to
mean "bring this one to the front" on anything that isn't the
active slide. */
function TitleLink({
ev,
linked,
children,
}: {
ev: Pick<EventListItem, "id">;
linked: boolean;
children: ReactNode;
}) {
function TitleLink({ ev, linked, children }) {
if (!linked) return <>{children}</>;
return (
<Link to={eventHref(ev.id)} className="hover:underline underline-offset-4">
@ -173,16 +150,6 @@ function TitleLink({
`linked` is the one thing a caller turns off: a card on the
event's own page shouldn't link to the page it's already on.
═══════════════════════════════════════════════════════════════ */
type CardProps = {
ev: EventListItem;
defaultColor?: string;
accent?: string;
compact?: boolean;
interactive?: boolean;
linked?: boolean;
showType?: boolean;
};
export function Card({
ev,
defaultColor = TEAL,
@ -191,7 +158,7 @@ export function Card({
interactive = true,
linked = true,
showType = false,
}: CardProps) {
}) {
const past = ev.status === "past";
const color = ev.color || defaultColor;
const orgLogo = ev.org_logo || DEFAULT_ORG_LOGO;
@ -390,23 +357,14 @@ export function Card({
them visible is one tap, and the row reads as what the section
contains rather than as a form control.
═══════════════════════════════════════════════════════════════ */
type TypeFilterValue = EventType | "all";
type TypeFilterProps = {
types: typeof EVENT_TYPES;
active: TypeFilterValue;
setActive: (id: TypeFilterValue) => void;
accent: string;
};
export function TypeFilter({ types, active, setActive, accent }: TypeFilterProps) {
const chip = (on: boolean) => ({
export function TypeFilter({ types, active, setActive, accent }) {
const chip = on => ({
border: `1px solid ${accent}`,
background: on ? accent : "transparent",
color: on ? "#ffffff" : accent,
});
const button = (id: TypeFilterValue, label: string) => (
const button = (id, label) => (
<button
key={id}
onClick={() => setActive(id)}
@ -434,12 +392,8 @@ export function TypeFilter({ types, active, setActive, accent }: TypeFilterProps
/* ═══════════════════════════════════════════════════════════════
TOGGLE — the control for the section heading's action bar
═══════════════════════════════════════════════════════════════ */
export function EventCardsToggle({
view,
setView,
accent,
}: Pick<SectionToggleProps, "view" | "setView" | "accent">) {
const btn = (active: boolean) => ({
export function EventCardsToggle({ view, setView, accent }) {
const btn = active => ({
background: active ? accent : "transparent",
color: active ? "#ffffff" : accent,
});
@ -491,14 +445,6 @@ export function EventCardsToggle({
differently to someone waiting, so they're distinguished rather
than all falling through to "coming soon".
═══════════════════════════════════════════════════════════════ */
type EventListCardsProps = EventFilter & {
/** "carousel" or "grid". */
view?: string;
accent?: string;
defaultColor?: string;
empty?: string;
};
export default function EventListCards({
section,
host,
@ -508,7 +454,7 @@ export default function EventListCards({
accent = TEAL,
defaultColor,
empty = "· Events coming soon, stay connected for announcements ·",
}: EventListCardsProps) {
}) {
const { events: fetched, loading, error } = useEvents({
section,
host,
@ -519,7 +465,7 @@ export default function EventListCards({
const [index, setIndex] = useState(0);
const [showPast, setShowPast] = useState(false);
const [activeType, setActiveType] = useState<TypeFilterValue>("all");
const [activeType, setActiveType] = useState("all");
/* What this band holds, which is what the chips offer — not the
full list of declared types, three quarters of which would be
@ -573,7 +519,7 @@ export default function EventListCards({
const next = () => setIndex(i => Math.min(events.length - 1, i + 1));
// Arrows and dots follow the section accent, not the active card.
const arrowStyle = (enabled: boolean) => ({
const arrowStyle = enabled => ({
border: `1px solid ${accent}`,
background: "rgba(255,255,255,0.85)",
color: enabled ? accent : "#b8c6c9",
@ -581,7 +527,7 @@ export default function EventListCards({
opacity: enabled ? 1 : 0.4,
});
const notice = (text: string) => (
const notice = text => (
<p className="max-w-6xl mx-auto px-6 font-600" style={{ color: accent }}>
{text}
</p>

View file

@ -11,7 +11,7 @@
page to the nav adds it to this form too.
═══════════════════════════════════════════════════════════════ */
import { useState, type FormEvent, type ReactNode } from "react";
import { useState } from "react";
import { post, ApiError } from "../../lib/api.js";
import { PAGE_LINKS, PAGE_SECTIONS } from "../../navConfig.js";
import { FEEDBACK_TYPES } from "../../data/feedbackTypes.js";
@ -46,7 +46,7 @@ function OptionalTag() {
);
}
function FieldError({ id, children }: { id: string; children?: ReactNode }) {
function FieldError({ id, children }) {
if (!children) return null;
return (
<p id={id} className="mt-2 text-sm text-[#b3261e]">
@ -56,15 +56,7 @@ function FieldError({ id, children }: { id: string; children?: ReactNode }) {
}
// Native select plus a chevron, since appearance-none strips the default one.
type SelectProps = {
id: string;
label: string;
value: string;
onChange: (value: string) => void;
children: ReactNode;
};
function Select({ id, label, value, onChange, children }: SelectProps) {
function Select({ id, label, value, onChange, children }) {
return (
<div>
<label htmlFor={id} className="block text-sm font-medium text-[#26454c]">
@ -101,13 +93,7 @@ function Select({ id, label, value, onChange, children }: SelectProps) {
/* ── Type picker ─────────────────────────────────────────────── */
function TypePicker({
value,
onChange,
}: {
value: string | null;
onChange: (id: string) => void;
}) {
function TypePicker({ value, onChange }) {
return (
<fieldset>
<legend className="text-base font-semibold text-[#26454c]">
@ -165,16 +151,7 @@ function TypePicker({
/* ── Where on the site ───────────────────────────────────────── */
type LocationPickerProps = {
/** A nav path, or SITE_WIDE. */
page: string;
/** A nav hash, or WHOLE_PAGE. */
section: string;
onPageChange: (page: string) => void;
onSectionChange: (section: string) => void;
};
function LocationPicker({ page, section, onPageChange, onSectionChange }: LocationPickerProps) {
function LocationPicker({ page, section, onPageChange, onSectionChange }) {
const sections = page === SITE_WIDE ? [] : PAGE_SECTIONS[page] ?? [];
return (
@ -228,7 +205,7 @@ function LocationPicker({ page, section, onPageChange, onSectionChange }: Locati
}
// Human-readable version of the picked location, for the thank-you panel.
function describeLocation(page: string, section: string) {
function describeLocation(page, section) {
if (page === SITE_WIDE) return null;
const pageLabel = PAGE_LINKS.find((p) => p.path === page)?.label ?? page;
const sectionLabel = (PAGE_SECTIONS[page] ?? []).find(
@ -239,11 +216,8 @@ function describeLocation(page: string, section: string) {
/* ── The form ────────────────────────────────────────────────── */
/* The fields server/src/routes/feedback.js can reject by name. */
type FeedbackFieldErrors = { message?: string; email?: string };
export default function FeedbackForm() {
const [type, setType] = useState<string | null>(null);
const [type, setType] = useState(null);
const [page, setPage] = useState(SITE_WIDE);
const [section, setSection] = useState(WHOLE_PAGE);
const [message, setMessage] = useState("");
@ -254,14 +228,14 @@ export default function FeedbackForm() {
const [website, setWebsite] = useState("");
// idle → sending → sent, or back to idle with an error to show.
const [status, setStatus] = useState<"idle" | "sending" | "sent">("idle");
const [formError, setFormError] = useState<string | null>(null);
const [fieldErrors, setFieldErrors] = useState<FeedbackFieldErrors>({});
const [status, setStatus] = useState("idle");
const [formError, setFormError] = useState(null);
const [fieldErrors, setFieldErrors] = useState({});
const sending = status === "sending";
const ready = Boolean(type) && message.trim().length >= MIN_MESSAGE;
async function handleSubmit(event: FormEvent<HTMLFormElement>) {
async function handleSubmit(event) {
event.preventDefault();
if (!ready || sending) return;

View file

@ -1,7 +1,5 @@
import { useState, type ReactNode } from "react";
import { useState } from "react";
import ArrowLink from "../../components/ArrowLink.tsx";
import type { OrgKind } from "../../lib/hrefs.ts";
import type { OrganizationListItem } from "../../lib/useContent.ts";
import {
initialsFor,
orgPath,
@ -35,13 +33,7 @@ const FALLBACK_COLOR = "#4a6b72";
const CARD_MIN = "20rem";
const GRID_MAX = "88rem";
function OrgMark({
org,
color,
}: {
org: Pick<OrganizationListItem, "logo" | "name">;
color: string;
}) {
function OrgMark({ org, color }) {
const [failed, setFailed] = useState(false);
if (org.logo && !failed) {
@ -66,14 +58,7 @@ function OrgMark({
);
}
type CardLabels = { accent: string; pageLabel: string; siteLabel: string };
function OrgCard({
org,
accent,
pageLabel,
siteLabel,
}: CardLabels & { org: OrganizationListItem }) {
function OrgCard({ org, accent, pageLabel, siteLabel }) {
const color = org.color || accent;
const path = orgPath(org);
@ -151,13 +136,7 @@ function OrgCard({
);
}
function Block({
title,
orgs,
accent,
pageLabel,
siteLabel,
}: CardLabels & { title?: string; orgs: OrganizationListItem[] }) {
function Block({ title, orgs, accent, pageLabel, siteLabel }) {
if (orgs.length === 0) return null;
return (
@ -188,30 +167,7 @@ function Block({
);
}
const byName = (a: OrganizationListItem, b: OrganizationListItem) =>
a.name.localeCompare(b.name);
/* One heading's worth of the grid. Labels override the grid's own. */
type OrgGroup = {
key: string;
title: string;
pageLabel?: string;
siteLabel?: string;
};
type OrgListCardsProps = {
kind?: OrgKind;
title?: string;
groups?: OrgGroup[];
/** Which group key an organization files under. */
groupBy?: (org: OrganizationListItem) => string | null | undefined;
accent?: string;
pageLabel?: string;
siteLabel?: string;
/** Null keeps the API's order. */
sort?: ((a: OrganizationListItem, b: OrganizationListItem) => number) | null;
empty?: string;
};
const byName = (a, b) => a.name.localeCompare(b.name);
export default function OrgListCards({
kind,
@ -223,10 +179,10 @@ export default function OrgListCards({
siteLabel = "Visit site",
sort = byName,
empty = "· Nothing to show here just yet ·",
}: OrgListCardsProps) {
}) {
const { organizations, loading, error } = useOrganizations(kind);
const shell = (children: ReactNode) => (
const shell = children => (
<div className="mx-auto px-8 md:px-12" style={{ maxWidth: GRID_MAX }}>
{children}
</div>

View file

@ -1,16 +1,9 @@
import { useEffect, useRef, useState, type ReactNode, type RefObject } from "react";
import {
useCommunity,
type Chapter,
type Community,
type Region,
} from "../../data/chapters.js";
import { useEffect, useRef, useState } from "react";
import { useCommunity } from "../../data/chapters.js";
import { Link } from "react-router-dom";
import ArrowLink from "../../components/ArrowLink.tsx";
import { initialsFor, orgPath } from "../../data/organizations.js";
import { AREAS, AREA_NAMES, type AreaSlice } from "../../data/mapGrid.js";
import type { SectionToggleProps } from "../../lib/sections.tsx";
import type { ContentBlock, OrganizationListItem } from "../../lib/useContent.ts";
import { AREAS, AREA_NAMES } from "../../data/mapGrid.js";
/* ═══════════════════════════════════════════════════════════════
ORGANIZATION LIST — MAP
@ -55,16 +48,7 @@ const FALLBACK_COLOR = "#4a6b72";
/* organizations.color is nullable; an SVG fill left undefined paints
black, so an uncoloured region takes the same fallback as a card. */
const colorOf = (item: { color?: string | null }) => item.color || FALLBACK_COLOR;
/* Which region is picked and which is under the pointer, shared by
the map, the legend and the list. */
type Highlight = {
selected: string | null;
hovered: string | null;
setSelected: (id: string | null) => void;
setHovered: (id: string | null) => void;
};
const colorOf = (item) => item.color || FALLBACK_COLOR;
const US_TITLE = "US Unity Regions";
const INTL_TITLE = "International Unity Regions";
@ -75,7 +59,7 @@ const INTL_TITLE = "International Unity Regions";
vanishing. When organization and person pages arrive this should
move to a shared component; small enough to live here until then.
───────────────────────────────────────────────────────────── */
function Blocks({ blocks = [], color }: { blocks?: ContentBlock[]; color: string }) {
function Blocks({ blocks = [], color }) {
if (blocks.length === 0) return null;
return (
@ -108,7 +92,7 @@ function Blocks({ blocks = [], color }: { blocks?: ContentBlock[]; color: string
case "links":
return (
<ul key={i} className="list-disc ml-5 flex flex-col gap-1">
{(block.items ?? []).map((item, j) => (
{block.items.map((item, j) => (
<li key={j}>
{item.url ? (
<a
@ -154,19 +138,6 @@ function Blocks({ blocks = [], color }: { blocks?: ContentBlock[]; color: string
subtracts, and the order the slices arrive in doesn't change
what's drawn.
───────────────────────────────────────────────────────────── */
type TileProps = Highlight & {
code: string;
x: number;
y: number;
size: number;
width?: number;
label?: string;
slices?: AreaSlice[];
count?: number;
onPick?: (code: string) => void;
fontSize?: number;
};
function Tile({
code,
x,
@ -182,12 +153,11 @@ function Tile({
setHovered,
onPick,
fontSize = 34,
}: TileProps) {
}) {
if (slices.length === 0) return null;
const primary = slices[0];
// Nullable so indexOf and includes take `selected` as it is.
const ids: Array<string | null> = slices.map(s => s.regionId);
const ids = slices.map(s => s.regionId);
const active = ids.includes(selected) || ids.includes(hovered);
const dimmed = selected && !ids.includes(selected);
const clipId = `clip-${code}`;
@ -278,13 +248,7 @@ function Tile({
);
}
type RegionMapProps = Highlight & {
slices: Record<string, AreaSlice[]>;
chapterCounts: Record<string, number>;
onPick?: (code: string) => void;
};
function RegionMap({ slices, chapterCounts, ...props }: RegionMapProps) {
function RegionMap({ slices, chapterCounts, ...props }) {
const size = TILE - PAD * 2;
return (
@ -315,15 +279,8 @@ function RegionMap({ slices, chapterCounts, ...props }: RegionMapProps) {
);
}
function LegendButton({
region,
selected,
setSelected,
hovered,
setHovered,
}: Highlight & { region: Region }) {
function LegendButton({ region, selected, setSelected, hovered, setHovered }) {
const on = selected === region.id || hovered === region.id;
const color = colorOf(region);
return (
<button
onClick={() => setSelected(selected === region.id ? null : region.id)}
@ -334,36 +291,29 @@ function LegendButton({
aria-pressed={selected === region.id}
className="flex items-center gap-2 py-1.5 px-3 rounded-lg text-sm font-700 transition-all duration-200"
style={{
border: `1px solid ${color}`,
background: on ? color : "transparent",
color: on ? "#ffffff" : color,
border: `1px solid ${colorOf(region)}`,
background: on ? colorOf(region) : "transparent",
color: on ? "#ffffff" : colorOf(region),
opacity: selected && selected !== region.id ? 0.45 : 1,
}}
>
<span
className="h-2.5 w-2.5 rounded-full"
style={{ background: on ? "#ffffff" : color }}
style={{ background: on ? "#ffffff" : colorOf(region) }}
/>
{region.name}
</button>
);
}
type LegendProps = Highlight & {
domestic: Region[];
international: Region[];
/** Regions that paint at least one tile. */
onMapIds: Set<string>;
};
function Legend({ domestic, international, onMapIds, ...props }: LegendProps) {
function Legend({ domestic, international, onMapIds, ...props }) {
const { selected, setSelected } = props;
// A region is on the map if it paints a tile. West Central used
// to need a hardcoded exception here because its states arrived
// only through SPLITS; it has ordinary rows now, so the exception
// is gone.
const onMap = (region: Region) => onMapIds.has(region.id);
const onMap = region => onMapIds.has(region.id);
const us = domestic.filter(onMap);
const intl = international.filter(onMap);
@ -401,15 +351,6 @@ function Legend({ domestic, international, onMapIds, ...props }: LegendProps) {
);
}
type RegionBlockProps = Highlight & {
region: Region;
chapters: Chapter[];
subtext: string;
indent: boolean;
regionRefs?: RefObject<Record<string, HTMLDivElement | null>>;
chapterRefs?: RefObject<Record<string, HTMLLIElement | null>>;
};
function RegionBlock({
region,
chapters,
@ -420,15 +361,12 @@ function RegionBlock({
indent,
regionRefs,
chapterRefs,
}: RegionBlockProps) {
}) {
const on = selected === region.id;
const color = colorOf(region);
return (
<div
ref={el => {
if (regionRefs) regionRefs.current[region.id] = el;
}}
ref={el => regionRefs && (regionRefs.current[region.id] = el)}
className="transition-opacity duration-200"
style={{ opacity: selected && !on ? 0.35 : 1, marginLeft: indent ? "0.75rem" : 0 }}
>
@ -440,11 +378,11 @@ function RegionBlock({
>
<span
className="h-3 w-3 rounded-full shrink-0"
style={{ background: color }}
style={{ background: colorOf(region) }}
/>
<h4
className={`font-800 ${indent ? "text-lg" : "text-xl"}`}
style={{ color: color }}
style={{ color: colorOf(region) }}
>
{region.name}
</h4>
@ -465,60 +403,55 @@ function RegionBlock({
</p>
) : (
<ul className="ml-5 mb-4 flex flex-col gap-3">
{chapters.map(c => {
const path = orgPath(c);
return (
<li
key={c.id}
ref={el => {
if (chapterRefs) chapterRefs.current[c.id] = el;
}}
className="pl-3 flex items-start gap-3"
style={{ borderLeft: `2px solid ${color}` }}
>
<div className="min-w-0 flex-1">
<p className="font-700">{c.name}</p>
<p className="text-sm" style={{ color: FALLBACK_COLOR }}>
{c.location_label}
{c.meets ? ` · ${c.meets}` : ""}
{chapters.map(c => (
<li
key={c.id}
ref={el => chapterRefs && (chapterRefs.current[c.id] = el)}
className="pl-3 flex items-start gap-3"
style={{ borderLeft: `2px solid ${colorOf(region)}` }}
>
<div className="min-w-0 flex-1">
<p className="font-700">{c.name}</p>
<p className="text-sm" style={{ color: FALLBACK_COLOR }}>
{c.location_label}
{c.meets ? ` · ${c.meets}` : ""}
</p>
{(c.website || c.email) && (
<p className="text-sm mt-1 flex gap-4">
{c.website && (
<a
href={c.website}
target="_blank"
rel="noopener noreferrer"
className="font-700 underline"
style={{ color: colorOf(region) }}
>
Details
</a>
)}
{c.email && (
<a
href={`mailto:${c.email}`}
className="font-700 underline"
style={{ color: colorOf(region) }}
>
Contact
</a>
)}
</p>
{(c.website || c.email) && (
<p className="text-sm mt-1 flex gap-4">
{c.website && (
<a
href={c.website}
target="_blank"
rel="noopener noreferrer"
className="font-700 underline"
style={{ color: color }}
>
Details
</a>
)}
{c.email && (
<a
href={`mailto:${c.email}`}
className="font-700 underline"
style={{ color: color }}
>
Contact
</a>
)}
</p>
)}
</div>
{path && (
<ArrowLink
to={path}
label={`${c.name} — chapter page`}
color={color}
size="h-8 w-8"
/>
)}
</li>
);
})}
</div>
{orgPath(c) && (
<ArrowLink
to={orgPath(c)}
label={`${c.name} — chapter page`}
color={colorOf(region)}
size="h-8 w-8"
/>
)}
</li>
))}
</ul>
)}
</div>
@ -533,15 +466,7 @@ function RegionBlock({
═══════════════════════════════════════════════════════════════ */
/* Logo, or the organization's initials when there's no file. */
function OrgLogo({
org,
color,
size = "h-14 w-14",
}: {
org: Pick<OrganizationListItem, "logo" | "name">;
color: string;
size?: string;
}) {
function OrgLogo({ org, color, size = "h-14 w-14" }) {
const [failed, setFailed] = useState(false);
if (org.logo && !failed) {
@ -566,16 +491,7 @@ function OrgLogo({
);
}
type ChapterCardProps = {
chapter: Chapter;
color: string;
open: boolean;
onOpen: () => void;
};
function ChapterCard({ chapter, color, open, onOpen }: ChapterCardProps) {
const path = orgPath(chapter);
function ChapterCard({ chapter, color, open, onOpen }) {
return (
<div
className="rounded-2xl p-4 flex items-start gap-4 transition-all duration-200"
@ -627,9 +543,9 @@ function ChapterCard({ chapter, color, open, onOpen }: ChapterCardProps) {
</svg>
</button>
{path && (
{orgPath(chapter) && (
<ArrowLink
to={path}
to={orgPath(chapter)}
label={`${chapter.name} — chapter page`}
color={color}
/>
@ -639,18 +555,7 @@ function ChapterCard({ chapter, color, open, onOpen }: ChapterCardProps) {
);
}
function ChapterDetail({
chapter,
region,
onClose,
}: {
chapter: Chapter;
region: Region;
onClose: () => void;
}) {
const path = orgPath(chapter);
const color = colorOf(region);
function ChapterDetail({ chapter, region, onClose }) {
/* "Led by" comes from affiliations rather than a text field, so
it lists real people and stays empty until they exist. */
const leads = (chapter.leadership ?? [])
@ -659,23 +564,21 @@ function ChapterDetail({
)
.join(", ");
const rows = (
[
["Region", region.name],
["Where", chapter.venue],
["Meets", chapter.meets],
["Led by", leads],
["Since", chapter.started],
] satisfies Array<[label: string, value: string | null | undefined]>
).filter(([, v]) => v);
const rows = [
["Region", region.name],
["Where", chapter.venue],
["Meets", chapter.meets],
["Led by", leads],
["Since", chapter.started],
].filter(([, v]) => v);
return (
<div
className="rounded-2xl p-6 mb-6"
style={{ border: `2px solid ${color}`, background: `${color}0f` }}
style={{ border: `2px solid ${colorOf(region)}`, background: `${colorOf(region)}0f` }}
>
<div className="flex items-start gap-4">
<OrgLogo org={chapter} color={color} size="h-20 w-20" />
<OrgLogo org={chapter} color={colorOf(region)} size="h-20 w-20" />
<div className="min-w-0 flex-1">
<p className="text-2xl font-900 leading-tight">{chapter.name}</p>
@ -686,13 +589,13 @@ function ChapterDetail({
onClick={onClose}
aria-label="Close details"
className="shrink-0 h-8 w-8 rounded-full flex items-center justify-center text-lg font-700 transition-transform duration-200 hover:scale-110"
style={{ border: `1px solid ${color}`, color: color }}
style={{ border: `1px solid ${colorOf(region)}`, color: colorOf(region) }}
>
×
</button>
</div>
<Blocks blocks={chapter.blocks} color={color} />
<Blocks blocks={chapter.blocks} color={colorOf(region)} />
{rows.length > 0 && (
<dl className="mt-4 grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-1 text-sm">
@ -710,11 +613,11 @@ function ChapterDetail({
)}
<div className="mt-5 flex flex-wrap gap-3">
{path && (
{orgPath(chapter) && (
<Link
to={path}
to={orgPath(chapter)}
className="py-2 px-5 rounded-xl font-700 text-sm transition-transform duration-200 hover:scale-105"
style={{ background: color, color: "#ffffff" }}
style={{ background: colorOf(region), color: "#ffffff" }}
>
Chapter page
</Link>
@ -725,7 +628,7 @@ function ChapterDetail({
target="_blank"
rel="noopener noreferrer"
className="py-2 px-5 rounded-xl font-700 text-sm transition-transform duration-200 hover:scale-105"
style={{ border: `1px solid ${color}`, color: color }}
style={{ border: `1px solid ${colorOf(region)}`, color: colorOf(region) }}
>
Visit site
</a>
@ -735,7 +638,7 @@ function ChapterDetail({
<a
href={`mailto:${chapter.email}`}
className="py-2 px-5 rounded-xl font-700 text-sm transition-transform duration-200 hover:scale-105"
style={{ border: `1px solid ${color}`, color: color }}
style={{ border: `1px solid ${colorOf(region)}`, color: colorOf(region) }}
>
Get in touch
</a>
@ -745,19 +648,7 @@ function ChapterDetail({
);
}
type ChapterGridProps = Pick<Community, "regions" | "chapters" | "chaptersIn" | "subtextFor"> & {
openId: string | null;
setOpenId: (id: string | null) => void;
};
function ChapterGrid({
regions,
chapters,
chaptersIn,
subtextFor,
openId,
setOpenId,
}: ChapterGridProps) {
function ChapterGrid({ regions, chapters, chaptersIn, subtextFor, openId, setOpenId }) {
// Only regions that actually have chapters get a grid.
const populated = regions
.map(region => ({ region, list: chaptersIn(region.id) }))
@ -769,15 +660,14 @@ function ChapterGrid({
<div className="mx-auto px-8 md:px-12" style={{ maxWidth: CONTENT_MAX }}>
{populated.map(({ region, list }) => {
const subtext = subtextFor(region);
const color = colorOf(region);
return (
<section key={region.id} className="mb-12">
<div className="flex items-baseline gap-3 mb-1">
<span
className="h-3 w-3 rounded-full shrink-0"
style={{ background: color }}
style={{ background: colorOf(region) }}
/>
<h3 className="text-2xl font-800" style={{ color: color }}>
<h3 className="text-2xl font-800" style={{ color: colorOf(region) }}>
{region.name}
</h3>
<span className="text-sm" style={{ color: MUTED }}>
@ -810,7 +700,7 @@ function ChapterGrid({
<ChapterCard
key={c.id}
chapter={c}
color={color}
color={colorOf(region)}
open={openId === c.id}
onOpen={() => setOpenId(openId === c.id ? null : c.id)}
/>
@ -831,12 +721,8 @@ function ChapterGrid({
}
/* The control for the section heading's action bar. */
export function OrgMapToggle({
view,
setView,
accent,
}: Pick<SectionToggleProps, "view" | "setView" | "accent">) {
const btn = (active: boolean) => ({
export function OrgMapToggle({ view, setView, accent }) {
const btn = active => ({
background: active ? accent : "transparent",
color: active ? "#ffffff" : accent,
});
@ -866,14 +752,7 @@ export function OrgMapToggle({
);
}
export default function OrgListMap({
view = "map",
accent = FALLBACK_COLOR,
}: {
/** "map" or "grid". */
view?: string;
accent?: string;
}) {
export default function OrgListMap({ view = "map", accent = FALLBACK_COLOR }) {
const {
loading,
error,
@ -890,16 +769,16 @@ export default function OrgListMap({
subtextFor,
} = useCommunity();
const [selected, setSelected] = useState<string | null>(null);
const [hovered, setHovered] = useState<string | null>(null);
const [openId, setOpenId] = useState<string | null>(null); // no card open on arrival
const [selected, setSelected] = useState(null);
const [hovered, setHovered] = useState(null);
const [openId, setOpenId] = useState(null); // no card open on arrival
// The list scrolls itself to whatever the map or legend points at.
const listRef = useRef<HTMLDivElement>(null);
const regionRefs = useRef<Record<string, HTMLDivElement | null>>({});
const chapterRefs = useRef<Record<string, HTMLLIElement | null>>({});
const listRef = useRef(null);
const regionRefs = useRef({});
const chapterRefs = useRef({});
const scrollListTo = (el: HTMLElement | null | undefined) => {
const scrollListTo = el => {
const box = listRef.current;
if (!box || !el) return;
// Only when the list is its own scroll area (lg and up). Below
@ -917,7 +796,7 @@ export default function OrgListMap({
// Clicking a tile jumps to its first chapter when it has one,
// otherwise to the region it belongs to.
const pickArea = (code: string) => {
const pickArea = code => {
const chapter = chapters.find(c => c.area_code === code);
if (chapter && chapterRefs.current[chapter.id]) {
return scrollListTo(chapterRefs.current[chapter.id]);
@ -926,7 +805,7 @@ export default function OrgListMap({
if (region) scrollListTo(regionRefs.current[region.id]);
};
const shell = (children: ReactNode) => (
const shell = children => (
<div className="mx-auto px-8 md:px-12" style={{ maxWidth: CONTENT_MAX }}>
{children}
</div>
@ -962,7 +841,7 @@ export default function OrgListMap({
const shared = { selected, setSelected, hovered, setHovered };
const onMapIds = new Set(regionAreas.map(a => a.region_id));
const block = (region: Region, indent: boolean) => (
const block = (region, indent) => (
<RegionBlock
key={region.id}
region={region}

View file

@ -1,13 +1,5 @@
import {
useId,
useState,
type AnchorHTMLAttributes,
type ButtonHTMLAttributes,
type ReactNode,
} from "react";
import { useId, useState } from "react";
import ArrowLink from "../../components/ArrowLink.tsx";
import type { OrgKind } from "../../lib/hrefs.ts";
import type { OrganizationListItem } from "../../lib/useContent.ts";
import {
areasSentence,
initialsFor,
@ -55,14 +47,7 @@ const FALLBACK_COLOR = "#4a6b72";
it — a link nested in a button is invalid, and a screen reader
announces the whole row as one confused control.
───────────────────────────────────────────────────────────── */
type RowButtonProps = {
as?: "a" | "button";
color: string;
children: ReactNode;
} & AnchorHTMLAttributes<HTMLAnchorElement> &
ButtonHTMLAttributes<HTMLButtonElement>;
function RowButton({ as: As = "button", color, children, ...rest }: RowButtonProps) {
function RowButton({ as: As = "button", color, children, ...rest }) {
return (
<As
className="shrink-0 whitespace-nowrap py-2 px-4 rounded-xl font-700 text-sm transition-transform duration-200 hover:scale-105"
@ -74,13 +59,7 @@ function RowButton({ as: As = "button", color, children, ...rest }: RowButtonPro
);
}
function OrgMark({
org,
color,
}: {
org: Pick<OrganizationListItem, "logo" | "color" | "name">;
color: string;
}) {
function OrgMark({ org, color }) {
const [failed, setFailed] = useState(false);
if (org.logo && !failed) {
@ -115,9 +94,7 @@ function OrgMark({
);
}
type RowLabels = { pageLabel: string; siteLabel: string };
function OrgRow({ org, pageLabel, siteLabel }: RowLabels & { org: OrganizationListItem }) {
function OrgRow({ org, pageLabel, siteLabel }) {
const [open, setOpen] = useState(false);
const panelId = useId();
@ -268,12 +245,7 @@ function OrgRow({ org, pageLabel, siteLabel }: RowLabels & { org: OrganizationLi
);
}
function Block({
title,
orgs,
pageLabel,
siteLabel,
}: RowLabels & { title?: string; orgs: OrganizationListItem[] }) {
function Block({ title, orgs, pageLabel, siteLabel }) {
if (orgs.length === 0) return null;
return (
@ -290,30 +262,7 @@ function Block({
);
}
const byName = (a: OrganizationListItem, b: OrganizationListItem) =>
a.name.localeCompare(b.name);
/* One heading's worth of the list. Labels override the list's own. */
type OrgGroup = {
key: string;
title: string;
pageLabel?: string;
siteLabel?: string;
};
type OrgListVerticalProps = {
kind?: OrgKind;
title?: string;
groups?: OrgGroup[];
/** Which group key an organization files under. */
groupBy?: (org: OrganizationListItem) => string | null | undefined;
accent?: string;
pageLabel?: string;
siteLabel?: string;
/** Null keeps the API's order. */
sort?: ((a: OrganizationListItem, b: OrganizationListItem) => number) | null;
empty?: string;
};
const byName = (a, b) => a.name.localeCompare(b.name);
export default function OrgListVertical({
kind,
@ -325,10 +274,10 @@ export default function OrgListVertical({
siteLabel = "Visit site",
sort = byName,
empty = "· Nothing to show here just yet ·",
}: OrgListVerticalProps) {
}) {
const { organizations, loading, error } = useOrganizations(kind);
const shell = (children: ReactNode) => (
const shell = children => (
<div className="mx-auto px-8 md:px-12 max-w-6xl">{children}</div>
);