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>
)
}