Page features: directory and blog post tabs, image converter, version names

- Featured event badge: above the event's card from lg up, left out on phones
- Version names from the tag (The Region Cards Update) in the site and admin footers
- Tools -> Image converter (JPG, PNG, WebP in the browser) and Download as in Media
- People directory sections take several tags, a tab each (migration 078)
- Tab blocks split a blog post into tabs; contents follow the open tab (migration 079)
- The side nav sun fades out as the page scrolls into the footer

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aidan Dona 2026-10-16 19:37:07 -05:00
parent a6c66d4607
commit 31afa889d6
28 changed files with 878 additions and 70 deletions

View file

@ -8,9 +8,16 @@
There's no /blog index on purpose: the Community page's blog
section is where posts are listed, so "back" goes there.
Tab blocks (079) split the body into tabs (contents.ts,
splitTabs): the blocks before the first are an intro above them,
and the contents list follows the open tab. A link to a heading
in another tab (#tab-…) opens that tab. Printed (Download PDF) or
in reading mode, every tab shows, each under its title.
═══════════════════════════════════════════════════════════════ */
import { Link, useParams } from "react-router-dom"
import { useEffect, useId, useState, type KeyboardEvent } from "react"
import { Link, useLocation, useParams } from "react-router-dom"
import PageShell, { type ShellSection } from "../components/PageShell.tsx"
import PageState from "../components/PageState.tsx"
@ -18,9 +25,11 @@ import ContentBlocks from "../components/ContentBlocks.tsx"
import PeopleTiles from "../components/PeopleTiles.tsx"
import { mediaUrl } from "../lib/media.ts"
import { postDate, useBlogPost } from "../lib/useBlog.ts"
import { accentText, BRAND } from "../lib/color.ts"
import { accentText, BRAND, readableOn, withAlpha } from "../lib/color.ts"
import { useReadingMode } from "../lib/readingMode.ts"
import { jumpTo } from "../lib/focus.ts"
import PostContents from "../components/PostContents.tsx"
import { headingAnchors } from "../lib/contents.ts"
import { headingAnchors, splitTabs, type PostTab } from "../lib/contents.ts"
import QrCode from "../components/QrCode.tsx"
import RequestLink from "../components/RequestLink.tsx"
import { siteUrl } from "../lib/site.ts"
@ -34,6 +43,22 @@ const BACK = { to: "/community#blog", label: "Community Blog" }
export default function BlogPost() {
const { id } = useParams()
const { data: post, loading, error, notFound, reload } = useBlogPost(id)
const [tabIndex, setTabIndex] = useState(0)
const reading = useReadingMode()
const { hash } = useLocation()
// A link into another tab (#tab-…) opens it, then goes to the heading.
useEffect(() => {
if (!post || !hash.startsWith("#tab-")) return
const target = decodeURIComponent(hash.slice(1))
const found = splitTabs(post.blocks).tabs
const index = found.findIndex((tab) => target === tab.id || target.startsWith(tab.prefix))
if (index < 0) return
setTabIndex(index)
// The tab's own id is its printed title, hidden on screen: opening
// it is enough. A heading inside it is scrolled to once it shows.
if (target !== found[index].id) requestAnimationFrame(() => jumpTo(target))
}, [post, hash])
if (!post) {
return (
@ -49,8 +74,16 @@ export default function BlogPost() {
)
}
// Two headings or more make a list worth showing.
const contents = post.show_contents ? headingAnchors(post.blocks).entries : []
const { intro, tabs } = splitTabs(post.blocks)
const current = Math.min(tabIndex, Math.max(tabs.length - 1, 0))
// Two headings or more make a list worth showing: the intro's and
// the open tab's.
const contents = post.show_contents
? tabs.length
? [...headingAnchors(intro).entries, ...headingAnchors(tabs[current].blocks, tabs[current].prefix).entries]
: headingAnchors(post.blocks).entries
: []
const withContents = contents.length >= 2
const postUrl = siteUrl(`/blog/${post.id}`)
@ -146,7 +179,14 @@ export default function BlogPost() {
/>
)}
<ContentBlocks blocks={post.blocks} accent={BRAND} />
{tabs.length ? (
<>
<ContentBlocks blocks={intro} accent={BRAND} />
<PostTabs tabs={tabs} current={current} onSelect={setTabIndex} all={reading} />
</>
) : (
<ContentBlocks blocks={post.blocks} accent={BRAND} />
)}
<div className="flex flex-wrap items-center gap-3 border-t border-brand/15 pt-6 text-sm text-muted print:hidden">
Have a story to share?
@ -190,3 +230,86 @@ export default function BlogPost() {
/>
)
}
/* The post's tabs: a row of buttons, then the open tab's blocks. The
others stay in the page, hidden, so print shows them all; `all`
(reading mode) shows every tab, each under its title. */
function PostTabs({
tabs,
current,
onSelect,
all,
}: {
tabs: PostTab[]
current: number
onSelect: (index: number) => void
all: boolean
}) {
const baseId = useId()
// Arrows move one tab and wrap; Home and End jump to the ends.
const onKey = (e: KeyboardEvent<HTMLButtonElement>) => {
const last = tabs.length - 1
const next =
e.key === "ArrowRight" ? (current + 1) % tabs.length
: e.key === "ArrowLeft" ? (current + last) % tabs.length
: e.key === "Home" ? 0
: e.key === "End" ? last
: null
if (next === null) return
e.preventDefault()
onSelect(next)
document.getElementById(`${baseId}-tab-${next}`)?.focus()
}
return (
<div className="space-y-6">
{!all && (
<div role="tablist" aria-label="Parts of this post" className="flex flex-wrap gap-2 print:hidden">
{tabs.map((tab, index) => {
const selected = index === current
return (
<button
key={tab.id}
id={`${baseId}-tab-${index}`}
type="button"
role="tab"
aria-selected={selected}
aria-controls={`${baseId}-panel-${index}`}
tabIndex={selected ? 0 : -1}
onClick={() => onSelect(index)}
onKeyDown={onKey}
className="btn border px-5 py-2 text-sm transition-colors"
style={
selected
? { background: BRAND, borderColor: BRAND, color: readableOn(BRAND) }
: { borderColor: withAlpha(BRAND, 33), color: accentText(BRAND) }
}
>
{tab.title}
</button>
)
})}
</div>
)}
{tabs.map((tab, index) => (
<div
key={tab.id}
id={`${baseId}-panel-${index}`}
role={all ? undefined : "tabpanel"}
aria-labelledby={all ? undefined : `${baseId}-tab-${index}`}
className={all || index === current ? "space-y-6" : "hidden space-y-6 print:block"}
>
<h2
id={tab.id}
className={`text-3xl font-bold ${all ? "" : "hidden print:block"}`}
style={{ color: accentText(BRAND) }}
>
{tab.title}
</h2>
<ContentBlocks blocks={tab.blocks} accent={BRAND} anchorPrefix={tab.prefix} />
</div>
))}
</div>
)
}

View file

@ -31,7 +31,7 @@ import OrgListCards from './sections/OrgList-Card.tsx'
import EventListCards, { EventCardsToggle } from './sections/EventList-Cards.tsx'
import CommunityBlog from './sections/CommunityBlog.tsx'
import HistoryTimeline from './sections/history/HistoryTimeline.tsx'
import PeopleDirectory, { DIRECTORY_PREVIEW } from './sections/PeopleDirectory.tsx'
import { DirectoryTabs, DIRECTORY_PREVIEW } from './sections/PeopleDirectory.tsx'
/* Year the program starts: decades ending before it get the
pre-program look on the timeline. */
@ -91,8 +91,8 @@ const PRESETS: Record<string, (section: SitePageSection) => Record<string, any>>
}),
timeline: () => ({ Component: Timeline }),
people_directory: (section) => ({
Component: PeopleDirectory,
props: { tag: section.tag_id, limit: DIRECTORY_PREVIEW },
Component: DirectoryTabs,
props: { tags: section.tag_ids, limit: DIRECTORY_PREVIEW },
}),
}

