Commit 9ac6d75f08

9ac6d75f08f53c9584beef67316c6a5289c7c963

parent: 5aa88d0ffe

Unsigned

Duck <57977673+woducku@users.noreply.github.com> · 2026-07-29 16:30 UTC

Update SearchRibbon.vue

Layout: unified · split

docs/.vitepress/theme/components/search/SearchRibbon.vue +82 −11
@@ -1,5 +1,5 @@
11<script setup lang="ts">
2import { ChevronRight, Menu } from 'lucide-vue-next'
2import { ChevronLeft, ChevronRight, Menu } from 'lucide-vue-next'
33import { computed, nextTick, onBeforeUnmount, ref, shallowRef, watch } from 'vue'
44import { onClickOutside, useEventListener } from '@vueuse/core'
55import { homeCards } from '../../../configs/constants'
@@ -368,6 +368,35 @@ const activePageData = computed(() => {
368368function toggleListMenu() {
369369 showListMenu.value = !showListMenu.value
370370}
371
372const allPages = computed((): (string | null)[] => {
373 const pages: (string | null)[] = [null]
374 for (const entry of groupedMenuEntries.value) {
375 if (entry.type === 'page') {
376 pages.push(entry.page.key)
377 } else {
378 for (const page of entry.folder.pages) {
379 pages.push(page.key)
380 }
381 }
382 }
383 return pages
384})
385
386const currentPageIndex = computed(() => {
387 const activeKey = props.urlSearchMode ? props.urlActivePageFilter : props.activePageFilter
388 return allPages.value.indexOf(activeKey)
389})
390
391function pageNav(delta: number) {
392 const pages = allPages.value
393 if (pages.length <= 1) return
394 const idx = currentPageIndex.value
395 const nextIdx = ((idx + delta) % pages.length + pages.length) % pages.length
396 const key = pages[nextIdx]
397 if (props.urlSearchMode) setUrlPageFilter(key)
398 else setPageFilter(key)
399}
371400</script>
372401
373402<template>
@@ -386,16 +415,34 @@ function toggleListMenu() {
386415 <span class="page-ribbon-list-badge">{{ activePageData.count }}</span>
387416 </div>
388417
389 <button
390 ref="listMenuButtonRef"
391 type="button"
392 class="ribbon-menu-btn"
393 :class="{ active: showListMenu }"
394 title="Filter by page"
395 @click.stop="toggleListMenu"
396 >
397 <Menu :size="18" stroke-width="2" />
398 </button>
418 <div class="page-ribbon-list-actions">
419 <button
420 type="button"
421 class="ribbon-menu-btn ribbon-page-nav"
422 title="Previous page"
423 @click="pageNav(-1)"
424 >
425 <ChevronLeft :size="18" stroke-width="2" />
426 </button>
427 <button
428 type="button"
429 class="ribbon-menu-btn ribbon-page-nav"
430 title="Next page"
431 @click="pageNav(1)"
432 >
433 <ChevronRight :size="18" stroke-width="2" />
434 </button>
435 <button
436 ref="listMenuButtonRef"
437 type="button"
438 class="ribbon-menu-btn"
439 :class="{ active: showListMenu }"
440 title="Filter by page"
441 @click.stop="toggleListMenu"
442 >
443 <Menu :size="18" stroke-width="2" />
444 </button>
445 </div>
399446
400447 <!-- List menu dropdown -->
401448 <Transition name="ribbon-menu-popup">
@@ -732,6 +779,17 @@ function toggleListMenu() {
732779 overflow: visible;
733780}
734781
782@media (min-width: 768px) {
783 .ribbon-page-nav {
784 display: none;
785 }
786}
787
788.page-ribbon-list-actions {
789 display: flex;
790 align-items: center;
791}
792
735793.page-ribbon-list-label {
736794 display: flex;
737795 align-items: center;
@@ -797,8 +855,21 @@ function toggleListMenu() {
797855 background: transparent;
798856}
799857
858@media (hover: none) {
859 .ribbon-menu-btn:hover {
860 opacity: 0.55;
861 color: var(--vp-c-text-1);
862 }
863}
864
865.ribbon-menu-btn:focus {
866 outline: none;
867}
868
800869.ribbon-menu-btn:active {
801870 transform: scale(0.94);
871 opacity: 1;
872 color: var(--vp-c-text-1);
802873}
803874
804875html.effects-disabled .ribbon-menu-btn {