diff --git a/package-lock.json b/package-lock.json index 8267df2..ee12edc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "siteforge", - "version": "2.25.1", + "version": "2.25.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "siteforge", - "version": "2.25.1", + "version": "2.25.2", "dependencies": { "@aws-sdk/client-s3": "^3.1135.0", "@dnd-kit/core": "^6.3.1", diff --git a/package.json b/package.json index 0bfd5cc..1941818 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "siteforge", "private": true, - "version": "2.25.1", + "version": "2.25.2", "type": "module", "scripts": { "dev": "vite", diff --git a/src/App.css b/src/App.css index 61d4d2c..7b51d10 100644 --- a/src/App.css +++ b/src/App.css @@ -34,7 +34,10 @@ .site-search-bar { background: #13120d; border-bottom: 1px solid #28241a; - /* Scrolls away with the page; only the header stays pinned */ + position: sticky; + /* --site-header-h is set from the header's real height (see SiteHeader), so the bar sits flush below it */ + top: var(--site-header-h, 72px); + z-index: 99; } .site-search-bar-inner { max-width: 900px; diff --git a/src/App.tsx b/src/App.tsx index aa61a8f..919bec2 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -419,11 +419,23 @@ function SiteHeader({ content }: { content: SiteContent }) { const [studiesOpen, setStudiesOpen] = useState(false) const dropdownRef = useRef(null) const studiesDropdownRef = useRef(null) + const headerRef = useRef(null) const spotifyUrl = content.platformSpotifyUrl || '/spotify' const location = useLocation() const episodesActive = location.pathname.startsWith('/episodes') || location.pathname.startsWith('/finished') || location.pathname.startsWith('/nuggets') const studiesActive = location.pathname.startsWith('/study') || location.pathname === '/scripture' + // The pinned search bar sits just under the header, whatever height the header is at this screen size + useEffect(() => { + const header = headerRef.current + if (!header) return + const update = () => document.documentElement.style.setProperty('--site-header-h', `${header.getBoundingClientRect().height}px`) + update() + const observer = new ResizeObserver(update) + observer.observe(header) + return () => observer.disconnect() + }, []) + useEffect(() => { function handleOutsideClick(e: MouseEvent) { if (dropdownRef.current && !dropdownRef.current.contains(e.target as Node)) { @@ -438,7 +450,7 @@ function SiteHeader({ content }: { content: SiteContent }) { }, [episodesOpen, studiesOpen]) return ( -
+