View file

@ -0,0 +1,196 @@
/* ═══════════════════════════════════════════════════════════════
ADMIN: IMAGE CONVERTER (Tools → Image converter, everyone)
Pictures turned into JPG, PNG or WebP in the browser
(src/lib/convertImage.ts): pick or drop any number, choose the
format (and quality, for JPG and WebP), download each. Nothing is
uploaded or kept. The Media library's Download as does the same
for a picture already there.
═══════════════════════════════════════════════════════════════ */
import { useId, useState } from "react";
import { OUTPUT_FORMATS, convertImage, renamed, saveBlob, type OutputType } from "../../lib/convertImage.ts";
const MUTED = "var(--color-muted)";
const button =
"btn border border-brand px-4 py-2 text-sm text-link transition-colors hover:bg-tint disabled:cursor-default disabled:opacity-50";
const primary =
"btn bg-action px-5 py-2.5 text-white transition-colors hover:bg-action-hover disabled:bg-muted/25";
type Item = { file: File; result?: Blob; error?: string };
const kb = (bytes: number) => (bytes >= 1024 * 1024 ? `${(bytes / 1024 / 1024).toFixed(1)} MB` : `${Math.max(1, Math.round(bytes / 1024))} KB`);
export default function AdminConvert() {
const inputId = useId();
const formatId = useId();
const qualityId = useId();
const [items, setItems] = useState<Item[]>([]);
const [type, setType] = useState<OutputType>("image/jpeg");
const [quality, setQuality] = useState(90);
const [busy, setBusy] = useState(false);
const [over, setOver] = useState(false);
const lossy = OUTPUT_FORMATS.find((f) => f.type === type)?.lossy;
const add = (files: FileList | null) => {
const pictures = [...(files ?? [])].filter((file) => file.type.startsWith("image/") || /\.(heic|heif)$/i.test(file.name));
setItems((current) => [...current, ...pictures.map((file) => ({ file }))]);
};
async function convertAll() {
setBusy(true);
const next: Item[] = [];
for (const item of items) {
try {
next.push({ file: item.file, result: await convertImage(item.file, type, quality / 100) });
} catch (err) {
next.push({ file: item.file, error: err instanceof Error ? err.message : "Couldn't convert it." });
}
}
setItems(next);
setBusy(false);
}
const done = items.filter((item) => item.result);
return (
<div>
<div className="flex flex-wrap items-baseline gap-3">
<h1 className="text-2xl font-bold text-link">Image converter</h1>
<p className="text-sm" style={{ color: MUTED }}>
Turn pictures into JPG, PNG or WebP. Done in your browser: nothing is uploaded.
</p>
</div>
<section className="mt-6 bg-raised p-5 shadow-md">
<label
htmlFor={inputId}
onDragOver={(e) => {
e.preventDefault();
setOver(true);
}}
onDragLeave={() => setOver(false)}
onDrop={(e) => {
e.preventDefault();
setOver(false);
add(e.dataTransfer.files);
}}
className={`block cursor-pointer border-2 p-8 text-center text-sm transition-colors ${
over ? "border-brand bg-tint" : "border-muted/30"
}`}
>
<span className="font-semibold text-link">Choose pictures</span> or drop them here
<span className="mt-1 block text-xs" style={{ color: MUTED }}>
JPEG, PNG, WebP, GIF, AVIF, BMP or SVG (HEIC in Safari only)
</span>
<input
id={inputId}
type="file"
accept="image/*,.heic,.heif"
multiple
className="sr-only"
onChange={(e) => {
add(e.target.files);
e.target.value = "";
}}
/>
</label>
<div className="mt-5 flex flex-wrap items-end gap-4">
<div>
<label htmlFor={formatId} className="block text-sm font-medium text-body">
Save as
</label>
<select
id={formatId}
value={type}
onChange={(e) => {
setType(e.target.value as OutputType);
setItems((current) => current.map(({ file }) => ({ file })));
}}
className="mt-1 border border-muted/25 bg-surface px-3 py-2 text-sm text-body"
>
{OUTPUT_FORMATS.map((format) => (
<option key={format.type} value={format.type}>
{format.label}
</option>
))}
</select>
</div>
{lossy && (
<div>
<label htmlFor={qualityId} className="block text-sm font-medium text-body">
Quality: {quality}
</label>
<input
id={qualityId}
type="range"
min={40}
max={100}
value={quality}
onChange={(e) => {
setQuality(Number(e.target.value));
setItems((current) => current.map(({ file }) => ({ file })));
}}
className="mt-2 w-48 accent-[var(--color-action)]"
/>
</div>
)}
<button type="button" className={primary} disabled={busy || items.length === 0} onClick={convertAll}>
{busy ? "Converting…" : `Convert ${items.length || ""}`.trim()}
</button>
{done.length > 1 && (
<button
type="button"
className={button}
onClick={() => done.forEach((item) => saveBlob(item.result as Blob, renamed(item.file.name, type)))}
>
Download all
</button>
)}
{items.length > 0 && (
<button type="button" className={button} disabled={busy} onClick={() => setItems([])}>
Clear
</button>
)}
</div>
{type === "image/jpeg" && (
<p className="mt-2 text-xs" style={{ color: MUTED }}>
JPG has no transparency: see-through parts turn white.
</p>
)}
</section>
{items.length > 0 && (
<ul className="mt-6 divide-y divide-brand/10 bg-raised shadow-md">
{items.map((item, index) => (
<li key={`${item.file.name}-${index}`} className="flex flex-wrap items-center gap-3 px-4 py-3 text-sm">
<span className="min-w-0 flex-1 truncate text-body" title={item.file.name}>
{item.file.name}
</span>
<span style={{ color: MUTED }}>{kb(item.file.size)}</span>
{item.result ? (
<>
<span className="text-body">→ {kb(item.result.size)}</span>
<button
type="button"
className={button}
onClick={() => saveBlob(item.result as Blob, renamed(item.file.name, type))}
>
Download {renamed(item.file.name, type)}
</button>
</>
) : item.error ? (
<span className="text-danger">{item.error}</span>
) : (
<span style={{ color: MUTED }}>Ready</span>
)}
</li>
))}
</ul>
)}
</div>
);
}

