Commit e8e1248194
Unsigned
Layout: unified · split
docs/.vitepress/theme/components/HomeFeatures.vue +73 −21
| @@ -89,6 +89,7 @@ const dropdownOpen = ref(false) | |||
| 89 | type HelpSection = 'view' | 'columns' | 89 | type HelpSection = 'view' | 'columns' |
| 90 | const activeHelpSection = ref<HelpSection | null>(null) | 90 | const activeHelpSection = ref<HelpSection | null>(null) |
| 91 | const helpPopupEl = ref<HTMLDivElement | null>(null) | 91 | const helpPopupEl = ref<HTMLDivElement | null>(null) |
| 92 | const settingsDropdownEl = ref<HTMLDivElement | null>(null) | ||
| 92 | const helpPopupPos = ref({ top: -9999, left: -9999 }) | 93 | const helpPopupPos = ref({ top: -9999, left: -9999 }) |
| 93 | 94 | ||
| 94 | watch(dropdownOpen, (val) => { | 95 | watch(dropdownOpen, (val) => { |
| @@ -98,27 +99,67 @@ watch(dropdownOpen, (val) => { | |||
| 98 | } | 99 | } |
| 99 | }) | 100 | }) |
| 100 | 101 | ||
| 101 | function toggleHelpSection(section: HelpSection, e: MouseEvent) { | 102 | const canHoverHelp = () => |
| 102 | if (activeHelpSection.value === section) { | 103 | typeof window !== 'undefined' && window.matchMedia('(hover: hover)').matches |
| 103 | activeHelpSection.value = null | 104 | |
| 104 | helpPopupPos.value = { top: -9999, left: -9999 } | 105 | function positionHelpPopup(btn: HTMLElement) { |
| 105 | return | ||
| 106 | } | ||
| 107 | activeHelpSection.value = section | ||
| 108 | helpPopupPos.value = { top: -9999, left: -9999 } | 106 | helpPopupPos.value = { top: -9999, left: -9999 } |
| 109 | const btn = e.currentTarget as HTMLElement | ||
| 110 | const rect = btn.getBoundingClientRect() | 107 | 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() | ||
| 111 | nextTick(() => { | 110 | nextTick(() => { |
| 112 | const popupW = helpPopupEl.value?.offsetWidth || 220 | 111 | const popupW = helpPopupEl.value?.offsetWidth || 260 |
| 113 | const popupH = helpPopupEl.value?.offsetHeight || 160 | 112 | const popupH = helpPopupEl.value?.offsetHeight || 200 |
| 113 | const vw = window.innerWidth | ||
| 114 | const margin = 8 | 114 | const margin = 8 |
| 115 | helpPopupPos.value = { | 115 | const isMobile = vw < 768 |
| 116 | left: Math.max(margin, rect.left - popupW - 8), | 116 | if (isMobile) { |
| 117 | top: Math.max(margin, Math.min(rect.top, window.innerHeight - popupH - margin)), | 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 | } | ||
| 118 | } | 128 | } |
| 119 | }) | 129 | }) |
| 120 | } | 130 | } |
| 121 | 131 | ||
| 132 | function closeHelpSection() { | ||
| 133 | activeHelpSection.value = null | ||
| 134 | helpPopupPos.value = { top: -9999, left: -9999 } | ||
| 135 | } | ||
| 136 | |||
| 137 | function 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 | |||
| 152 | function onHelpEnter(section: HelpSection, e: MouseEvent) { | ||
| 153 | if (!canHoverHelp()) return | ||
| 154 | activeHelpSection.value = section | ||
| 155 | positionHelpPopup(e.currentTarget as HTMLElement) | ||
| 156 | } | ||
| 157 | |||
| 158 | function onHelpLeave() { | ||
| 159 | if (!canHoverHelp()) return | ||
| 160 | closeHelpSection() | ||
| 161 | } | ||
| 162 | |||
| 122 | watch(panelOpen, (open) => { | 163 | watch(panelOpen, (open) => { |
| 123 | if (typeof document !== 'undefined') | 164 | if (typeof document !== 'undefined') |
| 124 | document.body.style.overflow = open ? 'hidden' : '' | 165 | document.body.style.overflow = open ? 'hidden' : '' |
| @@ -387,18 +428,18 @@ function onHandlePointerUp() { | |||
| 387 | <div class="foot-group"> | 428 | <div class="foot-group"> |
| 388 | <div class="settings-wrap"> | 429 | <div class="settings-wrap"> |
| 389 | <div v-if="dropdownOpen" class="dropdown-overlay" @click="dropdownOpen = false" /> | 430 | <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"> |
| 391 | <div class="dropdown-section"> | 432 | <div class="dropdown-section"> |
| 392 | <div class="dropdown-section-header"> | 433 | <div class="dropdown-section-header"> |
| 393 | <span class="dropdown-label"> | 434 | <span class="dropdown-label"> |
| 394 | <span class="i-lucide-layout-list dropdown-label-icon" /> | 435 | <span class="i-lucide-layout-list dropdown-label-icon" /> |
| 395 | View | 436 | View |
| 396 | </span> | 437 | </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"> |
| 398 | <span class="i-carbon:help-filled settings-help-icon" /> | 439 | <span class="i-carbon:help-filled settings-help-icon" /> |
| 399 | </button> | 440 | </button> |
| 400 | </div> | 441 | </div> |
| 401 | <div class="dropdown-group"> | 442 | <div class="dropdown-group" :class="{ 'is-highlighted': activeHelpSection === 'view' }"> |
| 402 | <button class="tool-btn" :class="{ 'is-active': viewMode === 'default' }" @click="viewMode = 'default'">Default</button> | 443 | <button class="tool-btn" :class="{ 'is-active': viewMode === 'default' }" @click="viewMode = 'default'">Default</button> |
| 403 | <button class="tool-btn" :class="{ 'is-active': viewMode === 'mini' }" @click="viewMode = 'mini'">Mini</button> | 444 | <button class="tool-btn" :class="{ 'is-active': viewMode === 'mini' }" @click="viewMode = 'mini'">Mini</button> |
| 404 | </div> | 445 | </div> |
| @@ -409,11 +450,11 @@ function onHandlePointerUp() { | |||
| 409 | <span class="i-lucide-columns-3-cog dropdown-label-icon" /> | 450 | <span class="i-lucide-columns-3-cog dropdown-label-icon" /> |
| 410 | Columns | 451 | Columns |
| 411 | </span> | 452 | </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"> |
| 413 | <span class="i-carbon:help-filled settings-help-icon" /> | 454 | <span class="i-carbon:help-filled settings-help-icon" /> |
| 414 | </button> | 455 | </button> |
| 415 | </div> | 456 | </div> |
| 416 | <div class="dropdown-group"> | 457 | <div class="dropdown-group" :class="{ 'is-highlighted': activeHelpSection === 'columns' }"> |
| 417 | <button class="tool-btn" :class="{ 'is-active': columnMode === 'default' }" @click="columnMode = 'default'">Default</button> | 458 | <button class="tool-btn" :class="{ 'is-active': columnMode === 'default' }" @click="columnMode = 'default'">Default</button> |
| 418 | <button class="tool-btn" :class="{ 'is-active': columnMode === 'max' }" @click="columnMode = 'max'">Max</button> | 459 | <button class="tool-btn" :class="{ 'is-active': columnMode === 'max' }" @click="columnMode = 'max'">Max</button> |
| 419 | </div> | 460 | </div> |
| @@ -1141,8 +1182,8 @@ html.effects-disabled .row-toggle:active { | |||
| 1141 | 1182 | ||
| 1142 | .settings-help-icon { | 1183 | .settings-help-icon { |
| 1143 | display: block; | 1184 | display: block; |
| 1144 | width: 14px; | 1185 | width: 16px; |
| 1145 | height: 14px; | 1186 | height: 16px; |
| 1146 | } | 1187 | } |
| 1147 | 1188 | ||
| 1148 | .home-help-popup { | 1189 | .home-help-popup { |
| @@ -1201,11 +1242,15 @@ html.effects-disabled .row-toggle:active { | |||
| 1201 | display: flex; | 1242 | display: flex; |
| 1202 | flex-direction: column; | 1243 | flex-direction: column; |
| 1203 | gap: 4px; | 1244 | gap: 4px; |
| 1204 | background: var(--vp-c-bg-soft); | 1245 | background: #e8e6ec; |
| 1205 | border-radius: 12px; | 1246 | border-radius: 12px; |
| 1206 | padding: 10px 12px; | 1247 | padding: 10px 12px; |
| 1207 | } | 1248 | } |
| 1208 | 1249 | ||
| 1250 | .dark .sh-option { | ||
| 1251 | background: #2c2c31; | ||
| 1252 | } | ||
| 1253 | |||
| 1209 | .sh-option strong { | 1254 | .sh-option strong { |
| 1210 | display: flex; | 1255 | display: flex; |
| 1211 | align-items: center; | 1256 | align-items: center; |
| @@ -1290,6 +1335,13 @@ html.effects-disabled .row-toggle:active { | |||
| 1290 | background: var(--seg-track); | 1335 | background: var(--seg-track); |
| 1291 | border-radius: 8px; | 1336 | border-radius: 8px; |
| 1292 | padding: 4px; | 1337 | 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); | ||
| 1293 | } | 1345 | } |
| 1294 | 1346 | ||
| 1295 | .dropdown-group .tool-btn { | 1347 | .dropdown-group .tool-btn { |
docs/.vitepress/theme/components/Search.vue +77 −16
| @@ -356,16 +356,14 @@ watch(showSettingsPopup, (val) => { | |||
| 356 | } | 356 | } |
| 357 | }) | 357 | }) |
| 358 | 358 | ||
| 359 | function toggleHelpSection(section: HelpSection, e: MouseEvent) { | 359 | const canHoverHelp = () => |
| 360 | if (activeHelpSection.value === section) { | 360 | typeof window !== 'undefined' && window.matchMedia('(hover: hover)').matches |
| 361 | activeHelpSection.value = null | 361 | |
| 362 | helpPopupPos.value = { top: -9999, left: -9999 } | 362 | function positionHelpPopup(btn: HTMLElement) { |
| 363 | return | ||
| 364 | } | ||
| 365 | activeHelpSection.value = section | ||
| 366 | helpPopupPos.value = { top: -9999, left: -9999 } | 363 | helpPopupPos.value = { top: -9999, left: -9999 } |
| 367 | const btn = e.currentTarget as HTMLElement | ||
| 368 | const rect = btn.getBoundingClientRect() | 364 | 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() | ||
| 369 | nextTick(() => { | 367 | nextTick(() => { |
| 370 | const popupW = helpPopupEl.value?.offsetWidth || 260 | 368 | const popupW = helpPopupEl.value?.offsetWidth || 260 |
| 371 | const popupH = helpPopupEl.value?.offsetHeight || 200 | 369 | const popupH = helpPopupEl.value?.offsetHeight || 200 |
| @@ -379,14 +377,46 @@ function toggleHelpSection(section: HelpSection, e: MouseEvent) { | |||
| 379 | const left = Math.max(margin, Math.min((vw - popupW) / 2, vw - popupW - margin)) | 377 | const left = Math.max(margin, Math.min((vw - popupW) / 2, vw - popupW - margin)) |
| 380 | helpPopupPos.value = { top, left } | 378 | helpPopupPos.value = { top, left } |
| 381 | } else { | 379 | } else { |
| 380 | const anchorLeft = menuRect ? menuRect.left : rect.left | ||
| 382 | helpPopupPos.value = { | 381 | helpPopupPos.value = { |
| 383 | left: Math.max(margin, rect.left - popupW - 16), | 382 | left: Math.max(margin, anchorLeft - popupW - 16), |
| 384 | top: rect.top, | 383 | top: rect.top, |
| 385 | } | 384 | } |
| 386 | } | 385 | } |
| 387 | }) | 386 | }) |
| 388 | } | 387 | } |
| 389 | 388 | ||
| 389 | function closeHelpSection() { | ||
| 390 | activeHelpSection.value = null | ||
| 391 | helpPopupPos.value = { top: -9999, left: -9999 } | ||
| 392 | } | ||
| 393 | |||
| 394 | function 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 | |||
| 409 | function onHelpEnter(section: HelpSection, e: MouseEvent) { | ||
| 410 | if (!canHoverHelp()) return | ||
| 411 | activeHelpSection.value = section | ||
| 412 | positionHelpPopup(e.currentTarget as HTMLElement) | ||
| 413 | } | ||
| 414 | |||
| 415 | function onHelpLeave() { | ||
| 416 | if (!canHoverHelp()) return | ||
| 417 | closeHelpSection() | ||
| 418 | } | ||
| 419 | |||
| 390 | const settingsPopupStyle = computed(() => ({ | 420 | const settingsPopupStyle = computed(() => ({ |
| 391 | top: `${settingsBounding.bottom.value + 8}px`, | 421 | top: `${settingsBounding.bottom.value + 8}px`, |
| 392 | right: `calc(100vw - ${settingsBounding.right.value}px)`, | 422 | right: `calc(100vw - ${settingsBounding.right.value}px)`, |
| @@ -2577,11 +2607,16 @@ function onMouseMove(e: MouseEvent) { | |||
| 2577 | :class="{ active: activeHelpSection === 'search' }" | 2607 | :class="{ active: activeHelpSection === 'search' }" |
| 2578 | aria-label="Search mode help" | 2608 | aria-label="Search mode help" |
| 2579 | @click.stop="toggleHelpSection('search', $event)" | 2609 | @click.stop="toggleHelpSection('search', $event)" |
| 2610 | @mouseenter="onHelpEnter('search', $event)" | ||
| 2611 | @mouseleave="onHelpLeave" | ||
| 2580 | > | 2612 | > |
| 2581 | <span class="i-carbon:help-filled settings-help-icon" /> | 2613 | <span class="i-carbon:help-filled settings-help-icon" /> |
| 2582 | </button> | 2614 | </button> |
| 2583 | </div> | 2615 | </div> |
| 2584 | <div class="settings-options"> | 2616 | <div |
| 2617 | class="settings-options" | ||
| 2618 | :class="{ 'is-highlighted': activeHelpSection === 'search' }" | ||
| 2619 | > | ||
| 2585 | <button | 2620 | <button |
| 2586 | type="button" | 2621 | type="button" |
| 2587 | class="settings-option" | 2622 | class="settings-option" |
| @@ -2623,11 +2658,16 @@ function onMouseMove(e: MouseEvent) { | |||
| 2623 | :class="{ active: activeHelpSection === 'view' }" | 2658 | :class="{ active: activeHelpSection === 'view' }" |
| 2624 | aria-label="Result view help" | 2659 | aria-label="Result view help" |
| 2625 | @click.stop="toggleHelpSection('view', $event)" | 2660 | @click.stop="toggleHelpSection('view', $event)" |
| 2661 | @mouseenter="onHelpEnter('view', $event)" | ||
| 2662 | @mouseleave="onHelpLeave" | ||
| 2626 | > | 2663 | > |
| 2627 | <span class="i-carbon:help-filled settings-help-icon" /> | 2664 | <span class="i-carbon:help-filled settings-help-icon" /> |
| 2628 | </button> | 2665 | </button> |
| 2629 | </div> | 2666 | </div> |
| 2630 | <div class="settings-options"> | 2667 | <div |
| 2668 | class="settings-options" | ||
| 2669 | :class="{ 'is-highlighted': activeHelpSection === 'view' }" | ||
| 2670 | > | ||
| 2631 | <button | 2671 | <button |
| 2632 | type="button" | 2672 | type="button" |
| 2633 | class="settings-option" | 2673 | class="settings-option" |
| @@ -2662,11 +2702,16 @@ function onMouseMove(e: MouseEvent) { | |||
| 2662 | :class="{ active: activeHelpSection === 'preload' }" | 2702 | :class="{ active: activeHelpSection === 'preload' }" |
| 2663 | aria-label="Excerpt preload help" | 2703 | aria-label="Excerpt preload help" |
| 2664 | @click.stop="toggleHelpSection('preload', $event)" | 2704 | @click.stop="toggleHelpSection('preload', $event)" |
| 2705 | @mouseenter="onHelpEnter('preload', $event)" | ||
| 2706 | @mouseleave="onHelpLeave" | ||
| 2665 | > | 2707 | > |
| 2666 | <span class="i-carbon:help-filled settings-help-icon" /> | 2708 | <span class="i-carbon:help-filled settings-help-icon" /> |
| 2667 | </button> | 2709 | </button> |
| 2668 | </div> | 2710 | </div> |
| 2669 | <div class="settings-options"> | 2711 | <div |
| 2712 | class="settings-options" | ||
| 2713 | :class="{ 'is-highlighted': activeHelpSection === 'preload' }" | ||
| 2714 | > | ||
| 2670 | <button | 2715 | <button |
| 2671 | type="button" | 2716 | type="button" |
| 2672 | class="settings-option" | 2717 | class="settings-option" |
| @@ -2705,11 +2750,16 @@ function onMouseMove(e: MouseEvent) { | |||
| 2705 | :class="{ active: activeHelpSection === 'history' }" | 2750 | :class="{ active: activeHelpSection === 'history' }" |
| 2706 | aria-label="Search history help" | 2751 | aria-label="Search history help" |
| 2707 | @click.stop="toggleHelpSection('history', $event)" | 2752 | @click.stop="toggleHelpSection('history', $event)" |
| 2753 | @mouseenter="onHelpEnter('history', $event)" | ||
| 2754 | @mouseleave="onHelpLeave" | ||
| 2708 | > | 2755 | > |
| 2709 | <span class="i-carbon:help-filled settings-help-icon" /> | 2756 | <span class="i-carbon:help-filled settings-help-icon" /> |
| 2710 | </button> | 2757 | </button> |
| 2711 | </div> | 2758 | </div> |
| 2712 | <div class="settings-options"> | 2759 | <div |
| 2760 | class="settings-options" | ||
| 2761 | :class="{ 'is-highlighted': activeHelpSection === 'history' }" | ||
| 2762 | > | ||
| 2713 | <button | 2763 | <button |
| 2714 | type="button" | 2764 | type="button" |
| 2715 | class="settings-option" | 2765 | class="settings-option" |
| @@ -3638,8 +3688,8 @@ html.effects-disabled .clear-button:active { | |||
| 3638 | 3688 | ||
| 3639 | .settings-help-icon { | 3689 | .settings-help-icon { |
| 3640 | display: block; | 3690 | display: block; |
| 3641 | width: 14px; | 3691 | width: 16px; |
| 3642 | height: 14px; | 3692 | height: 16px; |
| 3643 | } | 3693 | } |
| 3644 | 3694 | ||
| 3645 | /* Help popup */ | 3695 | /* Help popup */ |
| @@ -3699,11 +3749,15 @@ html.effects-disabled .clear-button:active { | |||
| 3699 | display: flex; | 3749 | display: flex; |
| 3700 | flex-direction: column; | 3750 | flex-direction: column; |
| 3701 | gap: 4px; | 3751 | gap: 4px; |
| 3702 | background: var(--vp-c-bg-soft); | 3752 | background: #e8e6ec; |
| 3703 | border-radius: 12px; | 3753 | border-radius: 12px; |
| 3704 | padding: 10px 12px; | 3754 | padding: 10px 12px; |
| 3705 | } | 3755 | } |
| 3706 | 3756 | ||
| 3757 | .dark .sh-option { | ||
| 3758 | background: #2c2c31; | ||
| 3759 | } | ||
| 3760 | |||
| 3707 | .sh-option strong { | 3761 | .sh-option strong { |
| 3708 | display: flex; | 3762 | display: flex; |
| 3709 | align-items: center; | 3763 | align-items: center; |
| @@ -3725,6 +3779,13 @@ html.effects-disabled .clear-button:active { | |||
| 3725 | background: var(--seg-track); | 3779 | background: var(--seg-track); |
| 3726 | border-radius: 8px; | 3780 | border-radius: 8px; |
| 3727 | padding: 4px; | 3781 | 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); | ||
| 3728 | } | 3789 | } |
| 3729 | 3790 | ||
| 3730 | .settings-option { | 3791 | .settings-option { |
docs/.vitepress/theme/components/settings/MenuHelp.vue +12 −2
| @@ -28,6 +28,12 @@ watch(isHovered, (val) => { | |||
| 28 | const bounding = useElementBounding(menuTitleElementRef) | 28 | const bounding = useElementBounding(menuTitleElementRef) |
| 29 | const popupBounding = useElementBounding(popupElementRef) | 29 | const popupBounding = useElementBounding(popupElementRef) |
| 30 | 30 | ||
| 31 | // Enclosing flyout panel — anchor the popup to its outer left edge. | ||
| 32 | const menuPanelRef = computed( | ||
| 33 | () => (menuTitleElementRef.value?.closest('.VPMenu') as HTMLElement | null) ?? undefined | ||
| 34 | ) | ||
| 35 | const menuBounding = useElementBounding(menuPanelRef) | ||
| 36 | |||
| 31 | const helpPopupStyle = computed(() => { | 37 | const helpPopupStyle = computed(() => { |
| 32 | const margin = 8 | 38 | const margin = 8 |
| 33 | const popupW = popupBounding.width.value | 39 | const popupW = popupBounding.width.value |
| @@ -50,8 +56,11 @@ const helpPopupStyle = computed(() => { | |||
| 50 | : Math.max(margin, vh - popupH - margin) | 56 | : Math.max(margin, vh - popupH - margin) |
| 51 | left = Math.max(margin, Math.min((vw - popupW) / 2, vw - popupW - margin)) | 57 | left = Math.max(margin, Math.min((vw - popupW) / 2, vw - popupW - margin)) |
| 52 | } else { | 58 | } else { |
| 53 | // Desktop: place to the left of the menu title, aligned vertically | 59 | // Desktop: place to the left of the menu panel, aligned vertically |
| 54 | left = bounding.left.value - popupW - 16 | 60 | const anchorLeft = menuBounding.width.value |
| 61 | ? menuBounding.left.value | ||
| 62 | : bounding.left.value | ||
| 63 | left = Math.max(margin, anchorLeft - popupW - 16) | ||
| 55 | top = bounding.top.value | 64 | top = bounding.top.value |
| 56 | } | 65 | } |
| 57 | 66 | ||
| @@ -85,6 +94,7 @@ watch( | |||
| 85 | () => { | 94 | () => { |
| 86 | bounding.update() | 95 | bounding.update() |
| 87 | popupBounding.update() | 96 | popupBounding.update() |
| 97 | menuBounding.update() | ||
| 88 | }, | 98 | }, |
| 89 | { | 99 | { |
| 90 | flush: 'pre' | 100 | flush: 'pre' |