Commit 97d4ffe9ee

97d4ffe9ee76bf6f0658399bbf47533d5090ce63

parent: b10fadbbcc

Unsigned

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

Update HomeFeatures.vue

Layout: unified · split

docs/.vitepress/theme/components/HomeFeatures.vue +214 −6
@@ -1,5 +1,6 @@
11<script setup lang="ts">
2import { computed, onMounted, ref, watch } from 'vue'
2import { computed, nextTick, onMounted, ref, watch } from 'vue'
3import { Columns3, LayoutList } from 'lucide-vue-next'
34import type { HomeCard } from '../../configs/constants'
45
56const props = defineProps<{ cards: HomeCard[] }>()
@@ -85,6 +86,39 @@ function cardIcon(card: HomeCard) {
8586const panelOpen = ref(false)
8687const dropdownOpen = ref(false)
8788
89type HelpSection = 'view' | 'columns'
90const activeHelpSection = ref<HelpSection | null>(null)
91const helpPopupEl = ref<HTMLDivElement | null>(null)
92const helpPopupPos = ref({ top: -9999, left: -9999 })
93
94watch(dropdownOpen, (val) => {
95 if (!val) {
96 activeHelpSection.value = null
97 helpPopupPos.value = { top: -9999, left: -9999 }
98 }
99})
100
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
108 helpPopupPos.value = { top: -9999, left: -9999 }
109 const btn = e.currentTarget as HTMLElement
110 const rect = btn.getBoundingClientRect()
111 nextTick(() => {
112 const popupW = helpPopupEl.value?.offsetWidth || 220
113 const popupH = helpPopupEl.value?.offsetHeight || 160
114 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)),
118 }
119 })
120}
121
88122watch(panelOpen, (open) => {
89123 if (typeof document !== 'undefined')
90124 document.body.style.overflow = open ? 'hidden' : ''
@@ -339,14 +373,30 @@ function onHandlePointerUp() {
339373 <div v-if="dropdownOpen" class="dropdown-overlay" @click="dropdownOpen = false" />
340374 <div v-if="dropdownOpen" class="settings-dropdown">
341375 <div class="dropdown-section">
342 <span class="dropdown-label">View</span>
376 <div class="dropdown-section-header">
377 <span class="dropdown-label">
378 <LayoutList :size="10" stroke-width="2.5" />
379 View
380 </span>
381 <button type="button" class="settings-help-btn" :class="{ active: activeHelpSection === 'view' }" aria-label="View help" @click.stop="toggleHelpSection('view', $event)">
382 <span class="i-carbon:help-filled settings-help-icon" />
383 </button>
384 </div>
343385 <div class="dropdown-group">
344386 <button class="tool-btn" :class="{ 'is-active': viewMode === 'default' }" @click="viewMode = 'default'">Default</button>
345387 <button class="tool-btn" :class="{ 'is-active': viewMode === 'mini' }" @click="viewMode = 'mini'">Mini</button>
346388 </div>
347389 </div>
348390 <div class="dropdown-section">
349 <span class="dropdown-label">Columns</span>
391 <div class="dropdown-section-header">
392 <span class="dropdown-label">
393 <Columns3 :size="10" stroke-width="2.5" />
394 Columns
395 </span>
396 <button type="button" class="settings-help-btn" :class="{ active: activeHelpSection === 'columns' }" aria-label="Columns help" @click.stop="toggleHelpSection('columns', $event)">
397 <span class="i-carbon:help-filled settings-help-icon" />
398 </button>
399 </div>
350400 <div class="dropdown-group">
351401 <button class="tool-btn" :class="{ 'is-active': columnMode === 'default' }" @click="columnMode = 'default'">Default</button>
352402 <button class="tool-btn" :class="{ 'is-active': columnMode === 'max' }" @click="columnMode = 'max'">Max</button>
@@ -378,6 +428,50 @@ function onHandlePointerUp() {
378428 :style="{ left: cardTooltip.x + 'px', top: cardTooltip.y + 'px' }"
379429 >{{ cardTooltip.text }}</div>
380430
431 <Transition name="help-popup-fade">
432 <div
433 v-if="activeHelpSection && dropdownOpen"
434 ref="helpPopupEl"
435 class="home-help-popup"
436 :style="{ top: helpPopupPos.top + 'px', left: helpPopupPos.left + 'px' }"
437 >
438 <template v-if="activeHelpSection === 'view'">
439 <h4 class="sh-title">
440 <span class="i-lucide-layout-list sh-title-icon" />
441 View
442 </h4>
443 <p class="sh-desc">Controls how cards are displayed on the homepage.</p>
444 <div class="sh-options">
445 <div class="sh-option">
446 <strong>Default</strong>
447 <span>Full card with icon, title, and description.</span>
448 </div>
449 <div class="sh-option">
450 <strong>Mini</strong>
451 <span>Compact row with icon and title only.</span>
452 </div>
453 </div>
454 </template>
455 <template v-else-if="activeHelpSection === 'columns'">
456 <h4 class="sh-title">
457 <span class="i-lucide-columns-3 sh-title-icon" />
458 Columns
459 </h4>
460 <p class="sh-desc">Controls how many columns the card grid uses.</p>
461 <div class="sh-options">
462 <div class="sh-option">
463 <strong>Default</strong>
464 <span>Adapts automatically based on the number of cards.</span>
465 </div>
466 <div class="sh-option">
467 <strong>Max</strong>
468 <span>Always uses the maximum number of columns based on screen resolution.</span>
469 </div>
470 </div>
471 </template>
472 </div>
473 </Transition>
474
381475 <Transition name="ghost-fade">
382476 <div
383477 v-if="dragging && ghostPos"
@@ -912,6 +1006,118 @@ function onHandlePointerUp() {
9121006 background: var(--vp-c-brand-soft);
9131007}
9141008
1009/* ── Settings Help ── */
1010.dropdown-section-header {
1011 display: flex;
1012 align-items: center;
1013 justify-content: space-between;
1014 margin-bottom: 6px;
1015}
1016
1017.dropdown-section-header .dropdown-label {
1018 margin-bottom: 0;
1019}
1020
1021.settings-help-btn {
1022 display: flex;
1023 align-items: center;
1024 justify-content: center;
1025 padding: 3px;
1026 background: transparent;
1027 border: none;
1028 cursor: pointer;
1029 color: var(--vp-c-text-3);
1030 opacity: 0.5;
1031 transition: opacity 0.15s, color 0.15s;
1032 border-radius: 3px;
1033 line-height: 1;
1034}
1035
1036.settings-help-btn:hover,
1037.settings-help-btn.active {
1038 opacity: 1;
1039 color: var(--vp-c-text-1);
1040}
1041
1042.settings-help-icon {
1043 display: block;
1044 width: 14px;
1045 height: 14px;
1046}
1047
1048.home-help-popup {
1049 position: fixed;
1050 z-index: 9999;
1051 width: 220px;
1052 background: var(--vp-c-bg-elv);
1053 border: 1px solid var(--vp-c-divider);
1054 border-radius: 12px;
1055 padding: 16px;
1056 box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
1057 pointer-events: none;
1058}
1059
1060.help-popup-fade-enter-active,
1061.help-popup-fade-leave-active {
1062 transition: opacity 0.15s ease;
1063}
1064
1065.help-popup-fade-enter-from,
1066.help-popup-fade-leave-to {
1067 opacity: 0;
1068}
1069
1070.sh-title {
1071 display: flex;
1072 align-items: center;
1073 gap: 6px;
1074 font-size: 0.875rem;
1075 font-weight: 600;
1076 color: var(--vp-c-text-1);
1077 margin: 0 0 6px;
1078}
1079
1080.sh-title-icon {
1081 flex-shrink: 0;
1082 opacity: 0.8;
1083 width: 14px;
1084 height: 14px;
1085}
1086
1087.sh-desc {
1088 font-size: 0.78rem;
1089 color: var(--vp-c-text-2);
1090 margin: 0 0 10px;
1091 line-height: 1.5;
1092}
1093
1094.sh-options {
1095 display: flex;
1096 flex-direction: column;
1097 gap: 5px;
1098}
1099
1100.sh-option {
1101 display: flex;
1102 flex-direction: column;
1103 gap: 2px;
1104 background: var(--vp-c-bg-soft);
1105 border-radius: 6px;
1106 padding: 7px 9px;
1107}
1108
1109.sh-option strong {
1110 font-size: 0.78rem;
1111 font-weight: 600;
1112 color: var(--vp-c-text-1);
1113}
1114
1115.sh-option span {
1116 font-size: 0.74rem;
1117 color: var(--vp-c-text-2);
1118 line-height: 1.4;
1119}
1120
9151121/* ── Settings Dropdown ── */
9161122.settings-wrap {
9171123 position: relative;
@@ -943,13 +1149,15 @@ function onHandlePointerUp() {
9431149}
9441150
9451151.dropdown-label {
946 display: block;
947 font-size: 11px;
1152 display: flex;
1153 align-items: center;
1154 gap: 4px;
1155 font-size: 11.5px;
9481156 font-weight: 600;
9491157 text-transform: uppercase;
9501158 letter-spacing: 0.06em;
9511159 color: var(--vp-c-text-3, var(--vp-c-text-2));
952 margin-bottom: 6px;
1160 margin-bottom: 0;
9531161}
9541162
9551163.dropdown-group {