Navigation: section dropdowns, a side nav, Home's sections from the front page
- The header's second strip is gone: each top link drops down its page's sections on hover or keyboard focus. - Retreats, Community, Resources, Organization and History get the admin editors' "On this page" column (SectionNav), sticky at the left from lg up, with the section being read lit. - Home's sections in the dropdown, mobile menu, footer site map, the feedback form and the QR maker are the bands the front page is showing, in its order and under its headings (navSections.ts, frontPageBands.ts, which Home.tsx now draws from too). - Resources comes before Organization in the nav and footer. - The Organization page draws from its own editor's content. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
43797f38bc
commit
ed0f12022f
16 changed files with 283 additions and 237 deletions
|
|
@ -87,6 +87,7 @@ export default function CommunityPage() {
|
|||
|
||||
return (
|
||||
<PageShell
|
||||
sideNav
|
||||
title={PAGE.title}
|
||||
intro={PAGE.description}
|
||||
sections={sections}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ export default function History() {
|
|||
|
||||
return (
|
||||
<PageShell
|
||||
sideNav
|
||||
title={PAGE.title}
|
||||
intro={PAGE.description}
|
||||
sections={[
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import {
|
|||
type FrontPageSection,
|
||||
type FrontPageSectionKey,
|
||||
} from '../lib/useFrontPage.ts'
|
||||
import { FRONT_PAGE_BANDS, bandShows } from '../lib/frontPageBands.ts'
|
||||
import './sections/home/home.css'
|
||||
|
||||
type BandProps = {
|
||||
|
|
@ -51,56 +52,26 @@ type BandProps = {
|
|||
position: number
|
||||
}
|
||||
|
||||
/* Default headings for a band the admin didn't title, and how each
|
||||
one renders. The ids are the page anchors, #connect is what the
|
||||
hero's second button points at out of the box. */
|
||||
const SECTIONS: Record<
|
||||
FrontPageSectionKey,
|
||||
{ title: string; render: (props: BandProps) => ReactNode }
|
||||
> = {
|
||||
countdown: {
|
||||
title: 'Next up',
|
||||
render: ({ page, position }) =>
|
||||
page.countdown && <NextEventCountdown event={page.countdown} overlap={position === 0} />,
|
||||
},
|
||||
retreats: {
|
||||
title: 'National Retreats',
|
||||
render: ({ section, title }) => (
|
||||
<RetreatsBand id="retreats" title={title} blurb={section.blurb} />
|
||||
),
|
||||
},
|
||||
calendar: {
|
||||
title: 'What’s on',
|
||||
render: ({ section, title }) => (
|
||||
<CalendarBand id="calendar" title={title} blurb={section.blurb} />
|
||||
),
|
||||
},
|
||||
stats: {
|
||||
title: 'By the numbers',
|
||||
render: ({ page, section, title }) =>
|
||||
page.stats.length > 0 && (
|
||||
<StatsBand id="numbers" title={title} blurb={section.blurb} stats={page.stats} />
|
||||
),
|
||||
},
|
||||
timeline: {
|
||||
title: 'Our story so far',
|
||||
render: ({ section, title }) => (
|
||||
<FeaturedTimelineRail id="story" title={title} blurb={section.blurb} />
|
||||
),
|
||||
},
|
||||
connect: {
|
||||
title: 'Find your way in',
|
||||
render: ({ page, section, title }) => (
|
||||
<Pathfinder id="connect" title={title} blurb={section.blurb} paths={page.paths} />
|
||||
),
|
||||
},
|
||||
featured: {
|
||||
title: 'Featured',
|
||||
render: ({ page, section, title }) =>
|
||||
page.featured.length > 0 && (
|
||||
<FeaturedBand id="featured" title={title} blurb={section.blurb} cards={page.featured} />
|
||||
),
|
||||
},
|
||||
/* How each band renders. Its anchor, its heading when the admin
|
||||
gave it none, and whether it has anything to draw are
|
||||
frontPageBands.ts's, which the nav and footer read too; #connect is
|
||||
what the hero's second button points at out of the box. */
|
||||
const id = (key: FrontPageSectionKey) => FRONT_PAGE_BANDS[key].id ?? undefined
|
||||
|
||||
const BANDS: Record<FrontPageSectionKey, (props: BandProps) => ReactNode> = {
|
||||
countdown: ({ page, position }) => <NextEventCountdown event={page.countdown!} overlap={position === 0} />,
|
||||
retreats: ({ section, title }) => <RetreatsBand id={id('retreats')!} title={title} blurb={section.blurb} />,
|
||||
calendar: ({ section, title }) => <CalendarBand id={id('calendar')!} title={title} blurb={section.blurb} />,
|
||||
stats: ({ page, section, title }) => (
|
||||
<StatsBand id={id('stats')!} title={title} blurb={section.blurb} stats={page.stats} />
|
||||
),
|
||||
timeline: ({ section, title }) => <FeaturedTimelineRail id={id('timeline')!} title={title} blurb={section.blurb} />,
|
||||
connect: ({ page, section, title }) => (
|
||||
<Pathfinder id={id('connect')!} title={title} blurb={section.blurb} paths={page.paths} />
|
||||
),
|
||||
featured: ({ page, section, title }) => (
|
||||
<FeaturedBand id={id('featured')!} title={title} blurb={section.blurb} cards={page.featured} />
|
||||
),
|
||||
}
|
||||
|
||||
export default function Home() {
|
||||
|
|
@ -138,15 +109,16 @@ export default function Home() {
|
|||
)}
|
||||
|
||||
{page?.sections.map((section, position) => {
|
||||
const band = SECTIONS[section.section]
|
||||
// A key the CHECK has gained since this file was written.
|
||||
if (!band) return null
|
||||
const render = BANDS[section.section]
|
||||
// A key the CHECK has gained since this file was written, or a
|
||||
// band with nothing to draw.
|
||||
if (!render || !bandShows(page, section.section)) return null
|
||||
return (
|
||||
<div key={section.section}>
|
||||
{band.render({
|
||||
{render({
|
||||
page,
|
||||
section,
|
||||
title: section.title || band.title,
|
||||
title: section.title || FRONT_PAGE_BANDS[section.section].title,
|
||||
position,
|
||||
})}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,50 +1,49 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
ORGANIZATION: /organization (it was /leadership, which the API
|
||||
redirects here)
|
||||
ORGANIZATION: /organization
|
||||
|
||||
NGU itself, in three parts:
|
||||
NGU itself, in three parts, edited in the admin as Pages →
|
||||
Organization page (GET /organization-page):
|
||||
|
||||
mission Mission, Vision & Values: the national organization
|
||||
record's own description and content blocks (Data →
|
||||
Organizations → NGU), so editors change them with the
|
||||
block editor
|
||||
leadership that record's teams, each with its people (OrgTeams):
|
||||
the Board of Trustees, the Retreat Team, committees
|
||||
and volunteers, in the admin's order
|
||||
mission Mission, Vision & Values: the page's mission blocks
|
||||
leadership its leadership blocks, in order (a People block per
|
||||
team: the Board of Trustees, then the Retreat Team),
|
||||
then Volunteering: a title, a blurb and its links
|
||||
contact NGU's address, nonprofit status and email
|
||||
(src/data/organizationDetails.ts), and the record's
|
||||
own contact links (OrgContact)
|
||||
(src/data/organizationDetails.ts)
|
||||
|
||||
The record is the one organization of kind national, found rather
|
||||
than named, so its URL ID can change.
|
||||
A section with nothing written yet says so (ComingSoon) rather
|
||||
than showing a heading over nothing.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import PageShell from '../components/PageShell.tsx'
|
||||
import ComingSoon from '../components/ComingSoon.tsx'
|
||||
import ContentBlocks from '../components/ContentBlocks.tsx'
|
||||
import OrgTeams, { hasTeams } from '../components/OrgTeams.tsx'
|
||||
import OrgContact from '../components/OrgContact.tsx'
|
||||
import HomeLink from './sections/home/HomeLink.tsx'
|
||||
import { sitePage } from '../lib/site.ts'
|
||||
import { useOrganizations } from '../lib/organizations.ts'
|
||||
import { useOrganization, type OrganizationRecord } from '../lib/useContent.ts'
|
||||
import { useRecord } from '../lib/useRecord.ts'
|
||||
import type { ContentBlock } from '../lib/useContent.ts'
|
||||
import { ORGANIZATION_DETAILS } from '../data/organizationDetails.ts'
|
||||
import { ACCENTS, BRAND } from '../lib/color.ts'
|
||||
|
||||
/* Title and intro: site.json, which also gives the search metadata. */
|
||||
const PAGE = sitePage('/organization')
|
||||
|
||||
type OrganizationPage = {
|
||||
mission_title?: string | null
|
||||
mission_blocks: ContentBlock[]
|
||||
leadership_title?: string | null
|
||||
leadership_blurb?: string | null
|
||||
leadership_blocks: ContentBlock[]
|
||||
volunteer: { title?: string | null; blurb?: string | null; links: Array<{ label: string; url: string }> }
|
||||
}
|
||||
|
||||
export default function Organization() {
|
||||
const national = useOrganizations('national')
|
||||
const id = national.organizations[0]?.id
|
||||
const record = useOrganization(id)
|
||||
const org = record.data ?? null
|
||||
const failed = national.error || record.error
|
||||
const loading = !failed && !org && (national.loading || record.loading || Boolean(id))
|
||||
const { data: page, loading, error } = useRecord<OrganizationPage>('/organization-page', 'page')
|
||||
|
||||
const pending = (what: string) =>
|
||||
failed ? (
|
||||
error ? (
|
||||
<p className="mx-auto max-w-6xl px-6 text-danger">Couldn’t load {what} right now.</p>
|
||||
) : loading ? (
|
||||
) : loading || !page ? (
|
||||
<div className="mx-auto max-w-6xl px-6">
|
||||
<div className="skeleton !min-h-40" aria-label={`Loading ${what}`} />
|
||||
</div>
|
||||
|
|
@ -54,59 +53,78 @@ export default function Organization() {
|
|||
<PageShell
|
||||
title={PAGE.title}
|
||||
intro={PAGE.description}
|
||||
sideNav
|
||||
sections={[
|
||||
{
|
||||
id: 'mission',
|
||||
title: 'Mission, Vision & Values',
|
||||
title: page?.mission_title || 'Mission, Vision & Values',
|
||||
accent: BRAND,
|
||||
content: pending('our mission') ?? <Mission org={org} />,
|
||||
content:
|
||||
pending('our mission') ??
|
||||
(page!.mission_blocks.length > 0 ? (
|
||||
<div className="mx-auto max-w-6xl px-6">
|
||||
<div className="max-w-3xl">
|
||||
<ContentBlocks blocks={page!.mission_blocks} accent={BRAND} />
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<ComingSoon what="our mission, vision and values" />
|
||||
)),
|
||||
},
|
||||
{
|
||||
id: 'leadership',
|
||||
title: 'Leadership',
|
||||
blurb: 'Our board, retreat team, committees and volunteers.',
|
||||
title: page?.leadership_title || 'Leadership',
|
||||
blurb: page?.leadership_blurb ?? undefined,
|
||||
accent: ACCENTS.green,
|
||||
content:
|
||||
pending('our leadership') ??
|
||||
(org && hasTeams(org) ? (
|
||||
<div className="mx-auto max-w-6xl px-6">
|
||||
<OrgTeams org={org} accent={ACCENTS.green} />
|
||||
</div>
|
||||
) : (
|
||||
<ComingSoon what="our leadership list" />
|
||||
)),
|
||||
content: pending('our leadership') ?? <Leadership page={page!} />,
|
||||
},
|
||||
{
|
||||
id: 'contact',
|
||||
title: 'Details & Contact',
|
||||
accent: ACCENTS.deep,
|
||||
content: <Contact org={org} />,
|
||||
content: <Contact />,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function Mission({ org }: { org: OrganizationRecord | null }) {
|
||||
const paragraphs = org?.description ?? []
|
||||
const blocks = org?.blocks ?? []
|
||||
if (paragraphs.length === 0 && blocks.length === 0) return <ComingSoon what="our mission, vision and values" />
|
||||
function Leadership({ page }: { page: OrganizationPage }) {
|
||||
const { volunteer } = page
|
||||
const hasVolunteering = Boolean(volunteer.title || volunteer.blurb || volunteer.links.length)
|
||||
|
||||
return (
|
||||
<div className="mx-auto max-w-6xl space-y-6 px-6">
|
||||
{paragraphs.map((paragraph, index) => (
|
||||
<p key={index} className="max-w-3xl text-lg leading-relaxed text-body">
|
||||
{paragraph}
|
||||
</p>
|
||||
))}
|
||||
<div className="max-w-3xl">
|
||||
<ContentBlocks blocks={blocks} accent={BRAND} />
|
||||
</div>
|
||||
<div className="mx-auto max-w-6xl space-y-14 px-6">
|
||||
{page.leadership_blocks.length > 0 ? (
|
||||
<ContentBlocks blocks={page.leadership_blocks} accent={ACCENTS.green} />
|
||||
) : (
|
||||
<ComingSoon what="our leadership list" />
|
||||
)}
|
||||
|
||||
{hasVolunteering && (
|
||||
<div className="max-w-3xl">
|
||||
<h3 className="text-2xl font-bold text-ink">{volunteer.title || 'Volunteering'}</h3>
|
||||
{volunteer.blurb && <p className="mt-2 leading-relaxed text-body">{volunteer.blurb}</p>}
|
||||
{volunteer.links.length > 0 && (
|
||||
<div className="mt-5 flex flex-wrap gap-3">
|
||||
{volunteer.links.map((link) => (
|
||||
<HomeLink
|
||||
key={`${link.url}-${link.label}`}
|
||||
url={link.url}
|
||||
className="btn inline-block bg-action px-5 py-2.5 text-white transition-colors hover:bg-action-hover"
|
||||
>
|
||||
{link.label}
|
||||
</HomeLink>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function Contact({ org }: { org: OrganizationRecord | null }) {
|
||||
function Contact() {
|
||||
const details = ORGANIZATION_DETAILS
|
||||
return (
|
||||
<div className="mx-auto grid max-w-6xl gap-8 px-6 md:grid-cols-2">
|
||||
|
|
@ -122,14 +140,13 @@ function Contact({ org }: { org: OrganizationRecord | null }) {
|
|||
{details.nonprofit} Tax ID: {details.taxId}.
|
||||
</p>
|
||||
</div>
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<a
|
||||
href={`mailto:${details.email}`}
|
||||
className="btn inline-block border border-link px-6 py-2.5 text-link transition-colors hover:bg-tint"
|
||||
>
|
||||
{details.email}
|
||||
</a>
|
||||
{org && <OrgContact org={org} accent={ACCENTS.deep} />}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ const SECTIONS = [
|
|||
export default function ResourcesPage() {
|
||||
return (
|
||||
<PageShell
|
||||
sideNav
|
||||
title={PAGE.title}
|
||||
intro={PAGE.description}
|
||||
sections={SECTIONS}
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ export default function RetreatsPage() {
|
|||
|
||||
return (
|
||||
<PageShell
|
||||
sideNav
|
||||
title={PAGE.title}
|
||||
intro={PAGE.description}
|
||||
sections={sections}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
import { CaretDown } from '@phosphor-icons/react';
|
||||
import { useState } from "react";
|
||||
import { post, ApiError } from "../../lib/api.ts";
|
||||
import { PAGE_LINKS, PAGE_SECTIONS } from "../../navConfig.ts";
|
||||
import { PAGE_LINKS } from "../../navConfig.ts";
|
||||
import { useNavSections, type NavSection } from "../../lib/navSections.ts";
|
||||
import { DATA_REQUEST, FEEDBACK_TYPES } from "../../data/feedbackTypes.ts";
|
||||
import { accentText, BRAND } from '../../lib/color.ts'
|
||||
|
||||
|
|
@ -175,7 +176,8 @@ export function TilePicker({
|
|||
/* ── Where on the site ───────────────────────────────────────── */
|
||||
|
||||
function LocationPicker({ page, section, onPageChange, onSectionChange }) {
|
||||
const sections = page === SITE_WIDE ? [] : PAGE_SECTIONS[page] ?? [];
|
||||
const sectionsOf = useNavSections();
|
||||
const sections = page === SITE_WIDE ? [] : sectionsOf(page);
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
|
@ -228,10 +230,10 @@ function LocationPicker({ page, section, onPageChange, onSectionChange }) {
|
|||
}
|
||||
|
||||
// Human-readable version of the picked location, for the thank-you panel.
|
||||
function describeLocation(page, section) {
|
||||
function describeLocation(page, section, sectionsOf: (path: string) => NavSection[]) {
|
||||
if (page === SITE_WIDE) return null;
|
||||
const pageLabel = PAGE_LINKS.find((p) => p.path === page)?.label ?? page;
|
||||
const sectionLabel = (PAGE_SECTIONS[page] ?? []).find(
|
||||
const sectionLabel = sectionsOf(page).find(
|
||||
(s) => s.hash === section,
|
||||
)?.label;
|
||||
return sectionLabel ? `${pageLabel} → ${sectionLabel}` : pageLabel;
|
||||
|
|
@ -240,6 +242,7 @@ function describeLocation(page, section) {
|
|||
/* ── The form ────────────────────────────────────────────────── */
|
||||
|
||||
export default function FeedbackForm({ fixedType }: { fixedType?: string } = {}) {
|
||||
const sectionsOf = useNavSections();
|
||||
const request = fixedType === DATA_REQUEST.id;
|
||||
const [type, setType] = useState<any>(fixedType ?? null);
|
||||
const [page, setPage] = useState(SITE_WIDE);
|
||||
|
|
@ -309,7 +312,7 @@ export default function FeedbackForm({ fixedType }: { fixedType?: string } = {})
|
|||
}
|
||||
|
||||
if (status === "sent") {
|
||||
const where = describeLocation(page, section);
|
||||
const where = describeLocation(page, section, sectionsOf);
|
||||
return (
|
||||
<div
|
||||
aria-live="polite"
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@
|
|||
import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
|
||||
|
||||
import QrCode, { QR_DOVE, QR_INK, QR_PAPER, type QrCenter } from '../../components/QrCode.tsx'
|
||||
import { NAV_ACTIONS, PAGE_LINKS, PAGE_SECTIONS } from '../../navConfig.ts'
|
||||
import { NAV_ACTIONS, PAGE_LINKS } from '../../navConfig.ts'
|
||||
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'
|
||||
|
|
@ -252,6 +253,7 @@ function downloadPng(svg: SVGSVGElement, stem: string) {
|
|||
}
|
||||
|
||||
export default function QrCodeMaker() {
|
||||
const sectionsOf = useNavSections();
|
||||
const { data: directory, loading, error } = useDirectory()
|
||||
|
||||
const [kind, setKind] = useState<Kind>('pages')
|
||||
|
|
@ -277,7 +279,7 @@ export default function QrCodeMaker() {
|
|||
}
|
||||
}, [choices, path])
|
||||
|
||||
const sections = kind === 'pages' ? (PAGE_SECTIONS[path] ?? []) : []
|
||||
const sections = kind === 'pages' ? sectionsOf(path) : []
|
||||
const selected = choices.find((c) => c.path === path) ?? null
|
||||
const typed = kind === 'custom' ? typedUrl(custom) : null
|
||||
const target = kind === 'custom' ? typed : selected ? `${selected.path}${section}` : null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue