Commit 15682beef3

15682beef36539cf78cba398b73940dd28c58650

parent: d96aa184f5

Unsigned

Duck <57977673+woducku@users.noreply.github.com> · 2026-06-27 05:53 UTC

Add menu help

Layout: unified · split

docs/.vitepress/theme/components/Search.vue +283 −15
@@ -43,12 +43,15 @@ import {
43 ArrowRight, 43 ArrowRight,
44 ArrowRightToLine, 44 ArrowRightToLine,
45 ChevronRight, 45 ChevronRight,
46 Clock,
46 File, 47 File,
47 Globe, 48 Globe,
48 Hash, 49 Hash,
50 LayoutList,
49 List, 51 List,
50 LocateOff, 52 LocateOff,
51 Regex, 53 Regex,
54 Search,
52 Settings2, 55 Settings2,
53 TextAlignStart, 56 TextAlignStart,
54 X 57 X
@@ -336,6 +339,48 @@ const showSettingsPopup = ref(false)
336const settingsButtonRef = ref<HTMLButtonElement>() 339const settingsButtonRef = ref<HTMLButtonElement>()
337const settingsPopupRef = ref<HTMLDivElement>() 340const settingsPopupRef = ref<HTMLDivElement>()
338const settingsBounding = useElementBounding(settingsButtonRef) 341const settingsBounding = useElementBounding(settingsButtonRef)
342type HelpSection = 'search' | 'view' | 'history'
343const activeHelpSection = ref<HelpSection | null>(null)
344const helpPopupEl = ref<HTMLDivElement>()
345const helpPopupPos = ref({ top: -9999, left: -9999 })
346
347watch(showSettingsPopup, (val) => {
348 if (!val) {
349 activeHelpSection.value = null
350 helpPopupPos.value = { top: -9999, left: -9999 }
351 }
352})
353
354function toggleHelpSection(section: HelpSection, e: MouseEvent) {
355 if (activeHelpSection.value === section) {
356 activeHelpSection.value = null
357 helpPopupPos.value = { top: -9999, left: -9999 }
358 return
359 }
360 activeHelpSection.value = section
361 helpPopupPos.value = { top: -9999, left: -9999 }
362 const btn = e.currentTarget as HTMLElement
363 const rect = btn.getBoundingClientRect()
364 nextTick(() => {
365 const popupW = helpPopupEl.value?.offsetWidth || 260
366 const popupH = helpPopupEl.value?.offsetHeight || 200
367 const vw = window.innerWidth
368 const margin = 8
369 const isMobile = vw < 768
370 if (isMobile) {
371 const aboveTop = rect.top - popupH - margin
372 const belowTop = rect.bottom + margin
373 const top = aboveTop >= margin ? aboveTop : belowTop
374 const left = Math.max(margin, Math.min((vw - popupW) / 2, vw - popupW - margin))
375 helpPopupPos.value = { top, left }
376 } else {
377 helpPopupPos.value = {
378 left: Math.max(margin, rect.left - popupW - 16),
379 top: rect.top,
380 }
381 }
382 })
383}
339 384
340const settingsPopupStyle = computed(() => ({ 385const settingsPopupStyle = computed(() => ({
341 top: `${settingsBounding.bottom.value + 8}px`, 386 top: `${settingsBounding.bottom.value + 8}px`,
@@ -2348,9 +2393,24 @@ function onMouseMove(e: MouseEvent) {
2348 ref="settingsPopupRef" 2393 ref="settingsPopupRef"
2349 class="search-settings-popup" 2394 class="search-settings-popup"
2350 :style="settingsPopupStyle" 2395 :style="settingsPopupStyle"
2396 @click="activeHelpSection = null"
2351 > 2397 >
2352 <div class="settings-section"> 2398 <div class="settings-section">
2353 <div class="settings-section-label">Search</div> 2399 <div class="settings-section-header">
2400 <div class="settings-section-label">
2401 <Search :size="10" stroke-width="2.5" />
2402 Search
2403 </div>
2404 <button
2405 type="button"
2406 class="settings-help-btn"
2407 :class="{ active: activeHelpSection === 'search' }"
2408 aria-label="Search mode help"
2409 @click.stop="toggleHelpSection('search', $event)"
2410 >
2411 <span class="i-carbon:help-filled settings-help-icon" />
2412 </button>
2413 </div>
2354 <div class="settings-options"> 2414 <div class="settings-options">
2355 <button 2415 <button
2356 type="button" 2416 type="button"
@@ -2382,7 +2442,21 @@ function onMouseMove(e: MouseEvent) {
2382 v-if="!disableDetailedView && searchMode !== 'url'" 2442 v-if="!disableDetailedView && searchMode !== 'url'"
2383 class="settings-section" 2443 class="settings-section"
2384 > 2444 >
2385 <div class="settings-section-label">View</div> 2445 <div class="settings-section-header">
2446 <div class="settings-section-label">
2447 <LayoutList :size="10" stroke-width="2.5" />
2448 View
2449 </div>
2450 <button
2451 type="button"
2452 class="settings-help-btn"
2453 :class="{ active: activeHelpSection === 'view' }"
2454 aria-label="Result view help"
2455 @click.stop="toggleHelpSection('view', $event)"
2456 >
2457 <span class="i-carbon:help-filled settings-help-icon" />
2458 </button>
2459 </div>
2386 <div class="settings-options"> 2460 <div class="settings-options">
2387 <button 2461 <button
2388 type="button" 2462 type="button"
@@ -2403,7 +2477,21 @@ function onMouseMove(e: MouseEvent) {
2403 </div> 2477 </div>
2404 </div> 2478 </div>
2405 <div class="settings-section"> 2479 <div class="settings-section">
2406 <div class="settings-section-label">History</div> 2480 <div class="settings-section-header">
2481 <div class="settings-section-label">
2482 <Clock :size="10" stroke-width="2.5" />
2483 History
2484 </div>
2485 <button
2486 type="button"
2487 class="settings-help-btn"
2488 :class="{ active: activeHelpSection === 'history' }"
2489 aria-label="Search history help"
2490 @click.stop="toggleHelpSection('history', $event)"
2491 >
2492 <span class="i-carbon:help-filled settings-help-icon" />
2493 </button>
2494 </div>
2407 <div class="settings-options"> 2495 <div class="settings-options">
2408 <button 2496 <button
2409 type="button" 2497 type="button"
@@ -2425,6 +2513,75 @@ function onMouseMove(e: MouseEvent) {
2425 </div> 2513 </div>
2426 </div> 2514 </div>
2427 </Transition> 2515 </Transition>
2516 <Transition name="help-popup-fade">
2517 <div
2518 v-if="activeHelpSection && showSettingsPopup"
2519 ref="helpPopupEl"
2520 class="search-help-popup"
2521 :style="{ top: helpPopupPos.top + 'px', left: helpPopupPos.left + 'px' }"
2522 >
2523 <template v-if="activeHelpSection === 'search'">
2524 <h4 class="sh-title">
2525 <Search :size="14" stroke-width="1.75" class="sh-title-icon" />
2526 Search Mode
2527 </h4>
2528 <p class="sh-desc">Choose how queries are matched against content.</p>
2529 <div class="sh-options">
2530 <div class="sh-option">
2531 <strong>
2532 <Regex :size="12" stroke-width="1.5" />
2533 Exact
2534 </strong>
2535 <span>Matches the exact phrase you type</span>
2536 </div>
2537 <div class="sh-option">
2538 <strong>
2539 <LocateOff :size="12" stroke-width="1.5" />
2540 Fuzzy
2541 </strong>
2542 <span>Approximate matching that tolerates typos</span>
2543 </div>
2544 <div class="sh-option">
2545 <strong>
2546 <Globe :size="12" stroke-width="1.5" />
2547 URL
2548 </strong>
2549 <span>Searches page URLs and link destinations</span>
2550 </div>
2551 </div>
2552 </template>
2553 <template v-else-if="activeHelpSection === 'view'">
2554 <h4 class="sh-title">
2555 <LayoutList :size="14" stroke-width="1.75" class="sh-title-icon" />
2556 Result View
2557 </h4>
2558 <p class="sh-desc">Controls how search results are displayed.</p>
2559 <div class="sh-options">
2560 <div class="sh-option">
2561 <strong>
2562 <TextAlignStart :size="12" stroke-width="1.5" />
2563 Detail
2564 </strong>
2565 <span>Shows a content excerpt below each result. Uses more memory.</span>
2566 </div>
2567 <div class="sh-option">
2568 <strong>
2569 <List :size="12" stroke-width="1.5" />
2570 List
2571 </strong>
2572 <span>Compact list of titles only. Uses less memory.</span>
2573 </div>
2574 </div>
2575 </template>
2576 <template v-else-if="activeHelpSection === 'history'">
2577 <h4 class="sh-title">
2578 <Clock :size="14" stroke-width="1.75" class="sh-title-icon" />
2579 Search History
2580 </h4>
2581 <p class="sh-desc">Saves recent searches and shows them when the search bar is empty.</p>
2582 </template>
2583 </div>
2584 </Transition>
2428 </Teleport> 2585 </Teleport>
2429 </component> 2586 </component>
2430 </AnimatePresence> 2587 </AnimatePresence>
@@ -3142,38 +3299,149 @@ svg {
3142 z-index: 200; 3299 z-index: 200;
3143 background: var(--vp-c-bg); 3300 background: var(--vp-c-bg);
3144 border: 1px solid var(--vp-c-divider); 3301 border: 1px solid var(--vp-c-divider);
3145 border-radius: 10px; 3302 border-radius: 12px;
3146 padding: 10px; 3303 padding: 14px;
3147 box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25); 3304 box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
3148 display: flex; 3305 display: flex;
3149 flex-direction: column; 3306 flex-direction: column;
3150 min-width: 196px; 3307 min-width: 224px;
3151} 3308}
3152 3309
3153.settings-section { 3310.settings-section {
3154 display: flex; 3311 display: flex;
3155 flex-direction: column; 3312 flex-direction: column;
3156 gap: 6px; 3313 gap: 8px;
3157} 3314}
3158 3315
3159.settings-section + .settings-section { 3316.settings-section + .settings-section {
3160 border-top: 1px solid var(--vp-c-divider); 3317 border-top: 1px solid var(--vp-c-divider);
3161 margin-top: 8px; 3318 margin-top: 10px;
3162 padding-top: 8px; 3319 padding-top: 10px;
3320}
3321
3322.settings-section-header {
3323 display: flex;
3324 align-items: center;
3325 justify-content: space-between;
3326 margin-bottom: 2px;
3163} 3327}
3164 3328
3165.settings-section-label { 3329.settings-section-label {
3166 font-size: 11px; 3330 display: flex;
3331 align-items: center;
3332 gap: 4px;
3333 font-size: 11.5px;
3167 font-weight: 600; 3334 font-weight: 600;
3168 text-transform: uppercase; 3335 text-transform: uppercase;
3169 letter-spacing: 0.06em; 3336 letter-spacing: 0.06em;
3170 color: var(--vp-c-text-3, var(--vp-c-text-2)); 3337 color: var(--vp-c-text-3, var(--vp-c-text-2));
3171 margin-bottom: 2px; 3338}
3339
3340.settings-help-btn {
3341 display: flex;
3342 align-items: center;
3343 justify-content: center;
3344 padding: 3px;
3345 background: transparent;
3346 border: none;
3347 cursor: pointer;
3348 color: var(--vp-c-text-3);
3349 opacity: 0.5;
3350 transition: opacity 0.15s, color 0.15s;
3351 border-radius: 3px;
3352 line-height: 1;
3353}
3354
3355.settings-help-btn:hover,
3356.settings-help-btn.active {
3357 opacity: 1;
3358 color: var(--vp-c-text-1);
3359}
3360
3361.settings-help-icon {
3362 display: block;
3363 width: 14px;
3364 height: 14px;
3365}
3366
3367/* Help popup */
3368.search-help-popup {
3369 position: fixed;
3370 z-index: 9999;
3371 width: 260px;
3372 background: var(--vp-c-bg-elv);
3373 border: 1px solid var(--vp-c-divider);
3374 border-radius: 12px;
3375 padding: 16px;
3376 box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
3377 pointer-events: none;
3378}
3379
3380.help-popup-fade-enter-active,
3381.help-popup-fade-leave-active {
3382 transition: opacity 0.15s ease;
3383}
3384
3385.help-popup-fade-enter-from,
3386.help-popup-fade-leave-to {
3387 opacity: 0;
3388}
3389
3390.sh-title {
3391 display: flex;
3392 align-items: center;
3393 gap: 6px;
3394 font-size: 0.875rem;
3395 font-weight: 600;
3396 color: var(--vp-c-text-1);
3397 margin: 0 0 6px;
3398}
3399
3400.sh-title-icon {
3401 flex-shrink: 0;
3402 opacity: 0.8;
3403}
3404
3405.sh-desc {
3406 font-size: 0.78rem;
3407 color: var(--vp-c-text-2);
3408 margin: 0 0 10px;
3409 line-height: 1.5;
3410}
3411
3412.sh-options {
3413 display: flex;
3414 flex-direction: column;
3415 gap: 5px;
3416}
3417
3418.sh-option {
3419 display: flex;
3420 flex-direction: column;
3421 gap: 2px;
3422 background: var(--vp-c-bg-soft);
3423 border-radius: 6px;
3424 padding: 7px 9px;
3425}
3426
3427.sh-option strong {
3428 display: flex;
3429 align-items: center;
3430 gap: 5px;
3431 font-size: 0.78rem;
3432 font-weight: 600;
3433 color: var(--vp-c-text-1);
3434}
3435
3436.sh-option span {
3437 font-size: 0.74rem;
3438 color: var(--vp-c-text-2);
3439 line-height: 1.4;
3172} 3440}
3173 3441
3174.settings-options { 3442.settings-options {
3175 display: flex; 3443 display: flex;
3176 gap: 4px; 3444 gap: 5px;
3177} 3445}
3178 3446
3179.settings-option { 3447.settings-option {
@@ -3181,13 +3449,13 @@ svg {
3181 align-items: center; 3449 align-items: center;
3182 justify-content: center; 3450 justify-content: center;
3183 gap: 5px; 3451 gap: 5px;
3184 padding: 5px 6px; 3452 padding: 7px 8px;
3185 background: transparent; 3453 background: transparent;
3186 border: none; 3454 border: none;
3187 border-radius: 5px; 3455 border-radius: 6px;
3188 cursor: pointer; 3456 cursor: pointer;
3189 color: var(--vp-c-text-2); 3457 color: var(--vp-c-text-2);
3190 font-size: 14px; 3458 font-size: 14.5px;
3191 font-weight: 500; 3459 font-weight: 500;
3192 transition: background-color 0.15s, color 0.15s; 3460 transition: background-color 0.15s, color 0.15s;
3193 flex: 1; 3461 flex: 1;