@@ -167,6 +167,7 @@ export default function TopNav({
167167 const asPath = usePathname ( ) || '/' ;
168168 const [ openMenuPath , setOpenMenuPath ] = useState < string | null > ( null ) ;
169169 const [ showSearch , setShowSearch ] = useState ( false ) ;
170+ const [ isScrolled , setIsScrolled ] = useState ( false ) ;
170171 const scrollParentRef = useRef < HTMLDivElement > ( null ) ;
171172 // Deriving from the path hides the menu as soon as a navigation commits.
172173 // Forget the path afterwards, so going Back doesn't reopen the menu.
@@ -210,6 +211,24 @@ export default function TopNav({
210211 } ;
211212 } , [ ] ) ;
212213
214+ const scrollDetectorRef = useRef ( null ) ;
215+ useEffect ( ( ) => {
216+ const observer = new IntersectionObserver (
217+ ( entries ) => {
218+ entries . forEach ( ( entry ) => {
219+ setIsScrolled ( ! entry . isIntersecting ) ;
220+ } ) ;
221+ } ,
222+ {
223+ root : null ,
224+ rootMargin : `0px 0px` ,
225+ threshold : 0 ,
226+ }
227+ ) ;
228+ observer . observe ( scrollDetectorRef . current ! ) ;
229+ return ( ) => observer . disconnect ( ) ;
230+ } , [ ] ) ;
231+
213232 const onOpenSearch = useCallback ( ( ) => {
214233 startTransition ( ( ) => {
215234 setShowSearch ( true ) ;
@@ -226,6 +245,7 @@ export default function TopNav({
226245 onOpen = { onOpenSearch }
227246 onClose = { onCloseSearch }
228247 />
248+ < div ref = { scrollDetectorRef } />
229249 < div
230250 className = { cn (
231251 isMenuOpen
@@ -234,8 +254,8 @@ export default function TopNav({
234254 ) } >
235255 < nav
236256 className = { cn (
237- 'items-center w-full flex justify-between bg-wash dark:bg-wash-dark px-1.5 lg:pe-5 lg:ps-4 z-40' ,
238- isMenuOpen && 'dark:shadow-nav-dark shadow-nav'
257+ 'duration-300 backdrop-filter backdrop-blur-lg backdrop-saturate-200 transition-shadow bg-opacity-90 items-center w-full flex justify-between bg-wash dark:bg-wash-dark dark:bg-opacity-95 px-1.5 lg:pe-5 lg:ps-4 z-40' ,
258+ { 'dark:shadow-nav-dark shadow-nav' : isScrolled || isMenuOpen }
239259 ) } >
240260 < div className = "flex items-center justify-between w-full h-16 gap-0 sm:gap-3" >
241261 < div className = "flex flex-row 3xl:flex-1 items-centers" >
0 commit comments