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
|
|
@ -1,5 +1,6 @@
|
|||
import { Link } from "react-router-dom";
|
||||
import { PAGE_LINKS, PAGE_SECTIONS, NAV_ACTIONS } from "../navConfig.ts";
|
||||
import { PAGE_LINKS, NAV_ACTIONS } from "../navConfig.ts";
|
||||
import { useNavSections } from "../lib/navSections.ts";
|
||||
import siteLogo from "../assets/logos/NGU_Logo.svg";
|
||||
import PlatformIcon from "./PlatformIcon.tsx";
|
||||
import { ORGANIZATION_DETAILS as Organization_Details } from "../data/organizationDetails.ts";
|
||||
|
|
@ -44,6 +45,7 @@ const sectionLinkClass =
|
|||
const headingClass = "text-white/90 text-sm font-semibold mb-4";
|
||||
|
||||
export default function Footer() {
|
||||
const sectionsOf = useNavSections();
|
||||
return (
|
||||
<footer className="py-16 px-6" style={{ background: "#001011" }}>
|
||||
<div className="max-w-6xl mx-auto">
|
||||
|
|
@ -85,7 +87,7 @@ export default function Footer() {
|
|||
<h2 className={headingClass}>Site Map</h2>
|
||||
<ul className="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-x-6 gap-y-6">
|
||||
{PAGE_LINKS.map((page) => {
|
||||
const sections = PAGE_SECTIONS[page.path] ?? [];
|
||||
const sections = sectionsOf(page.path);
|
||||
return (
|
||||
<li key={page.path}>
|
||||
<Link to={page.path} className={pageLinkClass}>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { X, List } from "@phosphor-icons/react";
|
||||
import { Suspense, useState, useEffect, useRef } from "react";
|
||||
import { NavLink, Link, Outlet, useLocation } from "react-router-dom";
|
||||
import { PAGE_LINKS, PAGE_SECTIONS, NAV_ACTIONS } from "../navConfig.ts";
|
||||
import { PAGE_LINKS, NAV_ACTIONS } from "../navConfig.ts";
|
||||
import { useNavSections } from "../lib/navSections.ts";
|
||||
import Banner from "./Banner.tsx";
|
||||
import siteLogo from "../assets/logos/NGU_Logo.svg";
|
||||
import Footer from "./Footer.tsx";
|
||||
|
|
@ -76,23 +77,18 @@ const navActions = NAV_ACTIONS as NavActionItem[];
|
|||
|
||||
export default function Layout() {
|
||||
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
|
||||
const [activeSection, setActiveSection] = useState<string | null>(null);
|
||||
// Measured below; this first guess (nav, plus the section strip on
|
||||
// pages that have one) keeps the content from jumping when it lands.
|
||||
const [headerHeight, setHeaderHeight] = useState(() =>
|
||||
72 + ((PAGE_SECTIONS[window.location.pathname] ?? []).length ? 36 : 0),
|
||||
);
|
||||
// Measured below; this first guess keeps the content from jumping
|
||||
// when it lands.
|
||||
const [headerHeight, setHeaderHeight] = useState(72);
|
||||
const headerRef = useRef<HTMLElement>(null);
|
||||
const closeMenuRef = useRef<HTMLButtonElement>(null);
|
||||
const location = useLocation();
|
||||
|
||||
const sections = PAGE_SECTIONS[location.pathname] ?? [];
|
||||
const activePage = PAGE_LINKS.find((p) => p.path === location.pathname);
|
||||
const sectionsOf = useNavSections();
|
||||
|
||||
// Close the mobile menu whenever the route changes
|
||||
useEffect(() => {
|
||||
setMobileMenuOpen(false);
|
||||
setActiveSection(null);
|
||||
}, [location.pathname]);
|
||||
|
||||
// The open menu is modal: focus starts on its close button, Escape
|
||||
|
|
@ -105,9 +101,9 @@ export default function Layout() {
|
|||
return () => window.removeEventListener("keydown", onKey);
|
||||
}, [mobileMenuOpen]);
|
||||
|
||||
// The header grows and shrinks: the banner can be dismissed and the
|
||||
// subnav only exists on some pages. Measure it instead of guessing,
|
||||
// so the spacer below always matches.
|
||||
// The header grows and shrinks: the banner can be dismissed, and
|
||||
// wraps on a narrow screen. Measure it instead of guessing, so the
|
||||
// spacer below always matches.
|
||||
useEffect(() => {
|
||||
const el = headerRef.current;
|
||||
if (!el) return;
|
||||
|
|
@ -132,33 +128,6 @@ export default function Layout() {
|
|||
window.scrollTo({ top: 0 });
|
||||
}, [location.pathname, location.hash, location.key]);
|
||||
|
||||
// Highlight whichever section is currently in view
|
||||
useEffect(() => {
|
||||
if (sections.length === 0) return;
|
||||
|
||||
const targets = sections
|
||||
.map((s) => document.querySelector(s.hash))
|
||||
.filter(Boolean);
|
||||
if (targets.length === 0) return;
|
||||
|
||||
const observer = new IntersectionObserver(
|
||||
(entries) => {
|
||||
const visible = entries
|
||||
.filter((e) => e.isIntersecting)
|
||||
.sort(
|
||||
(a, b) => a.boundingClientRect.top - b.boundingClientRect.top
|
||||
)[0];
|
||||
if (visible) setActiveSection(`#${visible.target.id}`);
|
||||
},
|
||||
// Top margin tracks the live header height so the highlight stays
|
||||
// accurate whether or not the banner is showing.
|
||||
{ rootMargin: `-${headerHeight + 30}px 0px -60% 0px`, threshold: 0 }
|
||||
);
|
||||
|
||||
targets.forEach((t) => observer.observe(t));
|
||||
return () => observer.disconnect();
|
||||
}, [location.pathname, headerHeight]);
|
||||
|
||||
return (
|
||||
// overflow-x-clip, not -hidden: hidden makes this div a scroll
|
||||
// container, and then nothing inside it can be position: sticky
|
||||
|
|
@ -195,23 +164,51 @@ export default function Layout() {
|
|||
<img src={siteLogo} alt="Next Generation of Unity" className="h-10 w-auto" />
|
||||
</Link>
|
||||
|
||||
{/* Each page, and under it on hover or keyboard focus its
|
||||
sections (navSections.ts): the sections live in these
|
||||
dropdowns rather than a strip of their own. */}
|
||||
<div className="hidden lg:flex items-center gap-6">
|
||||
{PAGE_LINKS.map((page) => (
|
||||
<NavLink
|
||||
key={page.path}
|
||||
to={page.path}
|
||||
end={page.path === "/"}
|
||||
className={({ isActive }) =>
|
||||
`text-base font-bold pb-1 border-b-2 transition-colors duration-200 ${
|
||||
isActive
|
||||
? "text-white border-[#9cc47c]"
|
||||
: "text-white/75 hover:text-white border-transparent"
|
||||
}`
|
||||
}
|
||||
>
|
||||
{page.label}
|
||||
</NavLink>
|
||||
))}
|
||||
{PAGE_LINKS.map((page) => {
|
||||
const pageSections = sectionsOf(page.path);
|
||||
return (
|
||||
<div key={page.path} className="group relative">
|
||||
<NavLink
|
||||
to={page.path}
|
||||
end={page.path === "/"}
|
||||
className={({ isActive }) =>
|
||||
`block text-base font-bold pb-1 border-b-2 transition-colors duration-200 ${
|
||||
isActive
|
||||
? "text-white border-[#9cc47c]"
|
||||
: "text-white/75 hover:text-white border-transparent"
|
||||
}`
|
||||
}
|
||||
>
|
||||
{page.label}
|
||||
</NavLink>
|
||||
{pageSections.length > 0 && (
|
||||
// pt-3 is the bridge the pointer crosses from the
|
||||
// link into the menu without it closing.
|
||||
<div className="invisible absolute top-full left-0 z-10 pt-3 opacity-0 transition-opacity duration-150 group-hover:visible group-hover:opacity-100 group-focus-within:visible group-focus-within:opacity-100">
|
||||
<ul
|
||||
className="min-w-56 py-2 shadow-xl"
|
||||
style={{ background: "rgba(0, 16, 17, 0.97)", borderTop: "2px solid #9cc47c" }}
|
||||
>
|
||||
{pageSections.map((section) => (
|
||||
<li key={section.hash}>
|
||||
<Link
|
||||
to={`${page.path}${section.hash}`}
|
||||
className="block px-4 py-2 text-sm text-white/80 transition-colors hover:bg-white/10 hover:text-[#f0bd4f] focus-visible:bg-white/10"
|
||||
>
|
||||
{section.label}
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -235,43 +232,6 @@ export default function Layout() {
|
|||
</div>
|
||||
</nav>
|
||||
|
||||
{/* Tier 2, sections of the current page */}
|
||||
{sections.length > 0 && (
|
||||
<nav
|
||||
className="hidden md:flex items-center px-6 py-2"
|
||||
aria-label={`On this page: ${activePage?.label}`}
|
||||
style={{
|
||||
background: "rgba(0, 16, 17, 0.92)",
|
||||
borderBottom: "1px solid rgba(92, 231, 255, 0.15)",
|
||||
}}
|
||||
>
|
||||
<span className="text-xs text-white/65">{activePage?.label}</span>
|
||||
|
||||
{/* Separates the page label from its sections */}
|
||||
<span
|
||||
aria-hidden
|
||||
className="mx-5 h-4 w-px"
|
||||
style={{ background: "rgba(92, 231, 255, 0.3)" }}
|
||||
/>
|
||||
|
||||
<div className="flex items-center gap-6">
|
||||
{sections.map((section) => (
|
||||
<a
|
||||
key={section.hash}
|
||||
href={section.hash}
|
||||
aria-current={activeSection === section.hash ? "location" : undefined}
|
||||
className={`text-sm transition-colors duration-200 ${
|
||||
activeSection === section.hash
|
||||
? "text-[#9cc47c]"
|
||||
: "text-white/75 hover:text-[#9cc47c]"
|
||||
}`}
|
||||
>
|
||||
{section.label}
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
</nav>
|
||||
)}
|
||||
</header>
|
||||
|
||||
<PageBackdrop />
|
||||
|
|
@ -313,7 +273,7 @@ export default function Layout() {
|
|||
|
||||
<div className="w-64">
|
||||
{PAGE_LINKS.map((page) => {
|
||||
const pageSections = PAGE_SECTIONS[page.path] ?? [];
|
||||
const pageSections = sectionsOf(page.path);
|
||||
const isActive = location.pathname === page.path;
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@
|
|||
heading with a blurb and rule. Sections paint no background of
|
||||
their own: the page's (PageBackdrop.tsx) runs behind all of them.
|
||||
|
||||
`sideNav` adds an "On this page" column at the left from lg up, the
|
||||
admin editors' own (SectionNav), sticky under the header, listing
|
||||
the sections with the one being read lit. Below lg the menu lists
|
||||
the sections instead.
|
||||
|
||||
Whatever goes inside a section is passed as `content`, the shell
|
||||
doesn't care what it is.
|
||||
|
||||
|
|
@ -33,6 +38,7 @@ import { useEffect, type ReactNode } from "react";
|
|||
|
||||
import { documentTitle } from "../lib/site.ts";
|
||||
import { accentText, BRAND } from '../lib/color.ts'
|
||||
import { SectionNav } from "./admin/SectionNav.tsx";
|
||||
|
||||
|
||||
export type ShellSection = {
|
||||
|
|
@ -48,6 +54,8 @@ type PageShellProps = {
|
|||
title: ReactNode;
|
||||
intro?: ReactNode;
|
||||
sections: ShellSection[];
|
||||
/** An "On this page" column beside the sections, from lg up. */
|
||||
sideNav?: boolean;
|
||||
};
|
||||
|
||||
export function Section({ section }: { section: ShellSection }) {
|
||||
|
|
@ -89,7 +97,7 @@ export function Section({ section }: { section: ShellSection }) {
|
|||
);
|
||||
}
|
||||
|
||||
export default function PageShell({ title, intro, sections }: PageShellProps) {
|
||||
export default function PageShell({ title, intro, sections, sideNav = false }: PageShellProps) {
|
||||
// The tab's title as the visitor moves around. The first load's
|
||||
// comes from the server (pageMeta.js), which also sets the page's
|
||||
// description and preview for search and link sharing.
|
||||
|
|
@ -97,6 +105,15 @@ export default function PageShell({ title, intro, sections }: PageShellProps) {
|
|||
if (typeof title === "string") document.title = documentTitle(title);
|
||||
}, [title]);
|
||||
|
||||
const bands = sections.map((section, i) => (
|
||||
<div key={section.id}>
|
||||
{/* Thin solid banner between sections */}
|
||||
<div className="h-2" style={{ background: section.accent }} />
|
||||
<Section section={section} />
|
||||
{i === sections.length - 1 && <div className="h-2" style={{ background: section.accent }} />}
|
||||
</div>
|
||||
));
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* Page header */}
|
||||
|
|
@ -109,16 +126,18 @@ export default function PageShell({ title, intro, sections }: PageShellProps) {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{sections.map((section, i) => (
|
||||
<div key={section.id}>
|
||||
{/* Thin solid banner between sections */}
|
||||
<div className="h-2" style={{ background: section.accent }} />
|
||||
<Section section={section} />
|
||||
{i === sections.length - 1 && (
|
||||
<div className="h-2" style={{ background: section.accent }} />
|
||||
)}
|
||||
{sideNav ? (
|
||||
<div className="lg:grid lg:grid-cols-[13rem_minmax(0,1fr)]">
|
||||
<aside className="hidden lg:block">
|
||||
<div className="sticky pt-8 pl-6" style={{ top: "calc(var(--header-h, 5rem) + 1rem)" }}>
|
||||
<SectionNav sections={sections.map((s) => ({ id: s.id, label: s.title }))} />
|
||||
</div>
|
||||
</aside>
|
||||
<div className="min-w-0">{bands}</div>
|
||||
</div>
|
||||
))}
|
||||
) : (
|
||||
bands
|
||||
)}
|
||||
|
||||
</>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
EDITOR SECTION NAV
|
||||
|
||||
The record editor's table of contents. On a wide screen it's a
|
||||
The record editor's table of contents, and the public pages'
|
||||
"On this page" column too (PageShell's sideNav). On a wide screen it's a
|
||||
sticky column left of the form; below lg it's a slim sticky bar
|
||||
with a "Jump to" menu. Both list the same sections, which
|
||||
EntityEdit derives from the manifest (field groups, then child
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue