Skip to main content

Site navigation

Every page, home included, renders one header: web_app/src/components/SiteHeader.tsx. Change it there and it changes everywhere. Issue: #1191. Why the tabs scroll to home sections: Site look and navigation.

LinkGoes toLit on
Data Storieshome #data-storiesthe section in view on home; /stories*, /challenge*
Places/jurisdictions/jurisdictions*, /jurisdiction/*
Searchhome #searchthe section in view on home; /search
How It Workshome #how-it-worksthe section in view on home
  • Impact is in the footer's Site links (next to Chat & Contact). It scrolls to the home page's Impact section.
  • Every link carries the place in the address (?state=&city=), so the destination keeps the reader's scope (CLAUDE.md, scope label rule).
  • Which link is lit is one pure function, activeNavKey(pathname, homeSection) in web_app/src/utils/navActive.ts, tested in navActive.test.ts. The lit link has aria-current="page".

Place controlโ€‹

The place control sits in the header on desktop and at the top of the phone menu. On a page whose data follows ?state=&city=, it names that page's actual scope (#1205, CLAUDE.md scope label rule). The scope-aware pages are /stories*, /search, /jurisdictions, /browse-topics, /browse-causes, /decisions-map, /policy-questions, /data-centers and /advocacy-topics (SCOPED_ROUTE_PREFIXES).

Page stateControl
?state=&city= in the URL๐Ÿ“ Tuscaloosa, AL โ–พ, which opens the picker
No place in the URL, a town saved๐Ÿ“ National ยท Use Tuscaloosa, AL โ–พ. Use applies the saved town in one click, and โ–พ opens the picker
No place in the URL, no town saved๐Ÿ“ National ยท Find your town โ–พ

Use goes through usePlacePick. It writes ?state=&city=, and the page remounts on the new address, so the label, the URL and the page's data change together.

On home, which has its own City / State / National level picker, and on pages that don't read ?state= (settings, profile, jurisdiction pages and so on), the control names the reader's town instead: the URL place, else the saved location, else Find your town. Nothing is hard-coded. The rule is one pure function, headerPlaceState(pathname, search, saved) in web_app/src/utils/headerPlace.ts, tested in headerPlace.test.ts.

The picker is LocationPickerDialog (web_app/src/components/LocationPickerDialog.tsx), the same dialog as the home page's Find your town button. The dialog wraps the real geocoder (AddressLookup โ†’ /api/geocode/search). It closes on Escape, the โœ• or a tap outside, and gives focus back to the control that opened it.

A pick goes through usePlacePick() (web_app/src/hooks/usePlacePick.ts):

  1. It saves the place (LocationContext, so later visits keep it).
  2. On the home page it clears any carried ?state=&city=: home's scope is the saved place. On every other page it writes the pick into ?state=&city= (and drops page), so the page's scope label, query and results change together.
  3. When the address changed, its navigation carries a pick marker in history state. Layout remounts the routed page once that navigation has committed, because most pages read their scope from the address once, on mount. In-page URL changes carry no marker, so they never remount.
  4. It fires open-navigator:place-picked; the home page resets its City / State / National level to the new place's.

The dialog traps Tab and locks the page's scroll while open.

Phone menuโ€‹

Below 1024px the links fold into a menu behind the โ˜ฐ button.

  • A full-width panel under the header, over a dimmed backdrop. The page behind it does not scroll.
  • It closes on Escape, a tap on the backdrop, the โœ•, or any route change. Escape, the backdrop and the โœ• give focus back to the โ˜ฐ button; a route change leaves focus to the new page.
  • Opening moves focus into the panel, and Tab stays inside the menu. The button has aria-expanded and aria-controls="site-mobile-menu".
  • From the top: the place control, the four links (left-aligned, at least 48px tall), the story sound setting on a story, then the account block. Signed out, that is Chat & Contact and full-width Register / Login buttons, one per sign-in provider. Signed in, it is the account links.

Page titlesโ€‹

useDocumentTitle(page) (web_app/src/utils/useDocumentTitle.ts) sets document.title to "<page> | Open Navigator" and puts the default title back when the page unmounts. Home keeps the default title.

PageTitle
/CommunityOne โ€” Open Navigator | Civic data & policy tracking
/storiesData stories | Open Navigator (or Data stories ยท Tuscaloosa, AL | โ€ฆ with a place)
/stories/:id<Topic> โ€” Data story | Open Navigator, e.g. Guns โ€” Data story | Open Navigator
/search?q=fluorideSearch: fluoride | Open Navigator
/jurisdictionsPlaces | Open Navigator
/jurisdiction/:id/meetings<Jurisdiction name> โ€” Meetings | Open Navigator

The story route takes the topic's name from the story registry or the topic catalog. It does not use the story's conclusion headline, because that is computed inside the story page.