import { FolderState } from "../ExplorerNode" // Current state of folders type MaybeHTMLElement = HTMLElement | undefined let currentExplorerState: FolderState[] const observer = new IntersectionObserver((entries) => { // If last element is observed, remove gradient of "overflow" class so element is visible const explorerUl = document.getElementById("explorer-ul") if (!explorerUl) return for (const entry of entries) { if (entry.isIntersecting) { explorerUl.classList.add("no-background") } else { explorerUl.classList.remove("no-background") } } }) function toggleExplorer(this: HTMLElement) { // Toggle collapsed state of entire explorer this.classList.toggle("collapsed") // Toggle collapsed aria state of entire explorer this.setAttribute( "aria-expanded", this.getAttribute("aria-expanded") === "true" ? "false" : "true", ) const content = ( this.nextElementSibling?.nextElementSibling ? this.nextElementSibling.nextElementSibling : this.nextElementSibling ) as MaybeHTMLElement if (!content) return content.classList.toggle("collapsed") content.classList.toggle("explorer-viewmode") // Prevent scroll under if (document.querySelector("#mobile-explorer")) { // Disable scrolling on the page when the explorer is opened on mobile const bodySelector = document.querySelector("#quartz-body") if (bodySelector) bodySelector.classList.toggle("lock-scroll") } } function toggleFolder(evt: MouseEvent) { evt.stopPropagation() // Element that was clicked const target = evt.target as MaybeHTMLElement if (!target) return // Check if target was svg icon or button const isSvg = target.nodeName === "svg" // corresponding