Commit 97d4ffe9ee
Unsigned
Layout: unified · split
docs/.vitepress/theme/components/HomeFeatures.vue +214 −6
| @@ -1,5 +1,6 @@ | |||
| 1 | <script setup lang="ts"> | 1 | <script setup lang="ts"> |
| 2 | import { computed, onMounted, ref, watch } from 'vue' | 2 | import { computed, nextTick, onMounted, ref, watch } from 'vue' |
| 3 | import { Columns3, LayoutList } from 'lucide-vue-next' | ||
| 3 | import type { HomeCard } from '../../configs/constants' | 4 | import type { HomeCard } from '../../configs/constants' |
| 4 | 5 | ||
| 5 | const props = defineProps<{ cards: HomeCard[] }>() | 6 | const props = defineProps<{ cards: HomeCard[] }>() |
| @@ -85,6 +86,39 @@ function cardIcon(card: HomeCard) { | |||
| 85 | const panelOpen = ref(false) | 86 | const panelOpen = ref(false) |
| 86 | const dropdownOpen = ref(false) | 87 | const dropdownOpen = ref(false) |
| 87 | 88 | ||
| 89 | type HelpSection = 'view' | 'columns' | ||
| 90 | const activeHelpSection = ref<HelpSection | null>(null) | ||
| 91 | const helpPopupEl = ref<HTMLDivElement | null>(null) | ||
| 92 | const helpPopupPos = ref({ top: -9999, left: -9999 }) | ||
| 93 | |||
| 94 | watch(dropdownOpen, (val) => { | ||
| 95 | if (!val) { | ||
| 96 | activeHelpSection.value = null | ||
| 97 | helpPopupPos.value = { top: -9999, left: -9999 } | ||
| 98 | } | ||
| 99 | }) | ||
| 100 | |||
| 101 | function 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 | |||
| 88 | watch(panelOpen, (open) => { | 122 | watch(panelOpen, (open) => { |
| 89 | if (typeof document !== 'undefined') | 123 | if (typeof document !== 'undefined') |
| 90 | document.body.style.overflow = open ? 'hidden' : '' | 124 | document.body.style.overflow = open ? 'hidden' : '' |
| @@ -339,14 +373,30 @@ function onHandlePointerUp() { | |||
| 339 | <div v-if="dropdownOpen" class="dropdown-overlay" @click="dropdownOpen = false" /> | 373 | <div v-if="dropdownOpen" class="dropdown-overlay" @click="dropdownOpen = false" /> |
| 340 | <div v-if="dropdownOpen" class="settings-dropdown"> | 374 | <div v-if="dropdownOpen" class="settings-dropdown"> |
| 341 | <div class="dropdown-section"> | 375 | <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> | ||
| 343 | <div class="dropdown-group"> | 385 | <div class="dropdown-group"> |
| 344 | <button class="tool-btn" :class="{ 'is-active': viewMode === 'default' }" @click="viewMode = 'default'">Default</button> | 386 | <button class="tool-btn" :class="{ 'is-active': viewMode === 'default' }" @click="viewMode = 'default'">Default</button> |
| 345 | <button class="tool-btn" :class="{ 'is-active': viewMode === 'mini' }" @click="viewMode = 'mini'">Mini</button> | 387 | <button class="tool-btn" :class="{ 'is-active': viewMode === 'mini' }" @click="viewMode = 'mini'">Mini</button> |
| 346 | </div> | 388 | </div> |
| 347 | </div> | 389 | </div> |
| 348 | <div class="dropdown-section"> | 390 | <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> | ||
| 350 | <div class="dropdown-group"> | 400 | <div class="dropdown-group"> |
| 351 | <button class="tool-btn" :class="{ 'is-active': columnMode === 'default' }" @click="columnMode = 'default'">Default</button> | 401 | <button class="tool-btn" :class="{ 'is-active': columnMode === 'default' }" @click="columnMode = 'default'">Default</button> |
| 352 | <button class="tool-btn" :class="{ 'is-active': columnMode === 'max' }" @click="columnMode = 'max'">Max</button> | 402 | <button class="tool-btn" :class="{ 'is-active': columnMode === 'max' }" @click="columnMode = 'max'">Max</button> |
| @@ -378,6 +428,50 @@ function onHandlePointerUp() { | |||
| 378 | :style="{ left: cardTooltip.x + 'px', top: cardTooltip.y + 'px' }" | 428 | :style="{ left: cardTooltip.x + 'px', top: cardTooltip.y + 'px' }" |
| 379 | >{{ cardTooltip.text }}</div> | 429 | >{{ cardTooltip.text }}</div> |
| 380 | 430 | ||
| 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 | |||
| 381 | <Transition name="ghost-fade"> | 475 | <Transition name="ghost-fade"> |
| 382 | <div | 476 | <div |
| 383 | v-if="dragging && ghostPos" | 477 | v-if="dragging && ghostPos" |
| @@ -912,6 +1006,118 @@ function onHandlePointerUp() { | |||
| 912 | background: var(--vp-c-brand-soft); | 1006 | background: var(--vp-c-brand-soft); |
| 913 | } | 1007 | } |
| 914 | 1008 | ||
| 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 | |||
| 915 | /* ── Settings Dropdown ── */ | 1121 | /* ── Settings Dropdown ── */ |
| 916 | .settings-wrap { | 1122 | .settings-wrap { |
| 917 | position: relative; | 1123 | position: relative; |
| @@ -943,13 +1149,15 @@ function onHandlePointerUp() { | |||
| 943 | } | 1149 | } |
| 944 | 1150 | ||
| 945 | .dropdown-label { | 1151 | .dropdown-label { |
| 946 | display: block; | 1152 | display: flex; |
| 947 | font-size: 11px; | 1153 | align-items: center; |
| 1154 | gap: 4px; | ||
| 1155 | font-size: 11.5px; | ||
| 948 | font-weight: 600; | 1156 | font-weight: 600; |
| 949 | text-transform: uppercase; | 1157 | text-transform: uppercase; |
| 950 | letter-spacing: 0.06em; | 1158 | letter-spacing: 0.06em; |
| 951 | color: var(--vp-c-text-3, var(--vp-c-text-2)); | 1159 | color: var(--vp-c-text-3, var(--vp-c-text-2)); |
| 952 | margin-bottom: 6px; | 1160 | margin-bottom: 0; |
| 953 | } | 1161 | } |
| 954 | 1162 | ||
| 955 | .dropdown-group { | 1163 | .dropdown-group { |