View file

@ -26,7 +26,7 @@ import { ArrowRight, ArrowUpRight } from "@phosphor-icons/react";
import { Link } from "react-router-dom";
import { useAuth } from "../../lib/auth.tsx";
import { useWideAdminPage } from "../../lib/adminWidth.tsx";
import { SITE_VERSION } from "../../lib/version.ts";
import { SITE_VERSION, VERSION_NAME } from "../../lib/version.ts";
import { ROLE_LABELS, isSuper } from "../../lib/roles.ts";
import { PALETTE } from "../../lib/color.ts";
import { DATA_NAV, FORMS_NAV, PAGES_NAV, PANEL_NAV, TOOLS_NAV, target, visibleItems } from "./adminNav.ts";
@ -187,7 +187,7 @@ export default function AdminHome() {
</PanelSection>
<PanelSection title="Site">
<p className="font-mono text-xs text-muted/80">{SITE_VERSION}</p>
<p className="font-mono text-xs text-muted/80">{SITE_VERSION}{VERSION_NAME && ` · ${VERSION_NAME}`}</p>
<a
href="/"
target="_blank"

View file

@ -26,7 +26,7 @@ import { Link, NavLink, Outlet, useLocation, useNavigate } from "react-router-do
import { useAuth } from "../../lib/auth.tsx";
import { AdminTitleContext } from "../../lib/adminTitle.tsx";
import { AdminWidthContext, type AdminWidth } from "../../lib/adminWidth.tsx";
import { SITE_VERSION } from "../../lib/version.ts";
import { SITE_VERSION, VERSION_NAME } from "../../lib/version.ts";
import { ROLE_LABELS, isSuper } from "../../lib/roles.ts";
import siteLogo from "../../assets/logos/NGU_Logo.svg";
import ThemeToggle from "../../components/ThemeToggle.tsx";
@ -226,7 +226,7 @@ export default function AdminLayout() {
<img src={siteLogo} alt="NGU" className="h-6 w-auto" />
</Link>
<span className="ml-auto font-mono text-xs text-muted/70">
{SITE_VERSION}
{SITE_VERSION}{VERSION_NAME && ` · ${VERSION_NAME}`}
</span>
</div>
</footer>

View file

@ -17,6 +17,7 @@
a page (an image field stores the path, not a foreign key).
═══════════════════════════════════════════════════════════════ */
import DownloadAs from "../../components/admin/DownloadAs.tsx";
import { useEffect, useState, type FormEvent } from "react";
import { Link } from "react-router-dom";
@ -641,6 +642,9 @@ export default function AdminMedia() {
>
Open
</a>
{item.content_type?.startsWith("image/") && (
<DownloadAs url={item.url} name={item.original_name} />
)}
{roleCanWrite(user) && (
<RenameControl
item={item}

View file

@ -201,6 +201,11 @@ export const TOOLS_NAV = {
label: "Media",
blurb: "Uploaded images: logos, photos and backgrounds, ready to reuse.",
},
{
to: "/admin/convert",
label: "Image converter",
blurb: "Turn pictures into JPG, PNG or WebP, in your browser. Images in Media can also be downloaded as any of them.",
},
{
to: "/admin/clips",
label: "Video clips",

View file

@ -11,14 +11,21 @@
"Vocals, piano · Gospel, folk"), or their tagline without one;
their details panel adds their links. With a limit, the first that
many show and a link leads to the full directory.
DirectoryTabs is the preset with several tags (078): a tab each,
in the order picked (Community's Directories: Musicians, Authors,
Creators). One tag shows without tabs; reading mode lists every
tag's people, each under its name.
═══════════════════════════════════════════════════════════════ */
import { ArrowRight } from '@phosphor-icons/react'
import { useId, useState, type KeyboardEvent } from 'react'
import { Link } from 'react-router-dom'
import { PeopleTilesView } from '../../components/PeopleTiles.tsx'
import { useDirectory } from '../../lib/useDirectory.ts'
import { accentText, BRAND } from '../../lib/color.ts'
import { useReadingMode } from '../../lib/readingMode.ts'
import { accentText, BRAND, readableOn, withAlpha } from '../../lib/color.ts'
/* How many people a section shows before "See the full directory". */
export const DIRECTORY_PREVIEW = 12
@ -78,3 +85,95 @@ export default function PeopleDirectory({ tag, limit, accent = BRAND }: PeopleDi
</div>
)
}
/* ── Several tags, a tab each ────────────────────────────────── */
type DirectoryTabsProps = {
tags: string[]
limit?: number
accent?: string
}
export function DirectoryTabs({ tags, limit, accent = BRAND }: DirectoryTabsProps) {
const [active, setActive] = useState(0)
const baseId = useId()
const reading = useReadingMode()
if (tags.length <= 1) return <PeopleDirectory tag={tags[0]} limit={limit} accent={accent} />
if (reading) {
return (
<>
{tags.map((tag) => (
<div key={tag} className="mb-10">
<div className="mx-auto max-w-6xl px-6">
<h3 className="mb-4 text-xl font-bold">
<TagName tag={tag} />
</h3>
</div>
<PeopleDirectory tag={tag} limit={limit} accent={accent} />
</div>
))}
</>
)
}
const current = Math.min(active, tags.length - 1)
// Arrows move one tab and wrap; Home and End jump to the ends.
const onKey = (e: KeyboardEvent<HTMLButtonElement>) => {
const last = tags.length - 1
const next =
e.key === 'ArrowRight' ? (current + 1) % tags.length
: e.key === 'ArrowLeft' ? (current + last) % tags.length
: e.key === 'Home' ? 0
: e.key === 'End' ? last
: null
if (next === null) return
e.preventDefault()
setActive(next)
document.getElementById(`${baseId}-tab-${next}`)?.focus()
}
return (
<>
<div className="mx-auto max-w-6xl px-6">
<div role="tablist" aria-label="Directories" className="mb-8 flex flex-wrap gap-2">
{tags.map((tag, index) => {
const selected = index === current
return (
<button
key={tag}
id={`${baseId}-tab-${index}`}
type="button"
role="tab"
aria-selected={selected}
aria-controls={`${baseId}-panel`}
tabIndex={selected ? 0 : -1}
onClick={() => setActive(index)}
onKeyDown={onKey}
className="btn border px-5 py-2 text-sm transition-colors"
style={
selected
? { background: accent, borderColor: accent, color: readableOn(accent) }
: { borderColor: withAlpha(accent, 33), color: accentText(accent) }
}
>
<TagName tag={tag} />
</button>
)
})}
</div>
</div>
<div id={`${baseId}-panel`} role="tabpanel" aria-labelledby={`${baseId}-tab-${current}`}>
<PeopleDirectory key={tags[current]} tag={tags[current]} limit={limit} accent={accent} />
</div>
</>
)
}
/* A tag's name, from its directory (asked once, and kept for its tab). */
function TagName({ tag }: { tag: string }) {
const { data } = useDirectory(tag)
return <>{data?.name ?? tag}</>
}

View file

@ -19,9 +19,11 @@
video a featured video under a "Featured video" badge.
Never autoplays: an embed waits for play, a file
shows the browser's player
event an event's card under a "Featured event" badge:
its photo, dates, place and buttons. The API picks
the event (pinned, else the countdown's)
event an event's card, under a "Featured event" badge
from lg up (on a phone the card sits under the
words and the badge is left out): its photo, dates,
place and buttons. The API picks the event (pinned,
else the countdown's)
A choice with nothing to show falls back: photos with no photos
to brand, a feature with no link set (or no event to show) to
@ -125,6 +127,12 @@ export default function HeroStage({ hero }: { hero: Hero | null }) {
{feature === 'event' && hero?.event && (
<div className="lg:col-span-7">
{/* Over the card it names, not over the headline beside it;
on a phone the card under the words speaks for itself. */}
<p className="mb-4 hidden items-center gap-3 bg-white/10 px-4 py-1.5 text-sm font-semibold uppercase tracking-[0.2em] text-white backdrop-blur lg:inline-flex">
<Star className="text-[var(--pal-amber-2)]" weight="fill" aria-hidden="true" />
Featured event
</p>
<EventPanel event={hero.event} />
</div>
)}
@ -151,12 +159,7 @@ function Words({ hero, feature }: { hero: Hero; feature: HeroFeature }) {
</span>
)}
</p>
) : feature === 'event' ? (
<p className="mb-6 inline-flex items-center gap-3 bg-white/10 px-4 py-1.5 text-sm font-semibold uppercase tracking-[0.2em] backdrop-blur">
<Star className="text-[var(--pal-amber-2)]" weight="fill" aria-hidden="true" />
Featured event
</p>
) : feature === 'video' ? (
) : feature === 'event' ? null : feature === 'video' ? (
<p className="mb-6 inline-flex items-center gap-3 bg-white/10 px-4 py-1.5 text-sm font-semibold uppercase tracking-[0.2em] backdrop-blur">
<Play className="text-[var(--pal-amber-2)]" weight="fill" aria-hidden="true" />
Featured video