perf(explorer): client side explorer (#1810)
* start work on client side explorer * fix tests * fmt * generic test flag * add prenav hook * add highlight class * make flex more consistent, remove transition * open folders that are prefixes of current path * make mobile look nice * more style fixes
This commit is contained in:
		
							
								
								
									
										39
									
								
								quartz/components/OverflowList.tsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								quartz/components/OverflowList.tsx
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
import { JSX } from "preact"
 | 
			
		||||
 | 
			
		||||
const OverflowList = ({
 | 
			
		||||
  children,
 | 
			
		||||
  ...props
 | 
			
		||||
}: JSX.HTMLAttributes<HTMLUListElement> & { id: string }) => {
 | 
			
		||||
  return (
 | 
			
		||||
    <ul class="overflow" {...props}>
 | 
			
		||||
      {children}
 | 
			
		||||
      <li class="overflow-end" />
 | 
			
		||||
    </ul>
 | 
			
		||||
  )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
OverflowList.afterDOMLoaded = (id: string) => `
 | 
			
		||||
document.addEventListener("nav", (e) => {
 | 
			
		||||
  const observer = new IntersectionObserver((entries) => {
 | 
			
		||||
    for (const entry of entries) {
 | 
			
		||||
      const parentUl = entry.target.parentElement
 | 
			
		||||
      if (entry.isIntersecting) {
 | 
			
		||||
        parentUl.classList.remove("gradient-active")
 | 
			
		||||
      } else {
 | 
			
		||||
        parentUl.classList.add("gradient-active")
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  const ul = document.getElementById("${id}")
 | 
			
		||||
  if (!ul) return
 | 
			
		||||
 | 
			
		||||
  const end = ul.querySelector(".overflow-end")
 | 
			
		||||
  if (!end) return
 | 
			
		||||
 | 
			
		||||
  observer.observe(end)
 | 
			
		||||
  window.addCleanup(() => observer.disconnect())
 | 
			
		||||
})
 | 
			
		||||
`
 | 
			
		||||
 | 
			
		||||
export default OverflowList
 | 
			
		||||
		Reference in New Issue
	
	Block a user