sovereign-intelligence
Front door to Drake Stapleton's sovereign stack.
Brought by drakestapleton
sovereign-intelligence / docs / archive / drakestapleton.com-old / src / components / Layout.tsx
| 1 | import { useEffect, useRef } from "react"; |
| 2 | import { Outlet, useLocation } from "react-router-dom"; |
| 3 | import { SiteNav } from "./SiteNav"; |
| 4 | import { SiteFooter } from "./SiteFooter"; |
| 5 | |
| 6 | function RouteFocus() { |
| 7 | const location = useLocation(); |
| 8 | const firstRender = useRef(true); |
| 9 | |
| 10 | useEffect(() => { |
| 11 | if (firstRender.current) { |
| 12 | firstRender.current = false; |
| 13 | return; |
| 14 | } |
| 15 | window.scrollTo({ top: 0, left: 0, behavior: "auto" }); |
| 16 | document.querySelector<HTMLElement>("#main-content")?.focus(); |
| 17 | }, [location.pathname]); |
| 18 | |
| 19 | return null; |
| 20 | } |
| 21 | |
| 22 | export function Layout() { |
| 23 | return ( |
| 24 | <div className="site-shell"> |
| 25 | <RouteFocus /> |
| 26 | <a className="skip-link" href="#main-content"> |
| 27 | Skip to main content |
| 28 | </a> |
| 29 | <SiteNav /> |
| 30 | <div id="main-content" tabIndex={-1}> |
| 31 | <Outlet /> |
| 32 | </div> |
| 33 | <SiteFooter /> |
| 34 | </div> |
| 35 | ); |
| 36 | } |