interplane.Get Omega
Read in your language

sovereign-intelligence

Front door to Drake Stapleton's sovereign stack.

Brought by drakestapleton

branch main Branches Tags History

sovereign-intelligence / docs / archive / drakestapleton.com-old / src / components / Layout.tsx

36 lines · 872 bytes Raw Blame History
1import { useEffect, useRef } from "react";
2import { Outlet, useLocation } from "react-router-dom";
3import { SiteNav } from "./SiteNav";
4import { SiteFooter } from "./SiteFooter";
5
6function 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
22export 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}