Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sovereign-intelligence/blob/main/docs/archive/drakestapleton.com-old/src/components/StickyChapterNav.tsx # sovereign-intelligence Front door to Drake Stapleton's sovereign stack. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `sovereign-intelligence / docs / archive / drakestapleton.com-old / src / components / StickyChapterNav.tsx` 190 lines · 6674 bytes Raw Blame History 1 import { useEffect, useRef, useState } from "react"; 2 3 export interface ChapterItem { 4 id: string; 5 number: string; 6 label: string; 7 summary: string; 8 } 9 10 export const HOMEPAGE_CHAPTERS: ChapterItem[] = [ 11 { id: "formation", number: "01", label: "Formation", summary: "Early life and resilience" }, 12 { id: "drive", number: "02", label: "Drive", summary: "Endurance and recovery" }, 13 { id: "record", number: "03", label: "Life Record", summary: "Documented milestones" }, 14 { id: "people", number: "04", label: "People", summary: "Family and inheritances" }, 15 { id: "work", number: "05", label: "Work", summary: "Career ladder and impact" }, 16 { id: "software", number: "06", label: "Software and AI", summary: "Engineering and practice" }, 17 { id: "latest", number: "07", label: "Latest Work", summary: "Atlas and AIEN architecture" }, 18 { id: "identity", number: "08", label: "Identity", summary: "Freedom Fighter ethos" }, 19 ]; 20 21 export function StickyChapterNav() { 22 const [activeId, setActiveId] = useState("formation"); 23 const [drawerOpen, setDrawerOpen] = useState(false); 24 const pillListRef = useRef(null); 25 26 useEffect(() => { 27 const observer = new IntersectionObserver( 28 (entries) => { 29 entries.forEach((entry) => { 30 if (entry.isIntersecting) { 31 setActiveId(entry.target.id); 32 } 33 }); 34 }, 35 { 36 rootMargin: "-25% 0px -60% 0px", 37 threshold: 0, 38 } 39 ); 40 41 HOMEPAGE_CHAPTERS.forEach((chapter) => { 42 const element = document.getElementById(chapter.id); 43 if (element) { 44 observer.observe(element); 45 } 46 }); 47 48 return () => observer.disconnect(); 49 }, []); 50 51 useEffect(() => { 52 const container = pillListRef.current; 53 if (container) { 54 const activePill = container.querySelector(`[data-id="${activeId}"]`) as HTMLElement | null; 55 if (activePill) { 56 const offsetLeft = activePill.offsetLeft - container.offsetLeft; 57 const targetScroll = offsetLeft - container.clientWidth / 2 + activePill.clientWidth / 2; 58 container.scrollTo({ left: targetScroll, behavior: "smooth" }); 59 } 60 } 61 }, [activeId]); 62 63 const activeIndex = HOMEPAGE_CHAPTERS.findIndex((c) => c.id === activeId); 64 const safeIndex = activeIndex >= 0 ? activeIndex : 0; 65 const currentChapter = HOMEPAGE_CHAPTERS[safeIndex]; 66 67 const hasPrev = safeIndex > 0; 68 const hasNext = safeIndex < HOMEPAGE_CHAPTERS.length - 1; 69 70 const scrollToChapter = (id: string) => { 71 const target = document.getElementById(id); 72 if (target) { 73 target.scrollIntoView({ behavior: "smooth" }); 74 setDrawerOpen(false); 75 } 76 }; 77 78 const progressPercent = Math.round(((safeIndex + 1) / HOMEPAGE_CHAPTERS.length) * 100); 79 80 return ( 81 189 ); 190 }