Commit 28adf8f579
Unsigned
Layout: unified · split
docs/.vitepress/theme/components/BookmarksPanel.vue +184 −40
| @@ -79,7 +79,9 @@ function flattenSidebarPaths(items: DefaultTheme.SidebarItem[]): string[] { | ||
| 79 | 79 | return paths |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | const sidebarPathOrder = flattenSidebarPaths(Array.isArray(sidebar) ? sidebar : Object.values(sidebar).flat()) | |
| 82 | const sidebarPathOrder = flattenSidebarPaths( | |
| 83 | Array.isArray(sidebar) ? sidebar : Object.values(sidebar).flat() | |
| 84 | ) | |
| 83 | 85 | |
| 84 | 86 | function sidebarIndex(path: string): number { |
| 85 | 87 | const exact = sidebarPathOrder.indexOf(path) |
| @@ -99,7 +101,10 @@ function getPageCard(path: string): HomeCard | null { | ||
| 99 | 101 | let best: HomeCard | null = null |
| 100 | 102 | let bestLen = 0 |
| 101 | 103 | for (const card of homeCards) { |
| 102 | if ((path === card.link || path.startsWith(card.link + '/')) && card.link.length > bestLen) { | |
| 104 | if ( | |
| 105 | (path === card.link || path.startsWith(card.link + '/')) && | |
| 106 | card.link.length > bestLen | |
| 107 | ) { | |
| 103 | 108 | best = card |
| 104 | 109 | bestLen = card.link.length |
| 105 | 110 | } |
| @@ -108,8 +113,18 @@ function getPageCard(path: string): HomeCard | null { | ||
| 108 | 113 | } |
| 109 | 114 | |
| 110 | 115 | type PageGroup = { path: string; card: HomeCard | null; items: BookmarkItem[] } |
| 111 | type TopLevelEntry = { type: 'page'; path: string; card: HomeCard | null; items: BookmarkItem[] } | |
| 112 | type FolderEntry = { type: 'folder'; section: string; parentCard: HomeCard | null; pages: PageGroup[] } | |
| 116 | type TopLevelEntry = { | |
| 117 | type: 'page' | |
| 118 | path: string | |
| 119 | card: HomeCard | null | |
| 120 | items: BookmarkItem[] | |
| 121 | } | |
| 122 | type FolderEntry = { | |
| 123 | type: 'folder' | |
| 124 | section: string | |
| 125 | parentCard: HomeCard | null | |
| 126 | pages: PageGroup[] | |
| 127 | } | |
| 113 | 128 | type GroupEntry = TopLevelEntry | FolderEntry |
| 114 | 129 | |
| 115 | 130 | const grouped = computed((): GroupEntry[] => { |
| @@ -140,13 +155,27 @@ const grouped = computed((): GroupEntry[] => { | ||
| 140 | 155 | // Build folder entries, sorted by parent card's sidebar position |
| 141 | 156 | const folderEntries: FolderEntry[] = [...folderMap.entries()] |
| 142 | 157 | .map(([section, paths]) => { |
| 143 | const parentCard = homeCards.find(c => c.title === section && !c.section) ?? null | |
| 158 | const parentCard = homeCards.find(c => | |
| 159 | c.title === section && !c.section | |
| 160 | ) ?? null | |
| 144 | 161 | const sortedPages = [...paths] |
| 145 | 162 | .sort((a, b) => sidebarIndex(a) - sidebarIndex(b)) |
| 146 | .map(path => ({ path, card: getPageCard(path), items: byPath.get(path)! })) | |
| 147 | return { type: 'folder' as const, section, parentCard, pages: sortedPages } | |
| 163 | .map(path => ({ | |
| 164 | path, | |
| 165 | card: getPageCard(path), | |
| 166 | items: byPath.get(path)! | |
| 167 | })) | |
| 168 | return { | |
| 169 | type: 'folder' as const, | |
| 170 | section, | |
| 171 | parentCard, | |
| 172 | pages: sortedPages | |
| 173 | } | |
| 148 | 174 | }) |
| 149 | .sort((a, b) => sidebarIndex(a.parentCard?.link ?? '') - sidebarIndex(b.parentCard?.link ?? '')) | |
| 175 | .sort((a, b) => | |
| 176 | sidebarIndex(a.parentCard?.link ?? '') - | |
| 177 | sidebarIndex(b.parentCard?.link ?? '') | |
| 178 | ) | |
| 150 | 179 | |
| 151 | 180 | // Merge top-level and folder entries in sidebar order |
| 152 | 181 | const topEntries: TopLevelEntry[] = topPages.map(path => ({ |
| @@ -157,8 +186,12 @@ const grouped = computed((): GroupEntry[] => { | ||
| 157 | 186 | })) |
| 158 | 187 | |
| 159 | 188 | return [...topEntries, ...folderEntries].sort((a, b) => { |
| 160 | const ai = a.type === 'page' ? sidebarIndex(a.path) : sidebarIndex(a.parentCard?.link ?? '') | |
| 161 | const bi = b.type === 'page' ? sidebarIndex(b.path) : sidebarIndex(b.parentCard?.link ?? '') | |
| 189 | const ai = a.type === 'page' | |
| 190 | ? sidebarIndex(a.path) | |
| 191 | : sidebarIndex(a.parentCard?.link ?? '') | |
| 192 | const bi = b.type === 'page' | |
| 193 | ? sidebarIndex(b.path) | |
| 194 | : sidebarIndex(b.parentCard?.link ?? '') | |
| 162 | 195 | return ai - bi |
| 163 | 196 | }) |
| 164 | 197 | }) |
| @@ -178,9 +211,21 @@ const grouped = computed((): GroupEntry[] => { | ||
| 178 | 211 | </button> |
| 179 | 212 | |
| 180 | 213 | <Transition name="bookmarks-panel"> |
| 181 | <div v-if="isOpen" ref="panelRef" class="bookmarks-panel" :style="panelStyle" role="dialog" aria-label="Bookmarks"> | |
| 214 | <div | |
| 215 | v-if="isOpen" | |
| 216 | ref="panelRef" | |
| 217 | class="bookmarks-panel" | |
| 218 | :style="panelStyle" | |
| 219 | role="dialog" | |
| 220 | aria-label="Bookmarks" | |
| 221 | > | |
| 182 | 222 | <div class="bookmarks-mobile-header"> |
| 183 | <button type="button" class="bookmarks-mobile-back" aria-label="Back" @click="isOpen = false"> | |
| 223 | <button | |
| 224 | type="button" | |
| 225 | class="bookmarks-mobile-back" | |
| 226 | aria-label="Back" | |
| 227 | @click="isOpen = false" | |
| 228 | > | |
| 184 | 229 | <ArrowLeft :size="18" :stroke-width="2" /> |
| 185 | 230 | </button> |
| 186 | 231 | <span class="bookmarks-mobile-title">Bookmarks</span> |
| @@ -192,27 +237,81 @@ const grouped = computed((): GroupEntry[] => { | ||
| 192 | 237 | > |
| 193 | 238 | <div v-if="bookmarks.length === 0" class="bookmarks-empty"> |
| 194 | 239 | <span class="bookmarks-empty-kaomoji">(˶ᵔ ᵕ ᵔ˶)</span> |
| 195 | <p class="bookmarks-empty-hint bookmarks-empty-hint--desktop">Tip: Hover over any primary heading under <strong>On this page</strong> and click <Bookmark :size="13" :stroke-width="2" class="bookmarks-empty-inline-icon" /> to bookmark it.</p> | |
| 196 | <p class="bookmarks-empty-hint bookmarks-empty-hint--mobile">Tip: Tap <strong>On this page</strong> and press <Bookmark :size="13" :stroke-width="2" class="bookmarks-empty-inline-icon" /> next to any primary heading to bookmark it.</p> | |
| 240 | <p class="bookmarks-empty-hint bookmarks-empty-hint--desktop"> | |
| 241 | Tip: Hover over any primary heading under <strong>On this | |
| 242 | page</strong> and click <Bookmark | |
| 243 | :size="13" | |
| 244 | :stroke-width="2" | |
| 245 | class="bookmarks-empty-inline-icon" | |
| 246 | /> to bookmark it. | |
| 247 | </p> | |
| 248 | <p class="bookmarks-empty-hint bookmarks-empty-hint--mobile"> | |
| 249 | Tip: Tap <strong>On this page</strong> and press <Bookmark | |
| 250 | :size="13" | |
| 251 | :stroke-width="2" | |
| 252 | class="bookmarks-empty-inline-icon" | |
| 253 | /> next to any primary heading to bookmark it. | |
| 254 | </p> | |
| 197 | 255 | </div> |
| 198 | 256 | <div v-else class="bookmarks-groups"> |
| 199 | <template v-for="group in grouped" :key="group.type === 'page' ? group.path : group.section"> | |
| 200 | ||
| 257 | <template | |
| 258 | v-for="group in grouped" | |
| 259 | :key="group.type === 'page' ? group.path : group.section" | |
| 260 | > | |
| 201 | 261 | <!-- Top-level page (no folder) --> |
| 202 | 262 | <div v-if="group.type === 'page'" class="bookmarks-group"> |
| 203 | 263 | <h3 class="bookmarks-group-title"> |
| 204 | <span v-if="group.card" :class="cardIconToClass(group.card.icon)" class="bookmarks-group-icon" /> | |
| 205 | <span v-else class="i-lucide:file-text bookmarks-group-icon" /> | |
| 206 | <span class="bookmarks-group-text">{{ group.card?.title ?? group.path }}</span> | |
| 264 | <span | |
| 265 | v-if="group.card" | |
| 266 | :class="cardIconToClass(group.card.icon)" | |
| 267 | class="bookmarks-group-icon" | |
| 268 | /> | |
| 269 | <span | |
| 270 | v-else | |
| 271 | class="i-lucide:file-text bookmarks-group-icon" | |
| 272 | /> | |
| 273 | <span class="bookmarks-group-text">{{ | |
| 274 | group.card?.title ?? group.path | |
| 275 | }}</span> | |
| 207 | 276 | </h3> |
| 208 | 277 | <ul class="bookmarks-list"> |
| 209 | <li v-for="bm in group.items" :key="bm.anchor" class="bookmarks-item"> | |
| 210 | <a class="bookmarks-item-link" :href="bm.path + '#' + bm.anchor" @click="isOpen = false"> | |
| 211 | <Hash :size="12" :stroke-width="2" class="bookmarks-item-icon" /> | |
| 278 | <li | |
| 279 | v-for="bm in group.items" | |
| 280 | :key="bm.anchor" | |
| 281 | class="bookmarks-item" | |
| 282 | > | |
| 283 | <a | |
| 284 | class="bookmarks-item-link" | |
| 285 | :href="bm.path + '#' + bm.anchor" | |
| 286 | @click="isOpen = false" | |
| 287 | > | |
| 288 | <Hash | |
| 289 | :size="12" | |
| 290 | :stroke-width="2" | |
| 291 | class="bookmarks-item-icon" | |
| 292 | /> | |
| 212 | 293 | {{ bm.title }} |
| 213 | 294 | </a> |
| 214 | <button type="button" class="bookmarks-item-remove" :aria-label="`Remove bookmark for ${bm.title}`" @click.stop="remove(bm.anchor, bm.path)"> | |
| 215 | <svg xmlns="http://www.w3.org/2000/svg" width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg> | |
| 295 | <button | |
| 296 | type="button" | |
| 297 | class="bookmarks-item-remove" | |
| 298 | :aria-label="`Remove bookmark for ${bm.title}`" | |
| 299 | @click.stop="remove(bm.anchor, bm.path)" | |
| 300 | > | |
| 301 | <svg | |
| 302 | xmlns="http://www.w3.org/2000/svg" | |
| 303 | width="11" | |
| 304 | height="11" | |
| 305 | viewBox="0 0 24 24" | |
| 306 | fill="none" | |
| 307 | stroke="currentColor" | |
| 308 | stroke-width="2.5" | |
| 309 | stroke-linecap="round" | |
| 310 | stroke-linejoin="round" | |
| 311 | > | |
| 312 | <path d="M18 6 6 18" /> | |
| 313 | <path d="m6 6 12 12" /> | |
| 314 | </svg> | |
| 216 | 315 | </button> |
| 217 | 316 | </li> |
| 218 | 317 | </ul> |
| @@ -221,31 +320,73 @@ const grouped = computed((): GroupEntry[] => { | ||
| 221 | 320 | <!-- Folder group (e.g. Guides, Glossary) --> |
| 222 | 321 | <div v-else class="bookmarks-group"> |
| 223 | 322 | <h3 class="bookmarks-group-title"> |
| 224 | <span v-if="group.parentCard" :class="cardIconToClass(group.parentCard.icon)" class="bookmarks-group-icon" /> | |
| 323 | <span | |
| 324 | v-if="group.parentCard" | |
| 325 | :class="cardIconToClass(group.parentCard.icon)" | |
| 326 | class="bookmarks-group-icon" | |
| 327 | /> | |
| 225 | 328 | <span v-else class="i-lucide:folder bookmarks-group-icon" /> |
| 226 | 329 | <span class="bookmarks-group-text">{{ group.section }}</span> |
| 227 | 330 | </h3> |
| 228 | <div v-for="page in group.pages" :key="page.path" class="bookmarks-sub-group"> | |
| 229 | <h4 class="bookmarks-sub-title">{{ page.card?.title ?? page.path }}</h4> | |
| 331 | <div | |
| 332 | v-for="page in group.pages" | |
| 333 | :key="page.path" | |
| 334 | class="bookmarks-sub-group" | |
| 335 | > | |
| 336 | <h4 class="bookmarks-sub-title"> | |
| 337 | {{ page.card?.title ?? page.path }} | |
| 338 | </h4> | |
| 230 | 339 | <ul class="bookmarks-list"> |
| 231 | <li v-for="bm in page.items" :key="bm.anchor" class="bookmarks-item"> | |
| 232 | <a class="bookmarks-item-link" :href="bm.path + '#' + bm.anchor" @click="isOpen = false"> | |
| 233 | <Hash :size="12" :stroke-width="2" class="bookmarks-item-icon" /> | |
| 340 | <li | |
| 341 | v-for="bm in page.items" | |
| 342 | :key="bm.anchor" | |
| 343 | class="bookmarks-item" | |
| 344 | > | |
| 345 | <a | |
| 346 | class="bookmarks-item-link" | |
| 347 | :href="bm.path + '#' + bm.anchor" | |
| 348 | @click="isOpen = false" | |
| 349 | > | |
| 350 | <Hash | |
| 351 | :size="12" | |
| 352 | :stroke-width="2" | |
| 353 | class="bookmarks-item-icon" | |
| 354 | /> | |
| 234 | 355 | {{ bm.title }} |
| 235 | 356 | </a> |
| 236 | <button type="button" class="bookmarks-item-remove" :aria-label="`Remove bookmark for ${bm.title}`" @click.stop="remove(bm.anchor, bm.path)"> | |
| 237 | <svg xmlns="http://www.w3.org/2000/svg" width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg> | |
| 357 | <button | |
| 358 | type="button" | |
| 359 | class="bookmarks-item-remove" | |
| 360 | :aria-label="`Remove bookmark for ${bm.title}`" | |
| 361 | @click.stop="remove(bm.anchor, bm.path)" | |
| 362 | > | |
| 363 | <svg | |
| 364 | xmlns="http://www.w3.org/2000/svg" | |
| 365 | width="11" | |
| 366 | height="11" | |
| 367 | viewBox="0 0 24 24" | |
| 368 | fill="none" | |
| 369 | stroke="currentColor" | |
| 370 | stroke-width="2.5" | |
| 371 | stroke-linecap="round" | |
| 372 | stroke-linejoin="round" | |
| 373 | > | |
| 374 | <path d="M18 6 6 18" /> | |
| 375 | <path d="m6 6 12 12" /> | |
| 376 | </svg> | |
| 238 | 377 | </button> |
| 239 | 378 | </li> |
| 240 | 379 | </ul> |
| 241 | 380 | </div> |
| 242 | 381 | </div> |
| 243 | ||
| 244 | 382 | </template> |
| 245 | 383 | </div> |
| 246 | 384 | </div> |
| 247 | 385 | <Transition name="bookmarks-fade"> |
| 248 | <div v-if="showFade && bookmarks.length > 0" class="bookmarks-fade-overlay" /> | |
| 386 | <div | |
| 387 | v-if="showFade && bookmarks.length > 0" | |
| 388 | class="bookmarks-fade-overlay" | |
| 389 | /> | |
| 249 | 390 | </Transition> |
| 250 | 391 | </div> |
| 251 | 392 | </Transition> |
| @@ -270,13 +411,15 @@ const grouped = computed((): GroupEntry[] => { | ||
| 270 | 411 | height: 100%; |
| 271 | 412 | color: var(--vp-c-text-1); |
| 272 | 413 | opacity: 0.55; |
| 273 | transition: | |
| 274 | opacity 0.25s, | |
| 275 | transform 0.2s cubic-bezier(0.16, 1, 0.3, 1); | |
| 414 | transition: opacity 0.25s, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1); | |
| 276 | 415 | } |
| 277 | 416 | |
| 278 | .bookmarks-btn:hover { opacity: 1; } | |
| 279 | .bookmarks-btn:active { transform: scale(0.94); } | |
| 417 | .bookmarks-btn:hover { | |
| 418 | opacity: 1; | |
| 419 | } | |
| 420 | .bookmarks-btn:active { | |
| 421 | transform: scale(0.94); | |
| 422 | } | |
| 280 | 423 | |
| 281 | 424 | .bookmarks-panel { |
| 282 | 425 | position: absolute; |
| @@ -481,7 +624,8 @@ const grouped = computed((): GroupEntry[] => { | ||
| 481 | 624 | .bookmarks-panel-enter-from, |
| 482 | 625 | .bookmarks-panel-leave-to { |
| 483 | 626 | opacity: 0; |
| 484 | transform: translateX(var(--bookmarks-panel-shift, -50%)) scale(0.95) translateY(-4px); | |
| 627 | transform: translateX(var(--bookmarks-panel-shift, -50%)) scale(0.95) | |
| 628 | translateY(-4px); | |
| 485 | 629 | } |
| 486 | 630 | |
| 487 | 631 | .bookmarks-fade-enter-active, |
docs/.vitepress/theme/components/search/SearchRibbon.vue +207 −50
| @@ -1,7 +1,18 @@ | ||
| 1 | 1 | <script setup lang="ts"> |
| 2 | import { | |
| 3 | onClickOutside, | |
| 4 | useElementBounding, | |
| 5 | useEventListener | |
| 6 | } from '@vueuse/core' | |
| 2 | 7 | import { ChevronLeft, ChevronRight, Menu } from 'lucide-vue-next' |
| 3 | import { computed, nextTick, onBeforeUnmount, ref, shallowRef, watch } from 'vue' | |
| 4 | import { onClickOutside, useEventListener } from '@vueuse/core' | |
| 8 | import { | |
| 9 | computed, | |
| 10 | nextTick, | |
| 11 | onBeforeUnmount, | |
| 12 | ref, | |
| 13 | shallowRef, | |
| 14 | watch | |
| 15 | } from 'vue' | |
| 5 | 16 | import { homeCards } from '../../../configs/constants' |
| 6 | 17 | import type { HomeCard } from '../../../configs/constants' |
| 7 | 18 | |
| @@ -34,7 +45,10 @@ function getPageCard(path: string): HomeCard | null { | ||
| 34 | 45 | let best: HomeCard | null = null |
| 35 | 46 | let bestLen = 0 |
| 36 | 47 | for (const card of homeCards) { |
| 37 | if ((path === card.link || path.startsWith(card.link + '/')) && card.link.length > bestLen) { | |
| 48 | if ( | |
| 49 | (path === card.link || path.startsWith(card.link + '/')) && | |
| 50 | card.link.length > bestLen | |
| 51 | ) { | |
| 38 | 52 | best = card |
| 39 | 53 | bestLen = card.link.length |
| 40 | 54 | } |
| @@ -74,6 +88,26 @@ const emit = defineEmits<{ | ||
| 74 | 88 | const showListMenu = ref(false) |
| 75 | 89 | const listMenuButtonRef = ref<HTMLElement>() |
| 76 | 90 | const listMenuRef = ref<HTMLElement>() |
| 91 | const showListMenuFade = ref(true) | |
| 92 | const listMenuBounding = useElementBounding(listMenuRef) | |
| 93 | const ribbonBounding = useElementBounding(() => | |
| 94 | listMenuRef.value?.closest('.page-ribbon-list') | |
| 95 | ) | |
| 96 | ||
| 97 | const listMenuFadeStyle = computed(() => ({ | |
| 98 | top: `${listMenuBounding.bottom.value - ribbonBounding.top.value - 56}px`, | |
| 99 | left: `${listMenuBounding.left.value - ribbonBounding.left.value}px`, | |
| 100 | width: `${listMenuBounding.width.value}px` | |
| 101 | })) | |
| 102 | ||
| 103 | const listMenuFadeReady = computed(() => listMenuBounding.width.value > 0) | |
| 104 | ||
| 105 | function onListMenuScroll() { | |
| 106 | const el = listMenuRef.value | |
| 107 | if (!el) return | |
| 108 | const { scrollTop, scrollHeight, clientHeight } = el | |
| 109 | showListMenuFade.value = scrollTop + clientHeight < scrollHeight - 4 | |
| 110 | } | |
| 77 | 111 | |
| 78 | 112 | // Tabs ribbon state |
| 79 | 113 | const ribbonTrack = shallowRef<HTMLElement>() |
| @@ -100,7 +134,7 @@ function onDragStart(e: MouseEvent) { | ||
| 100 | 134 | // Don't drag if user clicked on a scroll arrow |
| 101 | 135 | const target = e.target as HTMLElement |
| 102 | 136 | if (target.closest('.page-ribbon-arrow')) return |
| 103 | ||
| 137 | ||
| 104 | 138 | isDragging.value = true |
| 105 | 139 | dragStartX = e.clientX |
| 106 | 140 | dragStartScrollLeft = track.scrollLeft |
| @@ -115,13 +149,13 @@ function onDragMove(e: MouseEvent) { | ||
| 115 | 149 | if (!isDragging.value) return |
| 116 | 150 | const track = getRibbonTrack() |
| 117 | 151 | if (!track) return |
| 118 | ||
| 152 | ||
| 119 | 153 | const deltaX = e.clientX - dragStartX |
| 120 | 154 | const threshold = 4 |
| 121 | 155 | if (!dragMoved && Math.abs(deltaX) > threshold) { |
| 122 | 156 | dragMoved = true |
| 123 | 157 | } |
| 124 | ||
| 158 | ||
| 125 | 159 | if (dragMoved) { |
| 126 | 160 | track.scrollLeft = dragStartScrollLeft - deltaX |
| 127 | 161 | updateRibbonOverflow() |
| @@ -152,7 +186,10 @@ function onTrackWheel(e: WheelEvent) { | ||
| 152 | 186 | if (!track) return |
| 153 | 187 | const max = track.scrollWidth - track.clientWidth |
| 154 | 188 | if (max <= 0) return |
| 155 | const newScroll = Math.max(0, Math.min(max, track.scrollLeft + e.deltaX + e.deltaY)) | |
| 189 | const newScroll = Math.max( | |
| 190 | 0, | |
| 191 | Math.min(max, track.scrollLeft + e.deltaX + e.deltaY) | |
| 192 | ) | |
| 156 | 193 | if (newScroll !== track.scrollLeft) { |
| 157 | 194 | e.preventDefault() |
| 158 | 195 | track.scrollLeft = newScroll |
| @@ -189,9 +226,14 @@ function onTouchEnd() { | ||
| 189 | 226 | |
| 190 | 227 | function updateRibbonOverflow() { |
| 191 | 228 | const track = getRibbonTrack() |
| 192 | if (!track) { ribbonCanScrollLeft.value = false; ribbonCanScrollRight.value = false; return } | |
| 229 | if (!track) { | |
| 230 | ribbonCanScrollLeft.value = false | |
| 231 | ribbonCanScrollRight.value = false | |
| 232 | return | |
| 233 | } | |
| 193 | 234 | ribbonCanScrollLeft.value = track.scrollLeft > 2 |
| 194 | ribbonCanScrollRight.value = track.scrollWidth - track.clientWidth - track.scrollLeft > 2 | |
| 235 | ribbonCanScrollRight.value = | |
| 236 | track.scrollWidth - track.clientWidth - track.scrollLeft > 2 | |
| 195 | 237 | } |
| 196 | 238 | |
| 197 | 239 | function getRibbonTrack(): HTMLElement | null { |
| @@ -204,7 +246,9 @@ function scrollActivePagePillIntoView(direction = 0) { | ||
| 204 | 246 | const track = getRibbonTrack() |
| 205 | 247 | if (!track) return |
| 206 | 248 | const pills = [...track.querySelectorAll<HTMLElement>('.page-pill')] |
| 207 | const activeIndex = pills.findIndex((pill) => pill.classList.contains('active')) | |
| 249 | const activeIndex = pills.findIndex((pill) => | |
| 250 | pill.classList.contains('active') | |
| 251 | ) | |
| 208 | 252 | const active = pills[activeIndex] |
| 209 | 253 | if (!active) return |
| 210 | 254 | const trackRect = track.getBoundingClientRect() |
| @@ -243,7 +287,11 @@ function scrollRibbon(direction: number) { | ||
| 243 | 287 | const to = Math.max(0, Math.min(max, from + amount)) |
| 244 | 288 | if (to === from) return |
| 245 | 289 | if (ribbonAnimHandle) cancelAnimationFrame(ribbonAnimHandle) |
| 246 | if (!props.searchAnimationsEnabled) { track.scrollLeft = to; updateRibbonOverflow(); return } | |
| 290 | if (!props.searchAnimationsEnabled) { | |
| 291 | track.scrollLeft = to | |
| 292 | updateRibbonOverflow() | |
| 293 | return | |
| 294 | } | |
| 247 | 295 | |
| 248 | 296 | const duration = 280 |
| 249 | 297 | const start = performance.now() |
| @@ -258,8 +306,23 @@ function scrollRibbon(direction: number) { | ||
| 258 | 306 | ribbonAnimHandle = requestAnimationFrame(step) |
| 259 | 307 | } |
| 260 | 308 | |
| 261 | watch(() => props.pageGroups, () => { nextTick(updateRibbonOverflow) }) | |
| 262 | watch(() => props.urlPageGroups, () => { nextTick(updateRibbonOverflow) }) | |
| 309 | watch(() => props.pageGroups, () => { | |
| 310 | nextTick(() => { | |
| 311 | updateRibbonOverflow() | |
| 312 | onListMenuScroll() | |
| 313 | }) | |
| 314 | }) | |
| 315 | watch(() => props.urlPageGroups, () => { | |
| 316 | nextTick(() => { | |
| 317 | updateRibbonOverflow() | |
| 318 | onListMenuScroll() | |
| 319 | }) | |
| 320 | }) | |
| 321 | watch(showListMenu, async (open) => { | |
| 322 | if (!open) return | |
| 323 | await nextTick() | |
| 324 | onListMenuScroll() | |
| 325 | }) | |
| 263 | 326 | useEventListener('resize', updateRibbonOverflow) |
| 264 | 327 | |
| 265 | 328 | onBeforeUnmount(() => { |
| @@ -304,11 +367,15 @@ const groupedMenuEntries = computed((): MenuEntry[] => { | ||
| 304 | 367 | // Build folder entries |
| 305 | 368 | const folderEntries: FolderGroup[] = [...folderMap.entries()] |
| 306 | 369 | .map(([section, pages]) => { |
| 307 | const parentCard = homeCards.find((c) => c.title === section && !c.section) ?? null | |
| 370 | const parentCard = homeCards.find((c) => | |
| 371 | c.title === section && !c.section | |
| 372 | ) ?? null | |
| 308 | 373 | return { |
| 309 | 374 | section, |
| 310 | 375 | parentCard, |
| 311 | iconClass: parentCard ? cardIconToClass(parentCard.icon) : 'i-lucide:folder', | |
| 376 | iconClass: parentCard | |
| 377 | ? cardIconToClass(parentCard.icon) | |
| 378 | : 'i-lucide:folder', | |
| 312 | 379 | pages |
| 313 | 380 | } |
| 314 | 381 | }) |
| @@ -338,12 +405,20 @@ const activePageData = computed(() => { | ||
| 338 | 405 | const findInEntries = (key: string, fallbackCount: number) => { |
| 339 | 406 | for (const entry of groupedMenuEntries.value) { |
| 340 | 407 | if (entry.type === 'page' && entry.page.key === key) { |
| 341 | return { label: entry.page.label, iconClass: entry.page.iconClass, count: entry.page.count } | |
| 408 | return { | |
| 409 | label: entry.page.label, | |
| 410 | iconClass: entry.page.iconClass, | |
| 411 | count: entry.page.count | |
| 412 | } | |
| 342 | 413 | } |
| 343 | 414 | if (entry.type === 'folder') { |
| 344 | 415 | const found = entry.folder.pages.find((p) => p.key === key) |
| 345 | 416 | if (found) { |
| 346 | return { label: found.label, iconClass: entry.folder.iconClass, count: found.count } | |
| 417 | return { | |
| 418 | label: found.label, | |
| 419 | iconClass: entry.folder.iconClass, | |
| 420 | count: found.count | |
| 421 | } | |
| 347 | 422 | } |
| 348 | 423 | } |
| 349 | 424 | } |
| @@ -352,17 +427,38 @@ const activePageData = computed(() => { | ||
| 352 | 427 | |
| 353 | 428 | if (props.urlSearchMode) { |
| 354 | 429 | if (props.urlActivePageFilter === null) { |
| 355 | return { label: 'All', iconClass: 'i-lucide:text-search', count: props.urlMatchesLength } | |
| 430 | return { | |
| 431 | label: 'All', | |
| 432 | iconClass: 'i-lucide:text-search', | |
| 433 | count: props.urlMatchesLength | |
| 434 | } | |
| 356 | 435 | } |
| 357 | const result = findInEntries(props.urlActivePageFilter, props.urlMatchesLength) | |
| 358 | return result ?? { label: 'All', iconClass: 'i-lucide:text-search', count: props.urlMatchesLength } | |
| 436 | const result = findInEntries( | |
| 437 | props.urlActivePageFilter, | |
| 438 | props.urlMatchesLength | |
| 439 | ) | |
| 440 | return result ?? | |
| 441 | { | |
| 442 | label: 'All', | |
| 443 | iconClass: 'i-lucide:text-search', | |
| 444 | count: props.urlMatchesLength | |
| 445 | } | |
| 359 | 446 | } |
| 360 | 447 | |
| 361 | 448 | if (props.activePageFilter === null) { |
| 362 | return { label: 'All', iconClass: 'i-lucide:text-search', count: props.resultsLength } | |
| 449 | return { | |
| 450 | label: 'All', | |
| 451 | iconClass: 'i-lucide:text-search', | |
| 452 | count: props.resultsLength | |
| 453 | } | |
| 363 | 454 | } |
| 364 | 455 | const result = findInEntries(props.activePageFilter, props.resultsLength) |
| 365 | return result ?? { label: 'All', iconClass: 'i-lucide:text-search', count: props.resultsLength } | |
| 456 | return result ?? | |
| 457 | { | |
| 458 | label: 'All', | |
| 459 | iconClass: 'i-lucide:text-search', | |
| 460 | count: props.resultsLength | |
| 461 | } | |
| 366 | 462 | }) |
| 367 | 463 | |
| 368 | 464 | function toggleListMenu() { |
| @@ -384,7 +480,9 @@ const allPages = computed((): (string | null)[] => { | ||
| 384 | 480 | }) |
| 385 | 481 | |
| 386 | 482 | const currentPageIndex = computed(() => { |
| 387 | const activeKey = props.urlSearchMode ? props.urlActivePageFilter : props.activePageFilter | |
| 483 | const activeKey = props.urlSearchMode | |
| 484 | ? props.urlActivePageFilter | |
| 485 | : props.activePageFilter | |
| 388 | 486 | return allPages.value.indexOf(activeKey) |
| 389 | 487 | }) |
| 390 | 488 | |
| @@ -451,40 +549,55 @@ function pageNav(delta: number) { | ||
| 451 | 549 | v-if="showListMenu" |
| 452 | 550 | ref="listMenuRef" |
| 453 | 551 | class="page-ribbon-list-menu" |
| 552 | @scroll.passive="onListMenuScroll" | |
| 454 | 553 | > |
| 455 | 554 | <!-- "All" item --> |
| 456 | 555 | <button |
| 457 | 556 | type="button" |
| 458 | 557 | class="ribbon-menu-item all-item" |
| 459 | :class="{ active: urlSearchMode | |
| 460 | ? urlActivePageFilter === null | |
| 461 | : activePageFilter === null }" | |
| 558 | :class="{ | |
| 559 | active: urlSearchMode | |
| 560 | ? urlActivePageFilter === null | |
| 561 | : activePageFilter === null | |
| 562 | }" | |
| 462 | 563 | @click="urlSearchMode |
| 463 | ? setUrlPageFilter(null) | |
| 464 | : setPageFilter(null)" | |
| 564 | ? setUrlPageFilter(null) | |
| 565 | : setPageFilter(null)" | |
| 465 | 566 | > |
| 466 | 567 | <span class="i-lucide:text-search ribbon-menu-item-icon" /> |
| 467 | 568 | <span class="ribbon-menu-item-label">All</span> |
| 468 | <span class="ribbon-menu-item-count">{{ urlSearchMode ? urlMatchesLength : resultsLength }}</span> | |
| 569 | <span class="ribbon-menu-item-count">{{ | |
| 570 | urlSearchMode ? urlMatchesLength : resultsLength | |
| 571 | }}</span> | |
| 469 | 572 | </button> |
| 470 | 573 | |
| 471 | 574 | <div class="ribbon-menu-divider" /> |
| 472 | 575 | |
| 473 | 576 | <!-- Grouped pages --> |
| 474 | <template v-for="entry in groupedMenuEntries" :key="entry.type === 'page' ? entry.page.key : entry.folder.section"> | |
| 577 | <template | |
| 578 | v-for="entry in groupedMenuEntries" | |
| 579 | :key="entry.type === 'page' | |
| 580 | ? entry.page.key | |
| 581 | : entry.folder.section" | |
| 582 | > | |
| 475 | 583 | <!-- Top-level page --> |
| 476 | 584 | <div v-if="entry.type === 'page'" class="ribbon-menu-group"> |
| 477 | 585 | <button |
| 478 | 586 | type="button" |
| 479 | 587 | class="ribbon-menu-item" |
| 480 | :class="{ active: urlSearchMode | |
| 481 | ? urlActivePageFilter === entry.page.key | |
| 482 | : activePageFilter === entry.page.key }" | |
| 588 | :class="{ | |
| 589 | active: urlSearchMode | |
| 590 | ? urlActivePageFilter === entry.page.key | |
| 591 | : activePageFilter === entry.page.key | |
| 592 | }" | |
| 483 | 593 | @click="urlSearchMode |
| 484 | ? setUrlPageFilter(entry.page.key) | |
| 485 | : setPageFilter(entry.page.key)" | |
| 594 | ? setUrlPageFilter(entry.page.key) | |
| 595 | : setPageFilter(entry.page.key)" | |
| 486 | 596 | > |
| 487 | <span :class="entry.page.iconClass" class="ribbon-menu-item-icon" /> | |
| 597 | <span | |
| 598 | :class="entry.page.iconClass" | |
| 599 | class="ribbon-menu-item-icon" | |
| 600 | /> | |
| 488 | 601 | <span class="ribbon-menu-item-label">{{ entry.page.label }}</span> |
| 489 | 602 | <span class="ribbon-menu-item-count">{{ entry.page.count }}</span> |
| 490 | 603 | </button> |
| @@ -493,8 +606,13 @@ function pageNav(delta: number) { | ||
| 493 | 606 | <!-- Folder group --> |
| 494 | 607 | <div v-else class="ribbon-menu-group"> |
| 495 | 608 | <h4 class="ribbon-menu-group-title"> |
| 496 | <span :class="entry.folder.iconClass" class="ribbon-menu-group-icon" /> | |
| 497 | <span class="ribbon-menu-group-text">{{ entry.folder.section }}</span> | |
| 609 | <span | |
| 610 | :class="entry.folder.iconClass" | |
| 611 | class="ribbon-menu-group-icon" | |
| 612 | /> | |
| 613 | <span class="ribbon-menu-group-text">{{ | |
| 614 | entry.folder.section | |
| 615 | }}</span> | |
| 498 | 616 | </h4> |
| 499 | 617 | <div class="ribbon-menu-sub-items"> |
| 500 | 618 | <button |
| @@ -502,12 +620,14 @@ function pageNav(delta: number) { | ||
| 502 | 620 | :key="page.key" |
| 503 | 621 | type="button" |
| 504 | 622 | class="ribbon-menu-item" |
| 505 | :class="{ active: urlSearchMode | |
| 506 | ? urlActivePageFilter === page.key | |
| 507 | : activePageFilter === page.key }" | |
| 623 | :class="{ | |
| 624 | active: urlSearchMode | |
| 625 | ? urlActivePageFilter === page.key | |
| 626 | : activePageFilter === page.key | |
| 627 | }" | |
| 508 | 628 | @click="urlSearchMode |
| 509 | ? setUrlPageFilter(page.key) | |
| 510 | : setPageFilter(page.key)" | |
| 629 | ? setUrlPageFilter(page.key) | |
| 630 | : setPageFilter(page.key)" | |
| 511 | 631 | > |
| 512 | 632 | <span class="ribbon-menu-item-label">{{ page.label }}</span> |
| 513 | 633 | <span class="ribbon-menu-item-count">{{ page.count }}</span> |
| @@ -517,6 +637,14 @@ function pageNav(delta: number) { | ||
| 517 | 637 | </template> |
| 518 | 638 | </div> |
| 519 | 639 | </Transition> |
| 640 | ||
| 641 | <Transition name="ribbon-menu-fade"> | |
| 642 | <div | |
| 643 | v-if="showListMenu && showListMenuFade && listMenuFadeReady" | |
| 644 | class="page-ribbon-list-menu-fade" | |
| 645 | :style="listMenuFadeStyle" | |
| 646 | /> | |
| 647 | </Transition> | |
| 520 | 648 | </component> |
| 521 | 649 | |
| 522 | 650 | <!-- Tabs ribbon style (original) --> |
| @@ -652,7 +780,7 @@ function pageNav(delta: number) { | ||
| 652 | 780 | } |
| 653 | 781 | |
| 654 | 782 | .page-ribbon::after { |
| 655 | content: ''; | |
| 783 | content: ""; | |
| 656 | 784 | position: absolute; |
| 657 | 785 | right: 0; |
| 658 | 786 | bottom: 0; |
| @@ -681,14 +809,22 @@ function pageNav(delta: number) { | ||
| 681 | 809 | left: 0; |
| 682 | 810 | justify-content: flex-start; |
| 683 | 811 | padding-left: 6px; |
| 684 | background: linear-gradient(to right, var(--vp-local-search-bg) 60%, transparent); | |
| 812 | background: linear-gradient( | |
| 813 | to right, | |
| 814 | var(--vp-local-search-bg) 60%, | |
| 815 | transparent | |
| 816 | ); | |
| 685 | 817 | } |
| 686 | 818 | |
| 687 | 819 | .page-ribbon-arrow.right { |
| 688 | 820 | right: 0; |
| 689 | 821 | justify-content: flex-end; |
| 690 | 822 | padding-right: 6px; |
| 691 | background: linear-gradient(to left, var(--vp-local-search-bg) 60%, transparent); | |
| 823 | background: linear-gradient( | |
| 824 | to left, | |
| 825 | var(--vp-local-search-bg) 60%, | |
| 826 | transparent | |
| 827 | ); | |
| 692 | 828 | } |
| 693 | 829 | |
| 694 | 830 | .page-ribbon-arrow:hover { |
| @@ -728,7 +864,7 @@ function pageNav(delta: number) { | ||
| 728 | 864 | } |
| 729 | 865 | |
| 730 | 866 | .page-pill::after { |
| 731 | content: ''; | |
| 867 | content: ""; | |
| 732 | 868 | position: absolute; |
| 733 | 869 | z-index: 1; |
| 734 | 870 | right: 8px; |
| @@ -842,9 +978,7 @@ function pageNav(delta: number) { | ||
| 842 | 978 | opacity: 0.55; |
| 843 | 979 | padding: 8px 4px; |
| 844 | 980 | cursor: pointer; |
| 845 | transition: | |
| 846 | opacity 0.25s, | |
| 847 | transform 0.2s cubic-bezier(0.16, 1, 0.3, 1); | |
| 981 | transition: opacity 0.25s, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1); | |
| 848 | 982 | border-radius: 0; |
| 849 | 983 | line-height: 1; |
| 850 | 984 | } |
| @@ -903,6 +1037,29 @@ html.effects-disabled .ribbon-menu-btn:active { | ||
| 903 | 1037 | display: none; |
| 904 | 1038 | } |
| 905 | 1039 | |
| 1040 | .page-ribbon-list-menu-fade { | |
| 1041 | position: absolute; | |
| 1042 | z-index: 51; | |
| 1043 | height: 56px; | |
| 1044 | pointer-events: none; | |
| 1045 | background: linear-gradient( | |
| 1046 | to bottom, | |
| 1047 | transparent, | |
| 1048 | var(--vp-c-bg-elv) | |
| 1049 | ); | |
| 1050 | border-radius: 0 0 12px 12px; | |
| 1051 | } | |
| 1052 | ||
| 1053 | .ribbon-menu-fade-enter-active, | |
| 1054 | .ribbon-menu-fade-leave-active { | |
| 1055 | transition: opacity 0.2s; | |
| 1056 | } | |
| 1057 | ||
| 1058 | .ribbon-menu-fade-enter-from, | |
| 1059 | .ribbon-menu-fade-leave-to { | |
| 1060 | opacity: 0; | |
| 1061 | } | |
| 1062 | ||
| 906 | 1063 | .ribbon-menu-divider { |
| 907 | 1064 | height: 1px; |
| 908 | 1065 | background: var(--vp-c-divider); |
docs/.vitepress/theme/components/search/SearchSettings.vue +89 −10
| @@ -35,17 +35,43 @@ const emit = defineEmits<{ | ||
| 35 | 35 | |
| 36 | 36 | const settingsPopupRef = ref<HTMLDivElement>() |
| 37 | 37 | const settingsBounding = useElementBounding(() => props.settingsButtonRef) |
| 38 | const settingsPopupBounding = useElementBounding(settingsPopupRef) | |
| 39 | const showFade = ref(true) | |
| 38 | 40 | |
| 39 | type HelpSection = 'search' | 'view' | 'ribbon' | 'preload' | 'highlight' | 'history' | |
| 41 | const settingsFadeStyle = computed(() => ({ | |
| 42 | top: `${settingsPopupBounding.bottom.value - 56}px`, | |
| 43 | left: `${settingsPopupBounding.left.value}px`, | |
| 44 | width: `${settingsPopupBounding.width.value}px` | |
| 45 | })) | |
| 46 | ||
| 47 | const settingsFadeReady = computed(() => settingsPopupBounding.width.value > 0) | |
| 48 | ||
| 49 | function onSettingsScroll() { | |
| 50 | const el = settingsPopupRef.value | |
| 51 | if (!el) return | |
| 52 | const { scrollTop, scrollHeight, clientHeight } = el | |
| 53 | showFade.value = scrollTop + clientHeight < scrollHeight - 4 | |
| 54 | } | |
| 55 | ||
| 56 | type HelpSection = | |
| 57 | | 'search' | |
| 58 | | 'view' | |
| 59 | | 'ribbon' | |
| 60 | | 'preload' | |
| 61 | | 'highlight' | |
| 62 | | 'history' | |
| 40 | 63 | const activeHelpSection = ref<HelpSection | null>(null) |
| 41 | 64 | const helpPopupEl = ref<HTMLDivElement>() |
| 42 | 65 | const helpPopupPos = ref({ top: -9999, left: -9999 }) |
| 43 | 66 | |
| 44 | watch(() => props.showSettingsPopup, (val) => { | |
| 67 | watch(() => props.showSettingsPopup, async (val) => { | |
| 45 | 68 | if (!val) { |
| 46 | 69 | activeHelpSection.value = null |
| 47 | 70 | helpPopupPos.value = { top: -9999, left: -9999 } |
| 71 | return | |
| 48 | 72 | } |
| 73 | await nextTick() | |
| 74 | onSettingsScroll() | |
| 49 | 75 | }) |
| 50 | 76 | |
| 51 | 77 | const canHoverHelp = () => |
| @@ -65,13 +91,16 @@ function positionHelpPopup(btn: HTMLElement) { | ||
| 65 | 91 | const aboveTop = rect.top - popupH - margin |
| 66 | 92 | const belowTop = rect.bottom + margin |
| 67 | 93 | const top = aboveTop >= margin ? aboveTop : belowTop |
| 68 | const left = Math.max(margin, Math.min((vw - popupW) / 2, vw - popupW - margin)) | |
| 94 | const left = Math.max( | |
| 95 | margin, | |
| 96 | Math.min((vw - popupW) / 2, vw - popupW - margin) | |
| 97 | ) | |
| 69 | 98 | helpPopupPos.value = { top, left } |
| 70 | 99 | } else { |
| 71 | 100 | const anchorLeft = menuRect ? menuRect.left : rect.left |
| 72 | 101 | helpPopupPos.value = { |
| 73 | 102 | left: Math.max(margin, anchorLeft - popupW - 16), |
| 74 | top: rect.top, | |
| 103 | top: rect.top | |
| 75 | 104 | } |
| 76 | 105 | } |
| 77 | 106 | }) |
| @@ -109,7 +138,7 @@ function onHelpLeave() { | ||
| 109 | 138 | |
| 110 | 139 | const settingsPopupStyle = computed(() => ({ |
| 111 | 140 | top: `${settingsBounding.bottom.value + 8}px`, |
| 112 | right: `calc(100vw - ${settingsBounding.right.value}px)`, | |
| 141 | right: `calc(100vw - ${settingsBounding.right.value}px)` | |
| 113 | 142 | })) |
| 114 | 143 | |
| 115 | 144 | const settingsBtnEl = computed(() => props.settingsButtonRef) |
| @@ -129,6 +158,7 @@ function setSearchMode(mode: string) { | ||
| 129 | 158 | ref="settingsPopupRef" |
| 130 | 159 | class="search-settings-popup" |
| 131 | 160 | :style="settingsPopupStyle" |
| 161 | @scroll.passive="onSettingsScroll" | |
| 132 | 162 | @click="closeHelpSection" |
| 133 | 163 | > |
| 134 | 164 | <!-- Search Mode --> |
| @@ -415,6 +445,14 @@ function setSearchMode(mode: string) { | ||
| 415 | 445 | </div> |
| 416 | 446 | </Transition> |
| 417 | 447 | |
| 448 | <Transition name="settings-fade"> | |
| 449 | <div | |
| 450 | v-if="showSettingsPopup && showFade && settingsFadeReady" | |
| 451 | class="search-settings-fade-overlay" | |
| 452 | :style="settingsFadeStyle" | |
| 453 | /> | |
| 454 | </Transition> | |
| 455 | ||
| 418 | 456 | <!-- Help popups --> |
| 419 | 457 | <Transition name="help-popup-fade"> |
| 420 | 458 | <div |
| @@ -452,8 +490,10 @@ function setSearchMode(mode: string) { | ||
| 452 | 490 | <p class="sh-desc">Controls how search results are displayed.</p> |
| 453 | 491 | <div class="sh-options"> |
| 454 | 492 | <div class="sh-option"> |
| 455 | <strong><TextAlignStart :size="14" stroke-width="1.5" /> Detail</strong> | |
| 456 | <span>Shows a content excerpt below each result. Uses more memory.</span> | |
| 493 | <strong><TextAlignStart :size="14" stroke-width="1.5" /> | |
| 494 | Detail</strong> | |
| 495 | <span>Shows a content excerpt below each result. Uses more | |
| 496 | memory.</span> | |
| 457 | 497 | </div> |
| 458 | 498 | <div class="sh-option"> |
| 459 | 499 | <strong><List :size="14" stroke-width="1.5" /> List</strong> |
| @@ -466,7 +506,10 @@ function setSearchMode(mode: string) { | ||
| 466 | 506 | <Layers :size="16" stroke-width="1.75" class="sh-title-icon" /> |
| 467 | 507 | Excerpt Preload |
| 468 | 508 | </h4> |
| 469 | <p class="sh-desc">Renders excerpts for upcoming result pages ahead of time in Detail view.</p> | |
| 509 | <p class="sh-desc"> | |
| 510 | Renders excerpts for upcoming result pages ahead of time in Detail | |
| 511 | view. | |
| 512 | </p> | |
| 470 | 513 | <div class="sh-options"> |
| 471 | 514 | <div class="sh-option"> |
| 472 | 515 | <strong>All</strong> |
| @@ -474,7 +517,8 @@ function setSearchMode(mode: string) { | ||
| 474 | 517 | </div> |
| 475 | 518 | <div class="sh-option"> |
| 476 | 519 | <strong>Next</strong> |
| 477 | <span>Also prepares the next page so flipping forward is instant</span> | |
| 520 | <span>Also prepares the next page so flipping forward is | |
| 521 | instant</span> | |
| 478 | 522 | </div> |
| 479 | 523 | <div class="sh-option"> |
| 480 | 524 | <strong>Off</strong> |
| @@ -521,7 +565,9 @@ function setSearchMode(mode: string) { | ||
| 521 | 565 | <Clock :size="16" stroke-width="1.75" class="sh-title-icon" /> |
| 522 | 566 | Search History |
| 523 | 567 | </h4> |
| 524 | <p class="sh-desc">Saves recent searches and shows them when the search bar is empty.</p> | |
| 568 | <p class="sh-desc"> | |
| 569 | Saves recent searches and shows them when the search bar is empty. | |
| 570 | </p> | |
| 525 | 571 | </template> |
| 526 | 572 | </div> |
| 527 | 573 | </Transition> |
| @@ -543,6 +589,16 @@ function setSearchMode(mode: string) { | ||
| 543 | 589 | display: flex; |
| 544 | 590 | flex-direction: column; |
| 545 | 591 | min-width: 196px; |
| 592 | max-height: min(320px, 60vh); | |
| 593 | overflow-y: auto; | |
| 594 | overflow-x: hidden; | |
| 595 | overscroll-behavior: contain; | |
| 596 | scrollbar-width: none; | |
| 597 | -ms-overflow-style: none; | |
| 598 | } | |
| 599 | ||
| 600 | .search-settings-popup::-webkit-scrollbar { | |
| 601 | display: none; | |
| 546 | 602 | } |
| 547 | 603 | |
| 548 | 604 | .dark .search-settings-popup { |
| @@ -662,6 +718,29 @@ function setSearchMode(mode: string) { | ||
| 662 | 718 | transform: scale(0.92) translateY(-4px); |
| 663 | 719 | } |
| 664 | 720 | |
| 721 | .search-settings-fade-overlay { | |
| 722 | position: fixed; | |
| 723 | z-index: 200; | |
| 724 | height: 56px; | |
| 725 | pointer-events: none; | |
| 726 | background: linear-gradient( | |
| 727 | to bottom, | |
| 728 | transparent, | |
| 729 | var(--vp-c-bg-elv) | |
| 730 | ); | |
| 731 | border-radius: 0 0 12px 12px; | |
| 732 | } | |
| 733 | ||
| 734 | .settings-fade-enter-active, | |
| 735 | .settings-fade-leave-active { | |
| 736 | transition: opacity 0.2s; | |
| 737 | } | |
| 738 | ||
| 739 | .settings-fade-enter-from, | |
| 740 | .settings-fade-leave-to { | |
| 741 | opacity: 0; | |
| 742 | } | |
| 743 | ||
| 665 | 744 | .search-help-popup { |
| 666 | 745 | position: fixed; |
| 667 | 746 | z-index: 9999; |