bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

commit 2a305db74433a6b922f1028c4d2f69d974aef56f
parent 52e88af5225153c2c786a5500820829dcbbc430d
Author: Amit Dutta <mail@amit.is-a.dev>
Date:   Mon,  3 Aug 2026 23:58:33 +0530

Merge pull request #22 from notamitgamer/Patch-2

Patch 2
Diffstat:
Mdocs/.vitepress/theme/index.ts | 64++++++++++++++++++++++++++++++++++++++--------------------------
Mdocs/.vitepress/theme/style.css | 19++++++++++++-------
2 files changed, 50 insertions(+), 33 deletions(-)

diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts @@ -30,45 +30,57 @@ export default { setup() { onMounted(() => { setTimeout(() => { - // Target the search/ask AI button - const searchBtn = document.querySelector('.DocSearch-Button'); - if (!searchBtn) return; + const searchBtn = document.querySelector('.VPNavBarSearchButton'); + const askAiBtn = document.querySelector('.VPNavBarAskAiButton'); + const triggerBtns = [searchBtn, askAiBtn].filter(Boolean) as Element[]; + if (!triggerBtns.length) return; let prefetched = false; const prefetchDocSearch = () => { if (prefetched) return; prefetched = true; - import('@docsearch/js').catch(() => { + Promise.all([ + import('@docsearch/js'), + import('@docsearch/sidepanel-js') + ]).catch(() => { prefetched = false; }); }; - searchBtn.addEventListener('mouseenter', prefetchDocSearch, { once: true }); - searchBtn.addEventListener('focus', prefetchDocSearch, { once: true }); - searchBtn.addEventListener('touchstart', prefetchDocSearch, { once: true, passive: true }); - searchBtn.addEventListener('click', () => { - prefetchDocSearch(); - if (!document.querySelector('.DocSearch-Container')) { - searchBtn.classList.add('is-loading'); - } + + for (const btn of triggerBtns) { + btn.addEventListener('mouseenter', prefetchDocSearch, { once: true }); + btn.addEventListener('focus', prefetchDocSearch, { once: true }); + btn.addEventListener('touchstart', prefetchDocSearch, { once: true, passive: true }); + btn.addEventListener('click', prefetchDocSearch, { once: true }); + } + + window.addEventListener('keydown', (e) => { + const key = e.key.toLowerCase(); + const isShortcut = + ((e.ctrlKey || e.metaKey) && (key === 'k' || key === 'i')) || + key === '/'; + if (isShortcut) prefetchDocSearch(); }); - const observer = new MutationObserver((mutations) => { - for (const mutation of mutations) { - if (mutation.addedNodes.length) { - // Check if the added node is the Algolia modal container - const isModalAdded = Array.from(mutation.addedNodes).some( - (node: any) => node.classList && node.classList.contains('DocSearch-Container') - ); - - // If the modal is added, remove the loading state - if (isModalAdded) { - searchBtn.classList.remove('is-loading'); - } + for (const btn of triggerBtns) { + btn.addEventListener('click', () => { + if ( + !document.querySelector('.DocSearch-Modal') && + !document.querySelector('#docsearch-sidepanel') + ) { + btn.classList.add('is-loading'); } + }); + } + + const observer = new MutationObserver(() => { + const isOpen = + document.querySelector('.DocSearch-Modal') || + document.querySelector('#docsearch-sidepanel'); + if (isOpen) { + for (const btn of triggerBtns) btn.classList.remove('is-loading'); } }); - - // Start observing the body for injected elements observer.observe(document.body, { childList: true, subtree: true }); }, 500); }) diff --git a/docs/.vitepress/theme/style.css b/docs/.vitepress/theme/style.css @@ -403,8 +403,10 @@ min-width: 0; } -.DocSearch-Button:focus, -.DocSearch-Button:focus-visible { +.VPNavBarSearchButton:focus, +.VPNavBarSearchButton:focus-visible, +.VPNavBarAskAiButton:focus, +.VPNavBarAskAiButton:focus-visible { outline: none !important; box-shadow: none !important; } @@ -429,13 +431,17 @@ SEARCH BUTTON LOADING STATE ========================================================================== */ -/* Hide the default icon when loading */ -.DocSearch-Button.is-loading .DocSearch-Search-Icon { +/* Hide the default icon when loading (search button uses .vpi-search, + Ask AI button uses .vpi-sparkles - VitePress's own icon classes, not + DocSearch's) */ +.VPNavBarSearchButton.is-loading .vpi-search, +.VPNavBarAskAiButton.is-loading .vpi-sparkles { display: none !important; } /* Create the spinning animation */ -.DocSearch-Button.is-loading::before { +.VPNavBarSearchButton.is-loading::before, +.VPNavBarAskAiButton.is-loading::before { content: ""; display: inline-block; width: 16px; @@ -461,4 +467,4 @@ /* Fallback just in case standard container is used */ .DocSearch-Container * { font-family: var(--vp-font-family-base) !important; -}- \ No newline at end of file +}
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror