docs/.vitepress/theme/components/search/SearchRibbon.vue
1197 lines · 28900 bytes
1<script setup lang="ts">
2import {
3 onClickOutside,
4 useElementBounding,
5 useEventListener
6} from '@vueuse/core'
7import { ChevronLeft, ChevronRight, Menu } from 'lucide-vue-next'
8import {
9 computed,
10 nextTick,
11 onBeforeUnmount,
12 ref,
13 shallowRef,
14 watch
15} from 'vue'
16import { homeCards } from '../../../configs/constants'
17import type { HomeCard } from '../../../configs/constants'
18
19interface PageGroup {
20 key: string
21 label: string
22 count: number
23}
24
25interface GroupedPage {
26 key: string
27 label: string
28 count: number
29 card: HomeCard | null
30 iconClass: string
31}
32
33interface FolderGroup {
34 section: string
35 parentCard: HomeCard | null
36 iconClass: string
37 pages: GroupedPage[]
38}
39
40type MenuEntry =
41 | { type: 'page'; page: GroupedPage }
42 | { type: 'folder'; folder: FolderGroup }
43
44function getPageCard(path: string): HomeCard | null {
45 let best: HomeCard | null = null
46 let bestLen = 0
47 for (const card of homeCards) {
48 if (
49 (path === card.link || path.startsWith(card.link + '/')) &&
50 card.link.length > bestLen
51 ) {
52 best = card
53 bestLen = card.link.length
54 }
55 }
56 return best
57}
58
59function cardIconToClass(icon: string): string {
60 const m = icon.match(/^:(.+):$/)
61 if (!m) return 'i-lucide:file-text'
62 const name = m[1]
63 const dash = name.indexOf('-')
64 if (dash === -1) return 'i-lucide:file-text'
65 return `i-${name.slice(0, dash)}:${name.slice(dash + 1)}`
66}
67
68const props = defineProps<{
69 ribbonStyle: 'tabs' | 'list'
70 searchMotionDiv: string | object
71 ribbonMotion: Record<string, unknown>
72 searchAnimationsEnabled: boolean
73 urlSearchMode: boolean
74 urlPageGroups: PageGroup[]
75 urlActivePageFilter: string | null
76 urlMatchesLength: number
77 pageGroups: PageGroup[]
78 activePageFilter: string | null
79 resultsLength: number
80}>()
81
82const emit = defineEmits<{
83 selectUrlPage: [key: string | null]
84 selectPage: [key: string | null]
85}>()
86
87// List ribbon state
88const showListMenu = ref(false)
89const listMenuButtonRef = ref<HTMLElement>()
90const listMenuRef = ref<HTMLElement>()
91const showListMenuFade = ref(true)
92const listMenuBounding = useElementBounding(listMenuRef)
93const ribbonBounding = useElementBounding(() =>
94 listMenuRef.value?.closest('.page-ribbon-list')
95)
96
97const 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
103const listMenuFadeReady = computed(() => listMenuBounding.width.value > 0)
104
105function onListMenuScroll() {
106 const el = listMenuRef.value
107 if (!el) return
108 const { scrollTop, scrollHeight, clientHeight } = el
109 showListMenuFade.value = scrollTop + clientHeight < scrollHeight - 4
110}
111
112// Tabs ribbon state
113const ribbonTrack = shallowRef<HTMLElement>()
114const ribbonCanScrollLeft = ref(false)
115const ribbonCanScrollRight = ref(false)
116const isDragging = ref(false)
117let ribbonAnimHandle = 0
118let dragStartX = 0
119let dragStartScrollLeft = 0
120let dragMoved = false
121let touchStartX = 0
122let touchStartScrollLeft = 0
123let touchDragMoved = false
124
125onClickOutside(listMenuRef, () => {
126 showListMenu.value = false
127}, { ignore: [listMenuButtonRef] })
128
129function onDragStart(e: MouseEvent) {
130 // Only respond to primary (left) button
131 if (e.button !== 0) return
132 const track = getRibbonTrack()
133 if (!track) return
134 // Don't drag if user clicked on a scroll arrow
135 const target = e.target as HTMLElement
136 if (target.closest('.page-ribbon-arrow')) return
137
138 isDragging.value = true
139 dragStartX = e.clientX
140 dragStartScrollLeft = track.scrollLeft
141 dragMoved = false
142 track.style.cursor = 'grabbing'
143 track.style.userSelect = 'none'
144 // Prevent text selection while dragging
145 e.preventDefault()
146}
147
148function onDragMove(e: MouseEvent) {
149 if (!isDragging.value) return
150 const track = getRibbonTrack()
151 if (!track) return
152
153 const deltaX = e.clientX - dragStartX
154 const threshold = 4
155 if (!dragMoved && Math.abs(deltaX) > threshold) {
156 dragMoved = true
157 }
158
159 if (dragMoved) {
160 track.scrollLeft = dragStartScrollLeft - deltaX
161 updateRibbonOverflow()
162 }
163}
164
165function onDragEnd() {
166 if (!isDragging.value) return
167 isDragging.value = false
168 const track = getRibbonTrack()
169 if (track) {
170 track.style.cursor = ''
171 track.style.userSelect = ''
172 }
173}
174
175function onTrackClick(e: MouseEvent) {
176 if (dragMoved || touchDragMoved) {
177 e.preventDefault()
178 e.stopPropagation()
179 dragMoved = false
180 touchDragMoved = false
181 }
182}
183
184function onTrackWheel(e: WheelEvent) {
185 const track = getRibbonTrack()
186 if (!track) return
187 const max = track.scrollWidth - track.clientWidth
188 if (max <= 0) return
189 const newScroll = Math.max(
190 0,
191 Math.min(max, track.scrollLeft + e.deltaX + e.deltaY)
192 )
193 if (newScroll !== track.scrollLeft) {
194 e.preventDefault()
195 track.scrollLeft = newScroll
196 updateRibbonOverflow()
197 }
198}
199
200function onTouchStart(e: TouchEvent) {
201 const track = getRibbonTrack()
202 if (!track) return
203 const target = e.target as HTMLElement
204 if (target.closest('.page-ribbon-arrow')) return
205 touchStartX = e.touches[0].clientX
206 touchStartScrollLeft = track.scrollLeft
207 touchDragMoved = false
208}
209
210function onTouchMove(e: TouchEvent) {
211 const track = getRibbonTrack()
212 if (!track) return
213 const deltaX = e.touches[0].clientX - touchStartX
214 const threshold = 4
215 if (!touchDragMoved && Math.abs(deltaX) > threshold) {
216 touchDragMoved = true
217 }
218 if (touchDragMoved) {
219 track.scrollLeft = touchStartScrollLeft - deltaX
220 updateRibbonOverflow()
221 }
222}
223
224function onTouchEnd() {
225}
226
227function updateRibbonOverflow() {
228 const track = getRibbonTrack()
229 if (!track) {
230 ribbonCanScrollLeft.value = false
231 ribbonCanScrollRight.value = false
232 return
233 }
234 ribbonCanScrollLeft.value = track.scrollLeft > 2
235 ribbonCanScrollRight.value =
236 track.scrollWidth - track.clientWidth - track.scrollLeft > 2
237}
238
239function getRibbonTrack(): HTMLElement | null {
240 return ribbonTrack.value ?? null
241}
242
243function scrollActivePagePillIntoView(direction = 0) {
244 if (props.ribbonStyle === 'list') return
245 nextTick(() => {
246 const track = getRibbonTrack()
247 if (!track) return
248 const pills = [...track.querySelectorAll<HTMLElement>('.page-pill')]
249 const activeIndex = pills.findIndex((pill) =>
250 pill.classList.contains('active')
251 )
252 const active = pills[activeIndex]
253 if (!active) return
254 const trackRect = track.getBoundingClientRect()
255 const activeRect = active.getBoundingClientRect()
256 const gap = 8
257 let nextScrollLeft = track.scrollLeft
258 if (activeRect.left < trackRect.left) {
259 nextScrollLeft += activeRect.left - trackRect.left - gap
260 } else if (activeRect.right > trackRect.right) {
261 nextScrollLeft += activeRect.right - trackRect.right + gap
262 }
263 const peek = pills[activeIndex + Math.sign(direction)]
264 if (peek) {
265 const peekRect = peek.getBoundingClientRect()
266 if (direction > 0 && peekRect.right > trackRect.right) {
267 nextScrollLeft += peekRect.right - trackRect.right + gap
268 } else if (direction < 0 && peekRect.left < trackRect.left) {
269 nextScrollLeft += peekRect.left - trackRect.left - gap
270 }
271 }
272 const max = track.scrollWidth - track.clientWidth
273 track.scrollTo({
274 left: Math.max(0, Math.min(max, nextScrollLeft)),
275 behavior: props.searchAnimationsEnabled ? 'smooth' : 'auto'
276 })
277 updateRibbonOverflow()
278 })
279}
280
281function scrollRibbon(direction: number) {
282 const track = getRibbonTrack()
283 if (!track) return
284 const max = track.scrollWidth - track.clientWidth
285 const amount = track.clientWidth * 0.7 * direction
286 const from = track.scrollLeft
287 const to = Math.max(0, Math.min(max, from + amount))
288 if (to === from) return
289 if (ribbonAnimHandle) cancelAnimationFrame(ribbonAnimHandle)
290 if (!props.searchAnimationsEnabled) {
291 track.scrollLeft = to
292 updateRibbonOverflow()
293 return
294 }
295
296 const duration = 280
297 const start = performance.now()
298 const ease = (t: number) => 1 - Math.pow(1 - t, 3)
299 const step = (now: number) => {
300 const t = Math.min(1, (now - start) / duration)
301 track.scrollLeft = from + (to - from) * ease(t)
302 updateRibbonOverflow()
303 if (t < 1) ribbonAnimHandle = requestAnimationFrame(step)
304 else ribbonAnimHandle = 0
305 }
306 ribbonAnimHandle = requestAnimationFrame(step)
307}
308
309watch(() => props.pageGroups, () => {
310 nextTick(() => {
311 updateRibbonOverflow()
312 onListMenuScroll()
313 })
314})
315watch(() => props.urlPageGroups, () => {
316 nextTick(() => {
317 updateRibbonOverflow()
318 onListMenuScroll()
319 })
320})
321watch(showListMenu, async (open) => {
322 if (!open) return
323 await nextTick()
324 onListMenuScroll()
325})
326useEventListener('resize', updateRibbonOverflow)
327
328onBeforeUnmount(() => {
329 if (ribbonAnimHandle) cancelAnimationFrame(ribbonAnimHandle)
330 // Reset drag state if component unmounts mid-drag
331 if (isDragging.value) {
332 onDragEnd()
333 }
334})
335
336defineExpose({ scrollActivePagePillIntoView })
337
338const groupedMenuEntries = computed((): MenuEntry[] => {
339 const groups = props.urlSearchMode ? props.urlPageGroups : props.pageGroups
340 if (!groups.length) return []
341
342 // Wrap each group with card info
343 const withCards: GroupedPage[] = groups.map((g) => {
344 const card = getPageCard(g.key)
345 return {
346 key: g.key,
347 label: g.label,
348 count: g.count,
349 card,
350 iconClass: card ? cardIconToClass(card.icon) : 'i-lucide:file-text'
351 }
352 })
353
354 // Separate into top-level (no section) and folder (has section)
355 const topPages: GroupedPage[] = []
356 const folderMap = new Map<string, GroupedPage[]>()
357
358 for (const p of withCards) {
359 if (p.card?.section) {
360 if (!folderMap.has(p.card.section)) folderMap.set(p.card.section, [])
361 folderMap.get(p.card.section)!.push(p)
362 } else {
363 topPages.push(p)
364 }
365 }
366
367 // Build folder entries
368 const folderEntries: FolderGroup[] = [...folderMap.entries()]
369 .map(([section, pages]) => {
370 const parentCard = homeCards.find((c) =>
371 c.title === section && !c.section
372 ) ?? null
373 return {
374 section,
375 parentCard,
376 iconClass: parentCard
377 ? cardIconToClass(parentCard.icon)
378 : 'i-lucide:folder',
379 pages
380 }
381 })
382
383 // Merge: top-level pages first, then folder groups
384 const entries: MenuEntry[] = [
385 ...topPages.map((p) => ({ type: 'page' as const, page: p })),
386 ...folderEntries.map((f) => ({ type: 'folder' as const, folder: f }))
387 ]
388
389 return entries
390})
391
392function setUrlPageFilter(key: string | null) {
393 emit('selectUrlPage', key)
394 showListMenu.value = false
395 nextTick(updateRibbonOverflow)
396}
397
398function setPageFilter(key: string | null) {
399 emit('selectPage', key)
400 showListMenu.value = false
401 nextTick(updateRibbonOverflow)
402}
403
404const activePageData = computed(() => {
405 const findInEntries = (key: string, fallbackCount: number) => {
406 for (const entry of groupedMenuEntries.value) {
407 if (entry.type === 'page' && entry.page.key === key) {
408 return {
409 label: entry.page.label,
410 iconClass: entry.page.iconClass,
411 count: entry.page.count
412 }
413 }
414 if (entry.type === 'folder') {
415 const found = entry.folder.pages.find((p) => p.key === key)
416 if (found) {
417 return {
418 label: found.label,
419 iconClass: entry.folder.iconClass,
420 count: found.count
421 }
422 }
423 }
424 }
425 return null
426 }
427
428 if (props.urlSearchMode) {
429 if (props.urlActivePageFilter === null) {
430 return {
431 label: 'All',
432 iconClass: 'i-lucide:text-search',
433 count: props.urlMatchesLength
434 }
435 }
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 }
446 }
447
448 if (props.activePageFilter === null) {
449 return {
450 label: 'All',
451 iconClass: 'i-lucide:text-search',
452 count: props.resultsLength
453 }
454 }
455 const result = findInEntries(props.activePageFilter, props.resultsLength)
456 return result ??
457 {
458 label: 'All',
459 iconClass: 'i-lucide:text-search',
460 count: props.resultsLength
461 }
462})
463
464function toggleListMenu() {
465 showListMenu.value = !showListMenu.value
466}
467
468const allPages = computed((): (string | null)[] => {
469 const pages: (string | null)[] = [null]
470 for (const entry of groupedMenuEntries.value) {
471 if (entry.type === 'page') {
472 pages.push(entry.page.key)
473 } else {
474 for (const page of entry.folder.pages) {
475 pages.push(page.key)
476 }
477 }
478 }
479 return pages
480})
481
482const currentPageIndex = computed(() => {
483 const activeKey = props.urlSearchMode
484 ? props.urlActivePageFilter
485 : props.activePageFilter
486 return allPages.value.indexOf(activeKey)
487})
488
489function pageNav(delta: number) {
490 const pages = allPages.value
491 if (pages.length <= 1) return
492 const idx = currentPageIndex.value
493 const nextIdx = ((idx + delta) % pages.length + pages.length) % pages.length
494 const key = pages[nextIdx]
495 if (props.urlSearchMode) setUrlPageFilter(key)
496 else setPageFilter(key)
497}
498</script>
499
500<template>
501 <!-- List ribbon style -->
502 <component
503 :is="searchMotionDiv"
504 v-if="ribbonStyle === 'list' && (urlSearchMode
505 ? urlPageGroups.length > 1
506 : pageGroups.length > 1)"
507 class="page-ribbon page-ribbon-list"
508 v-bind="ribbonMotion"
509 >
510 <div class="page-ribbon-list-label">
511 <span :class="activePageData.iconClass" class="page-ribbon-list-icon" />
512 <span class="page-ribbon-list-name">{{ activePageData.label }}</span>
513 <span class="page-ribbon-list-badge">{{ activePageData.count }}</span>
514 </div>
515
516 <div class="page-ribbon-list-actions">
517 <button
518 type="button"
519 class="ribbon-menu-btn ribbon-page-nav"
520 title="Previous page"
521 @click="pageNav(-1)"
522 >
523 <ChevronLeft :size="18" stroke-width="2" />
524 </button>
525 <button
526 type="button"
527 class="ribbon-menu-btn ribbon-page-nav"
528 title="Next page"
529 @click="pageNav(1)"
530 >
531 <ChevronRight :size="18" stroke-width="2" />
532 </button>
533 <button
534 ref="listMenuButtonRef"
535 type="button"
536 class="ribbon-menu-btn"
537 :class="{ 'is-open': showListMenu }"
538 title="Filter by page"
539 :aria-expanded="showListMenu"
540 aria-haspopup="true"
541 @click.stop="toggleListMenu"
542 >
543 <Menu :size="18" stroke-width="2" />
544 </button>
545 </div>
546
547 <!-- List menu dropdown -->
548 <Transition name="ribbon-menu-popup">
549 <div
550 v-if="showListMenu"
551 ref="listMenuRef"
552 class="page-ribbon-list-menu"
553 @scroll.passive="onListMenuScroll"
554 >
555 <!-- "All" item -->
556 <button
557 type="button"
558 class="ribbon-menu-item all-item"
559 :class="{
560 active: urlSearchMode
561 ? urlActivePageFilter === null
562 : activePageFilter === null
563 }"
564 @click="urlSearchMode
565 ? setUrlPageFilter(null)
566 : setPageFilter(null)"
567 >
568 <span class="i-lucide:text-search ribbon-menu-item-icon" />
569 <span class="ribbon-menu-item-label">All</span>
570 <span class="ribbon-menu-item-count">{{
571 urlSearchMode ? urlMatchesLength : resultsLength
572 }}</span>
573 </button>
574
575 <div class="ribbon-menu-divider" />
576
577 <!-- Grouped pages -->
578 <template
579 v-for="entry in groupedMenuEntries"
580 :key="entry.type === 'page'
581 ? entry.page.key
582 : entry.folder.section"
583 >
584 <!-- Top-level page -->
585 <div v-if="entry.type === 'page'" class="ribbon-menu-group">
586 <button
587 type="button"
588 class="ribbon-menu-item"
589 :class="{
590 active: urlSearchMode
591 ? urlActivePageFilter === entry.page.key
592 : activePageFilter === entry.page.key
593 }"
594 @click="urlSearchMode
595 ? setUrlPageFilter(entry.page.key)
596 : setPageFilter(entry.page.key)"
597 >
598 <span
599 :class="entry.page.iconClass"
600 class="ribbon-menu-item-icon"
601 />
602 <span class="ribbon-menu-item-label">{{ entry.page.label }}</span>
603 <span class="ribbon-menu-item-count">{{ entry.page.count }}</span>
604 </button>
605 </div>
606
607 <!-- Folder group -->
608 <div v-else class="ribbon-menu-group">
609 <h4 class="ribbon-menu-group-title">
610 <span
611 :class="entry.folder.iconClass"
612 class="ribbon-menu-group-icon"
613 />
614 <span class="ribbon-menu-group-text">{{
615 entry.folder.section
616 }}</span>
617 </h4>
618 <div class="ribbon-menu-sub-items">
619 <button
620 v-for="page in entry.folder.pages"
621 :key="page.key"
622 type="button"
623 class="ribbon-menu-item"
624 :class="{
625 active: urlSearchMode
626 ? urlActivePageFilter === page.key
627 : activePageFilter === page.key
628 }"
629 @click="urlSearchMode
630 ? setUrlPageFilter(page.key)
631 : setPageFilter(page.key)"
632 >
633 <span class="ribbon-menu-item-label">{{ page.label }}</span>
634 <span class="ribbon-menu-item-count">{{ page.count }}</span>
635 </button>
636 </div>
637 </div>
638 </template>
639 </div>
640 </Transition>
641
642 <Transition name="ribbon-menu-fade">
643 <div
644 v-if="showListMenu && showListMenuFade && listMenuFadeReady"
645 class="page-ribbon-list-menu-fade"
646 :style="listMenuFadeStyle"
647 />
648 </Transition>
649 </component>
650
651 <!-- Tabs ribbon style (original) -->
652 <component
653 :is="searchMotionDiv"
654 v-if="ribbonStyle !== 'list' && (urlSearchMode
655 ? urlPageGroups.length > 1
656 : pageGroups.length > 1)"
657 class="page-ribbon"
658 :class="{
659 'can-scroll-left': ribbonCanScrollLeft,
660 'can-scroll-right': ribbonCanScrollRight
661 }"
662 v-bind="ribbonMotion"
663 >
664 <button
665 v-if="ribbonCanScrollLeft"
666 type="button"
667 class="page-ribbon-arrow left"
668 aria-label="Scroll filters left"
669 @click="scrollRibbon(-1)"
670 >
671 <ChevronRight :size="18" stroke-width="1.75" />
672 </button>
673 <div
674 ref="ribbonTrack"
675 class="page-ribbon-track"
676 :class="{ 'is-dragging': isDragging }"
677 @scroll="updateRibbonOverflow"
678 @mousedown="onDragStart"
679 @mousemove="onDragMove"
680 @mouseup="onDragEnd"
681 @mouseleave="onDragEnd"
682 @touchstart.passive="onTouchStart"
683 @touchmove.passive="onTouchMove"
684 @touchend="onTouchEnd"
685 @click.capture="onTrackClick"
686 @wheel="onTrackWheel"
687 >
688 <!-- URL mode tabs -->
689 <template v-if="urlSearchMode">
690 <button
691 type="button"
692 class="page-pill"
693 :class="{ active: urlActivePageFilter === null }"
694 @click="setUrlPageFilter(null)"
695 >
696 All
697 <span class="page-pill-count">{{ urlMatchesLength }}</span>
698 </button>
699 <button
700 v-for="group in urlPageGroups"
701 :key="group.key"
702 type="button"
703 class="page-pill"
704 :class="{ active: urlActivePageFilter === group.key }"
705 @click="setUrlPageFilter(group.key)"
706 >
707 <span class="page-pill-label">{{ group.label }}</span>
708 <span class="page-pill-count">{{ group.count }}</span>
709 </button>
710 </template>
711 <!-- Normal mode tabs -->
712 <template v-else>
713 <button
714 type="button"
715 class="page-pill"
716 :class="{ active: activePageFilter === null }"
717 @click="setPageFilter(null)"
718 >
719 All
720 <span class="page-pill-count">{{ resultsLength }}</span>
721 </button>
722 <button
723 v-for="group in pageGroups"
724 :key="group.key"
725 type="button"
726 class="page-pill"
727 :class="{ active: activePageFilter === group.key }"
728 @click="setPageFilter(group.key)"
729 >
730 <span class="page-pill-label">{{ group.label }}</span>
731 <span class="page-pill-count">{{ group.count }}</span>
732 </button>
733 </template>
734 </div>
735 <button
736 v-if="ribbonCanScrollRight"
737 type="button"
738 class="page-ribbon-arrow right"
739 aria-label="Scroll filters right"
740 @click="scrollRibbon(1)"
741 >
742 <ChevronRight :size="18" stroke-width="1.75" />
743 </button>
744 </component>
745</template>
746
747<style>
748.page-ribbon {
749 display: flex;
750 align-items: center;
751 position: relative;
752 min-width: 0;
753 flex: none;
754 overflow: hidden;
755 padding: 8px 12px 0;
756 transition: padding-inline 0.15s;
757}
758
759.page-ribbon.can-scroll-left {
760 padding-left: 42px;
761}
762
763.page-ribbon.can-scroll-right {
764 padding-right: 42px;
765}
766
767.page-ribbon-track {
768 display: flex;
769 flex-wrap: nowrap;
770 gap: 0;
771 min-width: 0;
772 flex: 1;
773 overflow: hidden;
774 position: relative;
775 cursor: grab;
776}
777
778.page-ribbon-track.is-dragging {
779 cursor: grabbing;
780 user-select: none;
781}
782
783.page-ribbon::after {
784 content: "";
785 position: absolute;
786 right: 0;
787 bottom: 0;
788 left: 0;
789 height: 2px;
790 background-color: var(--vp-c-divider);
791}
792
793.page-ribbon-arrow {
794 position: absolute;
795 top: 0;
796 bottom: 0;
797 z-index: 2;
798 display: inline-flex;
799 align-items: center;
800 justify-content: center;
801 width: 48px;
802 border: none;
803 background: transparent;
804 color: var(--vp-c-text-2);
805 cursor: pointer;
806 transition: color 0.15s;
807}
808
809.page-ribbon-arrow.left {
810 left: 0;
811 justify-content: flex-start;
812 padding-left: 6px;
813 background: linear-gradient(
814 to right,
815 var(--vp-local-search-bg) 60%,
816 transparent
817 );
818}
819
820.page-ribbon-arrow.right {
821 right: 0;
822 justify-content: flex-end;
823 padding-right: 6px;
824 background: linear-gradient(
825 to left,
826 var(--vp-local-search-bg) 60%,
827 transparent
828 );
829}
830
831.page-ribbon-arrow:hover {
832 color: var(--vp-c-text-1);
833}
834
835.page-ribbon-arrow.left svg {
836 transform: rotate(180deg);
837}
838
839.page-pill {
840 flex: none;
841 position: relative;
842 display: inline-flex;
843 align-items: center;
844 gap: 6px;
845 padding: 0 12px;
846 height: 36px;
847 font-size: 0.85rem;
848 font-weight: 500;
849 white-space: nowrap;
850 border: none;
851 border-bottom: 2px solid transparent;
852 background: transparent;
853 color: var(--vp-c-text-2);
854 cursor: pointer;
855 transition: color 0.2s;
856}
857
858.page-pill:hover {
859 color: var(--vp-c-text-1);
860}
861
862.page-pill.active {
863 color: var(--vp-c-text-1);
864 font-weight: 600;
865}
866
867.page-pill::after {
868 content: "";
869 position: absolute;
870 z-index: 1;
871 right: 8px;
872 bottom: -2px;
873 left: 8px;
874 height: 2px;
875 background-color: transparent;
876 border-radius: 0;
877 transition: background-color 0.2s;
878}
879
880.page-pill.active::after {
881 background-color: var(--vp-c-brand-1);
882}
883
884.page-pill-label {
885 max-width: 180px;
886 overflow: hidden;
887 text-overflow: ellipsis;
888}
889
890.page-pill-count {
891 font-variant-numeric: tabular-nums;
892 font-size: 0.7rem;
893 padding: 1px 6px;
894 border-radius: 3px;
895 background: rgba(128, 128, 128, 0.12);
896 color: var(--vp-c-text-3);
897 line-height: 1.4;
898}
899
900.page-pill.active .page-pill-count {
901 color: var(--vp-c-text-2);
902 background: rgba(128, 128, 128, 0.18);
903}
904
905@media (max-width: 767px) {
906 .page-pill {
907 height: 32px;
908 padding: 0 10px;
909 font-size: 0.8rem;
910 }
911}
912
913/* List ribbon style */
914.page-ribbon-list {
915 justify-content: space-between;
916 padding: 6px 12px 4px;
917 overflow: visible;
918}
919
920@media (min-width: 768px) {
921 .ribbon-page-nav {
922 display: none;
923 }
924}
925
926.page-ribbon-list-actions {
927 display: flex;
928 align-items: center;
929}
930
931.page-ribbon-list-label {
932 display: flex;
933 align-items: center;
934 gap: 6px;
935 font-size: 0.9rem;
936 font-weight: 500;
937 color: var(--vp-c-text-2);
938 font-variant-numeric: tabular-nums;
939 line-height: 1;
940 min-width: 0;
941}
942
943.page-ribbon-list-icon {
944 flex: none;
945 font-size: 16px;
946 width: 1em;
947 height: 1em;
948 color: var(--vp-c-text-1);
949}
950
951.page-ribbon-list-name {
952 overflow: hidden;
953 text-overflow: ellipsis;
954 white-space: nowrap;
955 min-width: 0;
956 color: var(--vp-c-text-1);
957 font-weight: 600;
958}
959
960.page-ribbon-list-badge {
961 flex-shrink: 0;
962 font-variant-numeric: tabular-nums;
963 font-size: 0.72rem;
964 padding: 1px 7px;
965 border-radius: 4px;
966 background: rgba(128, 128, 128, 0.15);
967 color: var(--vp-c-text-1);
968 line-height: 1.5;
969 font-weight: 600;
970}
971
972.ribbon-menu-btn {
973 display: flex;
974 align-items: center;
975 justify-content: center;
976 border: none;
977 background: transparent;
978 color: var(--vp-c-text-1);
979 opacity: 0.55;
980 padding: 8px 4px;
981 cursor: pointer;
982 transition: opacity 0.25s, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
983 border-radius: 0;
984 line-height: 1;
985}
986
987.ribbon-menu-btn:hover {
988 color: var(--vp-c-text-1);
989 opacity: 1;
990 background: transparent;
991}
992
993@media (hover: none) {
994 .ribbon-menu-btn:hover {
995 opacity: 0.55;
996 color: var(--vp-c-text-1);
997 }
998}
999
1000.ribbon-menu-btn:focus {
1001 outline: none;
1002}
1003
1004.ribbon-menu-btn:active {
1005 transform: scale(0.94);
1006 opacity: 1;
1007 color: var(--vp-c-text-1);
1008}
1009
1010.ribbon-menu-btn.is-open {
1011 opacity: 1;
1012 color: var(--vp-c-text-1);
1013}
1014
1015html.effects-disabled .ribbon-menu-btn {
1016 transition: none;
1017}
1018
1019html.effects-disabled .ribbon-menu-btn:active {
1020 transform: none;
1021}
1022
1023.page-ribbon-list-menu {
1024 position: absolute;
1025 top: 100%;
1026 right: 4px;
1027 z-index: 50;
1028 width: 228px;
1029 max-height: 320px;
1030 overflow-y: auto;
1031 overflow-x: hidden;
1032 background: var(--vp-c-bg-elv);
1033 border: 1px solid var(--vp-c-divider);
1034 border-radius: 12px;
1035 box-shadow: var(--vp-shadow-3);
1036 padding: 8px;
1037 overscroll-behavior: contain;
1038 scrollbar-width: none;
1039 -ms-overflow-style: none;
1040}
1041
1042.page-ribbon-list-menu::-webkit-scrollbar {
1043 display: none;
1044}
1045
1046.page-ribbon-list-menu-fade {
1047 position: absolute;
1048 z-index: 51;
1049 height: 56px;
1050 pointer-events: none;
1051 background: linear-gradient(
1052 to bottom,
1053 transparent,
1054 var(--vp-c-bg-elv)
1055 );
1056 border-radius: 0 0 12px 12px;
1057}
1058
1059.ribbon-menu-fade-enter-active {
1060 transition: opacity 0.2s;
1061}
1062
1063.ribbon-menu-fade-leave-active {
1064 transition: none;
1065}
1066
1067.ribbon-menu-fade-enter-from,
1068.ribbon-menu-fade-leave-to {
1069 opacity: 0;
1070}
1071
1072.ribbon-menu-divider {
1073 height: 1px;
1074 background: var(--vp-c-divider);
1075 margin: 4px 0;
1076}
1077
1078.ribbon-menu-item {
1079 display: flex;
1080 align-items: center;
1081 gap: 8px;
1082 padding: 6px 8px;
1083 border: none;
1084 background: transparent;
1085 border-radius: 6px;
1086 color: var(--vp-c-text-2);
1087 font-size: 0.82rem;
1088 font-weight: 500;
1089 cursor: pointer;
1090 transition: background-color 0.15s, color 0.15s;
1091 text-align: left;
1092 width: 100%;
1093}
1094
1095.ribbon-menu-item:hover {
1096 background: var(--vp-c-default-soft);
1097 color: var(--vp-c-text-1);
1098}
1099
1100.ribbon-menu-item.active {
1101 color: var(--vp-c-brand-1);
1102 background: color-mix(in srgb, var(--vp-c-brand-1) 10%, transparent);
1103 font-weight: 600;
1104}
1105
1106.ribbon-menu-item-icon {
1107 flex: none;
1108 font-size: 15px;
1109 color: var(--vp-c-text-1);
1110 width: 1em;
1111 height: 1em;
1112}
1113
1114.ribbon-menu-item-label {
1115 flex: 1;
1116 overflow: hidden;
1117 text-overflow: ellipsis;
1118 white-space: nowrap;
1119 min-width: 0;
1120}
1121
1122.all-item {
1123 font-weight: 600;
1124 font-size: 0.85rem;
1125}
1126
1127.ribbon-menu-item-count {
1128 flex-shrink: 0;
1129 font-variant-numeric: tabular-nums;
1130 font-size: 0.68rem;
1131 padding: 1px 6px;
1132 border-radius: 3px;
1133 background: rgba(128, 128, 128, 0.12);
1134 color: var(--vp-c-text-3);
1135 line-height: 1.4;
1136 margin-left: auto;
1137}
1138
1139.ribbon-menu-item.active .ribbon-menu-item-count {
1140 color: var(--vp-c-text-2);
1141 background: rgba(128, 128, 128, 0.18);
1142}
1143
1144.ribbon-menu-group + .ribbon-menu-group {
1145 margin-top: 2px;
1146}
1147
1148.ribbon-menu-group-title {
1149 display: flex;
1150 align-items: center;
1151 gap: 6px;
1152 font-size: 11px;
1153 font-weight: 700;
1154 letter-spacing: 0.02em;
1155 color: var(--vp-c-text-1);
1156 margin: 8px 0 2px;
1157 padding: 0 8px 4px;
1158 user-select: none;
1159 border-bottom: 1px solid var(--vp-c-divider);
1160}
1161
1162.ribbon-menu-group-icon {
1163 font-size: 13px;
1164 flex: none;
1165 width: 1em;
1166 height: 1em;
1167 color: var(--vp-c-text-1);
1168}
1169
1170.ribbon-menu-group-text {
1171 flex: 1;
1172 min-width: 0;
1173 overflow: hidden;
1174 white-space: nowrap;
1175 text-overflow: ellipsis;
1176 text-transform: uppercase;
1177 letter-spacing: 0.06em;
1178}
1179
1180.ribbon-menu-sub-items {
1181 display: flex;
1182 flex-direction: column;
1183 gap: 1px;
1184}
1185
1186.ribbon-menu-popup-enter-active,
1187.ribbon-menu-popup-leave-active {
1188 transition: opacity 0.12s ease, transform 0.12s ease;
1189 transform-origin: top right;
1190}
1191
1192.ribbon-menu-popup-enter-from,
1193.ribbon-menu-popup-leave-to {
1194 opacity: 0;
1195 transform: scale(0.92) translateY(-4px);
1196}
1197</style>