Commit e8e1248194

e8e1248194930c21484c3bdbf66ada613d7ab392

parent: 8b56123646

Unsigned

Duck <57977673+woducku@users.noreply.github.com> · 2026-07-07 10:40 UTC

menuhelp

Layout: unified · split

docs/.vitepress/theme/components/HomeFeatures.vue +73 −21
@@ -89,6 +89,7 @@ const dropdownOpen = ref(false)
8989type HelpSection = 'view' | 'columns'
9090const activeHelpSection = ref<HelpSection | null>(null)
9191const helpPopupEl = ref<HTMLDivElement | null>(null)
92const settingsDropdownEl = ref<HTMLDivElement | null>(null)
9293const helpPopupPos = ref({ top: -9999, left: -9999 })
9394
9495watch(dropdownOpen, (val) => {
@@ -98,27 +99,67 @@ watch(dropdownOpen, (val) => {
9899 }
99100})
100101
101function toggleHelpSection(section: HelpSection, e: MouseEvent) {
102 if (activeHelpSection.value === section) {
103 activeHelpSection.value = null
104 helpPopupPos.value = { top: -9999, left: -9999 }
105 return
106 }
107 activeHelpSection.value = section
102const canHoverHelp = () =>
103 typeof window !== 'undefined' && window.matchMedia('(hover: hover)').matches
104
105function positionHelpPopup(btn: HTMLElement) {
108106 helpPopupPos.value = { top: -9999, left: -9999 }
109 const btn = e.currentTarget as HTMLElement
110107 const rect = btn.getBoundingClientRect()
108 // Anchor to the dropdown's left edge so the popup sits beside it, not over it.
109 const menuRect = settingsDropdownEl.value?.getBoundingClientRect()
111110 nextTick(() => {
112 const popupW = helpPopupEl.value?.offsetWidth || 220
113 const popupH = helpPopupEl.value?.offsetHeight || 160
111 const popupW = helpPopupEl.value?.offsetWidth || 260
112 const popupH = helpPopupEl.value?.offsetHeight || 200
113 const vw = window.innerWidth
114114 const margin = 8
115 helpPopupPos.value = {
116 left: Math.max(margin, rect.left - popupW - 8),
117 top: Math.max(margin, Math.min(rect.top, window.innerHeight - popupH - margin)),
115 const isMobile = vw < 768
116 if (isMobile) {
117 const aboveTop = rect.top - popupH - margin
118 const belowTop = rect.bottom + margin
119 const top = aboveTop >= margin ? aboveTop : belowTop
120 const left = Math.max(margin, Math.min((vw - popupW) / 2, vw - popupW - margin))
121 helpPopupPos.value = { top, left }
122 } else {
123 const anchorLeft = menuRect ? menuRect.left : rect.left
124 helpPopupPos.value = {
125 left: Math.max(margin, anchorLeft - popupW - 16),
126 top: Math.max(margin, Math.min(rect.top, window.innerHeight - popupH - margin)),
127 }
118128 }
119129 })
120130}
121131
132function closeHelpSection() {
133 activeHelpSection.value = null
134 helpPopupPos.value = { top: -9999, left: -9999 }
135}
136
137function toggleHelpSection(section: HelpSection, e: MouseEvent) {
138 // Hover devices open/close via mouseenter/leave; touch devices toggle on tap.
139 if (canHoverHelp()) {
140 activeHelpSection.value = section
141 positionHelpPopup(e.currentTarget as HTMLElement)
142 return
143 }
144 if (activeHelpSection.value === section) {
145 closeHelpSection()
146 return
147 }
148 activeHelpSection.value = section
149 positionHelpPopup(e.currentTarget as HTMLElement)
150}
151
152function onHelpEnter(section: HelpSection, e: MouseEvent) {
153 if (!canHoverHelp()) return
154 activeHelpSection.value = section
155 positionHelpPopup(e.currentTarget as HTMLElement)
156}
157
158function onHelpLeave() {
159 if (!canHoverHelp()) return
160 closeHelpSection()
161}
162
122163watch(panelOpen, (open) => {
123164 if (typeof document !== 'undefined')
124165 document.body.style.overflow = open ? 'hidden' : ''
@@ -387,18 +428,18 @@ function onHandlePointerUp() {
387428 <div class="foot-group">
388429 <div class="settings-wrap">
389430 <div v-if="dropdownOpen" class="dropdown-overlay" @click="dropdownOpen = false" />
390 <div v-if="dropdownOpen" class="settings-dropdown">
431 <div v-if="dropdownOpen" ref="settingsDropdownEl" class="settings-dropdown">
391432 <div class="dropdown-section">
392433 <div class="dropdown-section-header">
393434 <span class="dropdown-label">
394435 <span class="i-lucide-layout-list dropdown-label-icon" />
395436 View
396437 </span>
397 <button type="button" class="settings-help-btn" :class="{ active: activeHelpSection === 'view' }" aria-label="View help" @click.stop="toggleHelpSection('view', $event)">
438 <button type="button" class="settings-help-btn" :class="{ active: activeHelpSection === 'view' }" aria-label="View help" @click.stop="toggleHelpSection('view', $event)" @mouseenter="onHelpEnter('view', $event)" @mouseleave="onHelpLeave">
398439 <span class="i-carbon:help-filled settings-help-icon" />
399440 </button>
400441 </div>
401 <div class="dropdown-group">
442 <div class="dropdown-group" :class="{ 'is-highlighted': activeHelpSection === 'view' }">
402443 <button class="tool-btn" :class="{ 'is-active': viewMode === 'default' }" @click="viewMode = 'default'">Default</button>
403444 <button class="tool-btn" :class="{ 'is-active': viewMode === 'mini' }" @click="viewMode = 'mini'">Mini</button>
404445 </div>
@@ -409,11 +450,11 @@ function onHandlePointerUp() {
409450 <span class="i-lucide-columns-3-cog dropdown-label-icon" />
410451 Columns
411452 </span>
412 <button type="button" class="settings-help-btn" :class="{ active: activeHelpSection === 'columns' }" aria-label="Columns help" @click.stop="toggleHelpSection('columns', $event)">
453 <button type="button" class="settings-help-btn" :class="{ active: activeHelpSection === 'columns' }" aria-label="Columns help" @click.stop="toggleHelpSection('columns', $event)" @mouseenter="onHelpEnter('columns', $event)" @mouseleave="onHelpLeave">
413454 <span class="i-carbon:help-filled settings-help-icon" />
414455 </button>
415456 </div>
416 <div class="dropdown-group">
457 <div class="dropdown-group" :class="{ 'is-highlighted': activeHelpSection === 'columns' }">
417458 <button class="tool-btn" :class="{ 'is-active': columnMode === 'default' }" @click="columnMode = 'default'">Default</button>
418459 <button class="tool-btn" :class="{ 'is-active': columnMode === 'max' }" @click="columnMode = 'max'">Max</button>
419460 </div>
@@ -1141,8 +1182,8 @@ html.effects-disabled .row-toggle:active {
11411182
11421183.settings-help-icon {
11431184 display: block;
1144 width: 14px;
1145 height: 14px;
1185 width: 16px;
1186 height: 16px;
11461187}
11471188
11481189.home-help-popup {
@@ -1201,11 +1242,15 @@ html.effects-disabled .row-toggle:active {
12011242 display: flex;
12021243 flex-direction: column;
12031244 gap: 4px;
1204 background: var(--vp-c-bg-soft);
1245 background: #e8e6ec;
12051246 border-radius: 12px;
12061247 padding: 10px 12px;
12071248}
12081249
1250.dark .sh-option {
1251 background: #2c2c31;
1252}
1253
12091254.sh-option strong {
12101255 display: flex;
12111256 align-items: center;
@@ -1290,6 +1335,13 @@ html.effects-disabled .row-toggle:active {
12901335 background: var(--seg-track);
12911336 border-radius: 8px;
12921337 padding: 4px;
1338 outline: 2px dashed transparent;
1339 outline-offset: 4px;
1340 transition: outline-color 0.2s ease;
1341}
1342
1343.dropdown-group.is-highlighted {
1344 outline-color: var(--vp-c-brand-1);
12931345}
12941346
12951347.dropdown-group .tool-btn {
docs/.vitepress/theme/components/Search.vue +77 −16
@@ -356,16 +356,14 @@ watch(showSettingsPopup, (val) => {
356356 }
357357})
358358
359function toggleHelpSection(section: HelpSection, e: MouseEvent) {
360 if (activeHelpSection.value === section) {
361 activeHelpSection.value = null
362 helpPopupPos.value = { top: -9999, left: -9999 }
363 return
364 }
365 activeHelpSection.value = section
359const canHoverHelp = () =>
360 typeof window !== 'undefined' && window.matchMedia('(hover: hover)').matches
361
362function positionHelpPopup(btn: HTMLElement) {
366363 helpPopupPos.value = { top: -9999, left: -9999 }
367 const btn = e.currentTarget as HTMLElement
368364 const rect = btn.getBoundingClientRect()
365 // Anchor to the menu's left edge so the popup sits beside it, not over it.
366 const menuRect = settingsPopupRef.value?.getBoundingClientRect()
369367 nextTick(() => {
370368 const popupW = helpPopupEl.value?.offsetWidth || 260
371369 const popupH = helpPopupEl.value?.offsetHeight || 200
@@ -379,14 +377,46 @@ function toggleHelpSection(section: HelpSection, e: MouseEvent) {
379377 const left = Math.max(margin, Math.min((vw - popupW) / 2, vw - popupW - margin))
380378 helpPopupPos.value = { top, left }
381379 } else {
380 const anchorLeft = menuRect ? menuRect.left : rect.left
382381 helpPopupPos.value = {
383 left: Math.max(margin, rect.left - popupW - 16),
382 left: Math.max(margin, anchorLeft - popupW - 16),
384383 top: rect.top,
385384 }
386385 }
387386 })
388387}
389388
389function closeHelpSection() {
390 activeHelpSection.value = null
391 helpPopupPos.value = { top: -9999, left: -9999 }
392}
393
394function toggleHelpSection(section: HelpSection, e: MouseEvent) {
395 // Hover devices open/close via mouseenter/leave; touch devices toggle on tap.
396 if (canHoverHelp()) {
397 activeHelpSection.value = section
398 positionHelpPopup(e.currentTarget as HTMLElement)
399 return
400 }
401 if (activeHelpSection.value === section) {
402 closeHelpSection()
403 return
404 }
405 activeHelpSection.value = section
406 positionHelpPopup(e.currentTarget as HTMLElement)
407}
408
409function onHelpEnter(section: HelpSection, e: MouseEvent) {
410 if (!canHoverHelp()) return
411 activeHelpSection.value = section
412 positionHelpPopup(e.currentTarget as HTMLElement)
413}
414
415function onHelpLeave() {
416 if (!canHoverHelp()) return
417 closeHelpSection()
418}
419
390420const settingsPopupStyle = computed(() => ({
391421 top: `${settingsBounding.bottom.value + 8}px`,
392422 right: `calc(100vw - ${settingsBounding.right.value}px)`,
@@ -2577,11 +2607,16 @@ function onMouseMove(e: MouseEvent) {
25772607 :class="{ active: activeHelpSection === 'search' }"
25782608 aria-label="Search mode help"
25792609 @click.stop="toggleHelpSection('search', $event)"
2610 @mouseenter="onHelpEnter('search', $event)"
2611 @mouseleave="onHelpLeave"
25802612 >
25812613 <span class="i-carbon:help-filled settings-help-icon" />
25822614 </button>
25832615 </div>
2584 <div class="settings-options">
2616 <div
2617 class="settings-options"
2618 :class="{ 'is-highlighted': activeHelpSection === 'search' }"
2619 >
25852620 <button
25862621 type="button"
25872622 class="settings-option"
@@ -2623,11 +2658,16 @@ function onMouseMove(e: MouseEvent) {
26232658 :class="{ active: activeHelpSection === 'view' }"
26242659 aria-label="Result view help"
26252660 @click.stop="toggleHelpSection('view', $event)"
2661 @mouseenter="onHelpEnter('view', $event)"
2662 @mouseleave="onHelpLeave"
26262663 >
26272664 <span class="i-carbon:help-filled settings-help-icon" />
26282665 </button>
26292666 </div>
2630 <div class="settings-options">
2667 <div
2668 class="settings-options"
2669 :class="{ 'is-highlighted': activeHelpSection === 'view' }"
2670 >
26312671 <button
26322672 type="button"
26332673 class="settings-option"
@@ -2662,11 +2702,16 @@ function onMouseMove(e: MouseEvent) {
26622702 :class="{ active: activeHelpSection === 'preload' }"
26632703 aria-label="Excerpt preload help"
26642704 @click.stop="toggleHelpSection('preload', $event)"
2705 @mouseenter="onHelpEnter('preload', $event)"
2706 @mouseleave="onHelpLeave"
26652707 >
26662708 <span class="i-carbon:help-filled settings-help-icon" />
26672709 </button>
26682710 </div>
2669 <div class="settings-options">
2711 <div
2712 class="settings-options"
2713 :class="{ 'is-highlighted': activeHelpSection === 'preload' }"
2714 >
26702715 <button
26712716 type="button"
26722717 class="settings-option"
@@ -2705,11 +2750,16 @@ function onMouseMove(e: MouseEvent) {
27052750 :class="{ active: activeHelpSection === 'history' }"
27062751 aria-label="Search history help"
27072752 @click.stop="toggleHelpSection('history', $event)"
2753 @mouseenter="onHelpEnter('history', $event)"
2754 @mouseleave="onHelpLeave"
27082755 >
27092756 <span class="i-carbon:help-filled settings-help-icon" />
27102757 </button>
27112758 </div>
2712 <div class="settings-options">
2759 <div
2760 class="settings-options"
2761 :class="{ 'is-highlighted': activeHelpSection === 'history' }"
2762 >
27132763 <button
27142764 type="button"
27152765 class="settings-option"
@@ -3638,8 +3688,8 @@ html.effects-disabled .clear-button:active {
36383688
36393689.settings-help-icon {
36403690 display: block;
3641 width: 14px;
3642 height: 14px;
3691 width: 16px;
3692 height: 16px;
36433693}
36443694
36453695/* Help popup */
@@ -3699,11 +3749,15 @@ html.effects-disabled .clear-button:active {
36993749 display: flex;
37003750 flex-direction: column;
37013751 gap: 4px;
3702 background: var(--vp-c-bg-soft);
3752 background: #e8e6ec;
37033753 border-radius: 12px;
37043754 padding: 10px 12px;
37053755}
37063756
3757.dark .sh-option {
3758 background: #2c2c31;
3759}
3760
37073761.sh-option strong {
37083762 display: flex;
37093763 align-items: center;
@@ -3725,6 +3779,13 @@ html.effects-disabled .clear-button:active {
37253779 background: var(--seg-track);
37263780 border-radius: 8px;
37273781 padding: 4px;
3782 outline: 2px dashed transparent;
3783 outline-offset: 4px;
3784 transition: outline-color 0.2s ease;
3785}
3786
3787.settings-options.is-highlighted {
3788 outline-color: var(--vp-c-brand-1);
37283789}
37293790
37303791.settings-option {
docs/.vitepress/theme/components/settings/MenuHelp.vue +12 −2
@@ -28,6 +28,12 @@ watch(isHovered, (val) => {
2828const bounding = useElementBounding(menuTitleElementRef)
2929const popupBounding = useElementBounding(popupElementRef)
3030
31// Enclosing flyout panel — anchor the popup to its outer left edge.
32const menuPanelRef = computed(
33 () => (menuTitleElementRef.value?.closest('.VPMenu') as HTMLElement | null) ?? undefined
34)
35const menuBounding = useElementBounding(menuPanelRef)
36
3137const helpPopupStyle = computed(() => {
3238 const margin = 8
3339 const popupW = popupBounding.width.value
@@ -50,8 +56,11 @@ const helpPopupStyle = computed(() => {
5056 : Math.max(margin, vh - popupH - margin)
5157 left = Math.max(margin, Math.min((vw - popupW) / 2, vw - popupW - margin))
5258 } else {
53 // Desktop: place to the left of the menu title, aligned vertically
54 left = bounding.left.value - popupW - 16
59 // Desktop: place to the left of the menu panel, aligned vertically
60 const anchorLeft = menuBounding.width.value
61 ? menuBounding.left.value
62 : bounding.left.value
63 left = Math.max(margin, anchorLeft - popupW - 16)
5564 top = bounding.top.value
5665 }
5766
@@ -85,6 +94,7 @@ watch(
8594 () => {
8695 bounding.update()
8796 popupBounding.update()
97 menuBounding.update()
8898 },
8999 {
90100 flush: 'pre'