Tidy the structure the audit found
- The colour defaults have one source, server/src/themeDefaults.js, read by the server and the admin; the build stops if src/index.css disagrees with it - server/src/admin-schema.js split into admin-schema/, one file per entity plus columns.js (the registry checked identical) - loadOwned() in shape.js replaces the same three loads on four detail routes (every public route checked identical); one NO_STORE - One OrgLogo component for the org lists and the chapter map; an organization's own page now shows the same initials as the lists - One localISO() for the viewer's calendar day, in place of three - Boot refuses a descriptor dropdown value the table's CHECK doesn't allow, instead of it failing on save - Deleted the unused Other.tsx and white-background logo; chapters.ts is useCommunity.ts; isSuper() in the Panel; stale comments and docs corrected Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
048c7599ce
commit
f934b1dd93
44 changed files with 1187 additions and 1170 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import siteConfiguration from "../../../site.json";
|
||||
import { mediaUrl } from "../media.ts";
|
||||
import { THEME_DEFAULTS } from "../../../server/src/themeDefaults.js";
|
||||
|
||||
/* ── Site settings (035_site_settings.sql) ───────────────────────
|
||||
Overrides for site.json, superadmins only: every blank falls back
|
||||
|
|
@ -8,24 +9,32 @@ const SITE_PAGES: [string, string][] = Object.entries(siteConfiguration.pages).m
|
|||
([path, page]) => [path, `${page.title} (${path})`],
|
||||
);
|
||||
|
||||
/* The palette an admin can change: token, label, light default, dark
|
||||
default. Keep in step with THEME_DEFAULTS in server/src/theme.js
|
||||
and the tokens in src/index.css. */
|
||||
const THEME_COLORS: [string, string, string, string][] = [
|
||||
["ink", "Headings", "#073d4a", "#eaf6f8"],
|
||||
["body", "Body text", "#26454c", "#cde0e4"],
|
||||
["muted", "Secondary text and quiet borders", "#4a6b72", "#9fb9bf"],
|
||||
["link", "Links and teal text", "#0f7183", "#5ccbdc"],
|
||||
["brand", "Brand teal (borders, rules, rings)", "#138ba0", "#2aa7bc"],
|
||||
["action", "Buttons (under white text)", "#0f7183", "#0f7183"],
|
||||
["action-hover", "Buttons, hovered", "#0b5c6a", "#0b5c6a"],
|
||||
["surface", "Page and card background", "#ffffff", "#0c1d21"],
|
||||
["tint", "Tinted sections and panels", "#eef9fb", "#11292e"],
|
||||
["tint-soft", "Faint panels and hovered rows", "#f6fbfc", "#0f2428"],
|
||||
["danger", "Errors and warnings", "#b3261e", "#ff8a80"],
|
||||
["danger-tint", "Error panel background", "#fdf3f2", "#3b1714"],
|
||||
/* The palette an admin can change, in the order the dropdown lists
|
||||
it: token and label. The defaults come from the server's list
|
||||
(server/src/themeDefaults.js), which the build checks against
|
||||
src/index.css, so there's one copy of each colour to change. */
|
||||
const THEME_LABELS: [string, string][] = [
|
||||
["ink", "Headings"],
|
||||
["body", "Body text"],
|
||||
["muted", "Secondary text and quiet borders"],
|
||||
["link", "Links and teal text"],
|
||||
["brand", "Brand teal (borders, rules, rings)"],
|
||||
["action", "Buttons (under white text)"],
|
||||
["action-hover", "Buttons, hovered"],
|
||||
["surface", "Page and card background"],
|
||||
["tint", "Tinted sections and panels"],
|
||||
["tint-soft", "Faint panels and hovered rows"],
|
||||
["danger", "Errors and warnings"],
|
||||
["danger-tint", "Error panel background"],
|
||||
];
|
||||
|
||||
const THEME_COLORS: [string, string, string, string][] = THEME_LABELS.map(([token, label]) => [
|
||||
token,
|
||||
label,
|
||||
THEME_DEFAULTS[token][0],
|
||||
THEME_DEFAULTS[token][1],
|
||||
]);
|
||||
|
||||
const defaultHelp = (row, column: 2 | 3) => {
|
||||
const entry = THEME_COLORS.find(([token]) => token === row?.token);
|
||||
return entry ? `Default: ${entry[column]}` : undefined;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
not instants, nothing here converts timezones.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { localISO } from './timeline.ts'
|
||||
|
||||
export type SeriesFrequency = 'weekly' | 'monthly_date' | 'monthly_weekday'
|
||||
|
||||
export type SeriesWeekday = 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat'
|
||||
|
|
@ -66,11 +68,7 @@ function parseDate(value?: string | null): Date | null {
|
|||
const isoDate = (date: Date) => date.toISOString().slice(0, 10)
|
||||
|
||||
/* The viewer's today, as a calendar date. */
|
||||
function today(): string {
|
||||
const now = new Date()
|
||||
const pad = (n: number) => String(n).padStart(2, '0')
|
||||
return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`
|
||||
}
|
||||
const today = (): string => localISO()
|
||||
|
||||
const daysInMonth = (year: number, month: number) =>
|
||||
new Date(Date.UTC(year, month + 1, 0)).getUTCDate()
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
Now the id is checked here. In dev that's a console.error with a
|
||||
stack trace pointing at the caller; in production the path still
|
||||
comes out, because a broken link beats a crashed page, and
|
||||
useResource refuses to fetch it.
|
||||
detailPath() returns null for it, so useRecord never fetches it.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
export type OrgKind = 'national' | 'region' | 'chapter' | 'partner'
|
||||
|
|
|
|||
|
|
@ -72,10 +72,11 @@ export function areasSentence(areas: any[] = []) {
|
|||
.join(", ");
|
||||
}
|
||||
|
||||
/* Initials for a card with no logo. "NGU Lynnwood" → "NL", dropping
|
||||
the org prefix so every card doesn't read "NG". */
|
||||
// Alphabetical by name, for sorting organizations.
|
||||
export const byName = (a, b) => a.name.localeCompare(b.name);
|
||||
|
||||
/* Initials for an organization with no logo. "NGU Lynnwood" → "NL",
|
||||
dropping the org prefix so every card doesn't read "NG". */
|
||||
export function initialsFor(name = "") {
|
||||
return name
|
||||
.replace(/^NGU\s+/i, "")
|
||||
|
|
|
|||
|
|
@ -185,8 +185,11 @@ export function windowStart(item: TimelineItem): string {
|
|||
return `${year}-${pad(month ?? 1)}-${pad(day ?? 1)}`
|
||||
}
|
||||
|
||||
export function todayISO(now: Date = new Date()): string {
|
||||
return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`
|
||||
/** A date as the viewer's own calendar day, YYYY-MM-DD (today when
|
||||
* given nothing). Local, not UTC: after 5pm in California, UTC is
|
||||
* already tomorrow. The site's one copy of this. */
|
||||
export function localISO(date: Date = new Date()): string {
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -197,7 +200,7 @@ export function partitionByDate(
|
|||
items: TimelineItem[],
|
||||
now: Date = new Date(),
|
||||
): { upcoming: TimelineItem[]; past: TimelineItem[] } {
|
||||
const today = todayISO(now)
|
||||
const today = localISO(now)
|
||||
const upcoming: TimelineItem[] = []
|
||||
const past: TimelineItem[] = []
|
||||
for (const item of items) {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
LOCAL CHAPTER DATA
|
||||
useCommunity
|
||||
|
||||
The chapter map's view of the organization list. Regions and
|
||||
chapters are the same table and the same endpoint; this hook
|
||||
reshapes them into what a map needs, slices per tile, counts
|
||||
per tile, chapters grouped by region.
|
||||
|
||||
Its return shape is unchanged from the version that called
|
||||
/regions and /chapters, so LocalChapters didn't have to move.
|
||||
The chapter map's view of the organization list (OrgList-Map).
|
||||
Regions and chapters are the same table and the same endpoint;
|
||||
this hook reshapes them into what a map needs, slices per tile,
|
||||
counts per tile, chapters grouped by region.
|
||||
|
||||
Two things live elsewhere:
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* The four detail endpoints, typed.
|
||||
* The detail endpoints, typed.
|
||||
*
|
||||
* Adding a fifth is a type and a one-line hook, useRecord owns
|
||||
* Adding one is a type and a one-line hook, useRecord owns
|
||||
* the fetching, the caching and the 404.
|
||||
*
|
||||
* An id that is missing, or the literal string "undefined", which
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
*
|
||||
* Every detail route in content.js answers the same shape: 200 with
|
||||
* a single top-level key, or 404 with `{ error }`. So the hook takes
|
||||
* the path and the key, and the four callers in useContent.ts are
|
||||
* one line each rather than four copies of this file.
|
||||
* the path and the key, and each caller (useContent.ts, useHistory,
|
||||
* useBlog) is one line rather than a copy of this file.
|
||||
*
|
||||
* `key` is a string rather than a selector function on purpose. A
|
||||
* selector passed inline would be a new identity every render, and
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue