Commit 7d53af3196
Unsigned
Layout: unified · split
docs/.vitepress/theme/components/Search.vue +224 −40
| @@ -21,7 +21,9 @@ import { escapeRegExp } from 'vitepress/dist/client/shared' | |||
| 21 | 21 | ||
| 22 | import { | 22 | import { |
| 23 | computedAsync, | 23 | computedAsync, |
| 24 | onClickOutside, | ||
| 24 | onKeyStroke, | 25 | onKeyStroke, |
| 26 | useElementBounding, | ||
| 25 | useEventListener, | 27 | useEventListener, |
| 26 | useLocalStorage, | 28 | useLocalStorage, |
| 27 | useScrollLock, | 29 | useScrollLock, |
| @@ -48,6 +50,7 @@ import { | |||
| 48 | List, | 50 | List, |
| 49 | LocateOff, | 51 | LocateOff, |
| 50 | Regex, | 52 | Regex, |
| 53 | Settings2, | ||
| 51 | TextAlignStart | 54 | TextAlignStart |
| 52 | } from 'lucide-vue-next' | 55 | } from 'lucide-vue-next' |
| 53 | import Mark from 'mark.js/dist/mark.es6.js' | 56 | import Mark from 'mark.js/dist/mark.es6.js' |
| @@ -279,6 +282,21 @@ function cycleSearchMode() { | |||
| 279 | const matchExact = computed(() => searchMode.value === 'exact') | 282 | const matchExact = computed(() => searchMode.value === 'exact') |
| 280 | const urlSearchMode = computed(() => searchMode.value === 'url') | 283 | const urlSearchMode = computed(() => searchMode.value === 'url') |
| 281 | 284 | ||
| 285 | // Mobile settings popup | ||
| 286 | const showSettingsPopup = ref(false) | ||
| 287 | const settingsButtonRef = ref<HTMLButtonElement>() | ||
| 288 | const settingsPopupRef = ref<HTMLDivElement>() | ||
| 289 | const settingsBounding = useElementBounding(settingsButtonRef) | ||
| 290 | |||
| 291 | const settingsPopupStyle = computed(() => ({ | ||
| 292 | top: `${settingsBounding.bottom.value + 8}px`, | ||
| 293 | right: `calc(100vw - ${settingsBounding.right.value}px)`, | ||
| 294 | })) | ||
| 295 | |||
| 296 | onClickOutside(settingsPopupRef, () => { | ||
| 297 | showSettingsPopup.value = false | ||
| 298 | }, { ignore: [settingsButtonRef] }) | ||
| 299 | |||
| 282 | interface PageGroupCount { | 300 | interface PageGroupCount { |
| 283 | key: string | 301 | key: string |
| 284 | count: number | 302 | count: number |
| @@ -1552,6 +1570,10 @@ function onResultClick() { | |||
| 1552 | } | 1570 | } |
| 1553 | 1571 | ||
| 1554 | onKeyStroke('Escape', () => { | 1572 | onKeyStroke('Escape', () => { |
| 1573 | if (showSettingsPopup.value) { | ||
| 1574 | showSettingsPopup.value = false | ||
| 1575 | return | ||
| 1576 | } | ||
| 1555 | showSearch.value = false | 1577 | showSearch.value = false |
| 1556 | }) | 1578 | }) |
| 1557 | 1579 | ||
| @@ -1736,33 +1758,6 @@ function onMouseMove(e: MouseEvent) { | |||
| 1736 | : 'Bubba loading'" | 1758 | : 'Bubba loading'" |
| 1737 | /> | 1759 | /> |
| 1738 | </button> | 1760 | </button> |
| 1739 | <div | ||
| 1740 | v-if="!disableDetailedView && searchMode !== 'url'" | ||
| 1741 | class="view-group toolbar-group" | ||
| 1742 | > | ||
| 1743 | <button | ||
| 1744 | type="button" | ||
| 1745 | class="mode-btn" | ||
| 1746 | :class="{ 'mode-active': showDetailedList }" | ||
| 1747 | title="Detail view (Consumes more RAM)" | ||
| 1748 | @click="showDetailedList | ||
| 1749 | ? showDetailedList = false | ||
| 1750 | : showDetailedList = true" | ||
| 1751 | > | ||
| 1752 | <TextAlignStart :size="18" stroke-width="1.25" /> | ||
| 1753 | </button> | ||
| 1754 | <button | ||
| 1755 | type="button" | ||
| 1756 | class="mode-btn" | ||
| 1757 | :class="{ 'mode-active': !showDetailedList }" | ||
| 1758 | title="List view (Consumes less RAM)" | ||
| 1759 | @click="!showDetailedList | ||
| 1760 | ? showDetailedList = true | ||
| 1761 | : showDetailedList = false" | ||
| 1762 | > | ||
| 1763 | <List :size="18" stroke-width="1.25" /> | ||
| 1764 | </button> | ||
| 1765 | </div> | ||
| 1766 | <div class="search-mode-group toolbar-group"> | 1761 | <div class="search-mode-group toolbar-group"> |
| 1767 | <button | 1762 | <button |
| 1768 | type="button" | 1763 | type="button" |
| @@ -1798,6 +1793,43 @@ function onMouseMove(e: MouseEvent) { | |||
| 1798 | <Globe :size="18" stroke-width="1.25" /> | 1793 | <Globe :size="18" stroke-width="1.25" /> |
| 1799 | </button> | 1794 | </button> |
| 1800 | </div> | 1795 | </div> |
| 1796 | <div | ||
| 1797 | v-if="!disableDetailedView && searchMode !== 'url'" | ||
| 1798 | class="view-group toolbar-group" | ||
| 1799 | > | ||
| 1800 | <button | ||
| 1801 | type="button" | ||
| 1802 | class="mode-btn" | ||
| 1803 | :class="{ 'mode-active': showDetailedList }" | ||
| 1804 | title="Detail view (Consumes more RAM)" | ||
| 1805 | @click="showDetailedList | ||
| 1806 | ? showDetailedList = false | ||
| 1807 | : showDetailedList = true" | ||
| 1808 | > | ||
| 1809 | <TextAlignStart :size="18" stroke-width="1.25" /> | ||
| 1810 | </button> | ||
| 1811 | <button | ||
| 1812 | type="button" | ||
| 1813 | class="mode-btn" | ||
| 1814 | :class="{ 'mode-active': !showDetailedList }" | ||
| 1815 | title="List view (Consumes less RAM)" | ||
| 1816 | @click="!showDetailedList | ||
| 1817 | ? showDetailedList = true | ||
| 1818 | : showDetailedList = false" | ||
| 1819 | > | ||
| 1820 | <List :size="18" stroke-width="1.25" /> | ||
| 1821 | </button> | ||
| 1822 | </div> | ||
| 1823 | <button | ||
| 1824 | ref="settingsButtonRef" | ||
| 1825 | type="button" | ||
| 1826 | class="mode-btn settings-toggle-btn" | ||
| 1827 | :class="{ 'mode-active': showSettingsPopup }" | ||
| 1828 | title="Search settings" | ||
| 1829 | @click.stop="showSettingsPopup = !showSettingsPopup" | ||
| 1830 | > | ||
| 1831 | <Settings2 :size="18" stroke-width="1.25" /> | ||
| 1832 | </button> | ||
| 1801 | <button | 1833 | <button |
| 1802 | class="clear-button" | 1834 | class="clear-button" |
| 1803 | type="reset" | 1835 | type="reset" |
| @@ -2211,6 +2243,75 @@ function onMouseMove(e: MouseEvent) { | |||
| 2211 | {{ translate('modal.footer.closeText') }} | 2243 | {{ translate('modal.footer.closeText') }} |
| 2212 | </span> | 2244 | </span> |
| 2213 | </component> | 2245 | </component> |
| 2246 | <Teleport to="body"> | ||
| 2247 | <Transition name="settings-popup"> | ||
| 2248 | <div | ||
| 2249 | v-if="showSettingsPopup" | ||
| 2250 | ref="settingsPopupRef" | ||
| 2251 | class="search-settings-popup" | ||
| 2252 | :style="settingsPopupStyle" | ||
| 2253 | > | ||
| 2254 | <div class="settings-section"> | ||
| 2255 | <div class="settings-section-label">Search Mode</div> | ||
| 2256 | <div class="settings-options"> | ||
| 2257 | <button | ||
| 2258 | type="button" | ||
| 2259 | class="settings-option" | ||
| 2260 | :class="{ active: searchMode === 'exact' }" | ||
| 2261 | @click="searchMode = 'exact'" | ||
| 2262 | > | ||
| 2263 | <Regex :size="16" stroke-width="1.25" /> | ||
| 2264 | <span>Exact</span> | ||
| 2265 | </button> | ||
| 2266 | <button | ||
| 2267 | type="button" | ||
| 2268 | class="settings-option" | ||
| 2269 | :class="{ active: searchMode === 'fuzzy' }" | ||
| 2270 | @click="searchMode = 'fuzzy'" | ||
| 2271 | > | ||
| 2272 | <LocateOff :size="16" stroke-width="1.25" /> | ||
| 2273 | <span>Fuzzy</span> | ||
| 2274 | </button> | ||
| 2275 | <button | ||
| 2276 | type="button" | ||
| 2277 | class="settings-option" | ||
| 2278 | :class="{ active: searchMode === 'url' }" | ||
| 2279 | @click="searchMode = 'url'" | ||
| 2280 | > | ||
| 2281 | <Globe :size="16" stroke-width="1.25" /> | ||
| 2282 | <span>URL</span> | ||
| 2283 | </button> | ||
| 2284 | </div> | ||
| 2285 | </div> | ||
| 2286 | <div | ||
| 2287 | v-if="!disableDetailedView && searchMode !== 'url'" | ||
| 2288 | class="settings-section" | ||
| 2289 | > | ||
| 2290 | <div class="settings-section-label">View Mode</div> | ||
| 2291 | <div class="settings-options"> | ||
| 2292 | <button | ||
| 2293 | type="button" | ||
| 2294 | class="settings-option" | ||
| 2295 | :class="{ active: showDetailedList }" | ||
| 2296 | @click="showDetailedList = true" | ||
| 2297 | > | ||
| 2298 | <TextAlignStart :size="16" stroke-width="1.25" /> | ||
| 2299 | <span>Detail</span> | ||
| 2300 | </button> | ||
| 2301 | <button | ||
| 2302 | type="button" | ||
| 2303 | class="settings-option" | ||
| 2304 | :class="{ active: !showDetailedList }" | ||
| 2305 | @click="showDetailedList = false" | ||
| 2306 | > | ||
| 2307 | <List :size="16" stroke-width="1.25" /> | ||
| 2308 | <span>List</span> | ||
| 2309 | </button> | ||
| 2310 | </div> | ||
| 2311 | </div> | ||
| 2312 | </div> | ||
| 2313 | </Transition> | ||
| 2314 | </Teleport> | ||
| 2214 | </component> | 2315 | </component> |
| 2215 | </AnimatePresence> | 2316 | </AnimatePresence> |
| 2216 | 2317 | ||
| @@ -2802,22 +2903,11 @@ svg { | |||
| 2802 | overflow: hidden; | 2903 | overflow: hidden; |
| 2803 | } | 2904 | } |
| 2804 | 2905 | ||
| 2805 | /* Mobile: hide inactive buttons in both groups — tap the active one to cycle */ | 2906 | /* Mobile: hide toolbar groups entirely — settings popup handles them */ |
| 2806 | @media (max-width: 767px) { | 2907 | @media (max-width: 767px) { |
| 2807 | .search-mode-group .mode-btn:not(.mode-active), | ||
| 2808 | .view-group .mode-btn:not(.mode-active) { | ||
| 2809 | display: none; | ||
| 2810 | } | ||
| 2811 | |||
| 2812 | .search-mode-group, | 2908 | .search-mode-group, |
| 2813 | .view-group { | 2909 | .view-group { |
| 2814 | border-radius: 5px; | 2910 | display: none; |
| 2815 | } | ||
| 2816 | |||
| 2817 | /* Tapping the sole visible button cycles to the next option */ | ||
| 2818 | .search-mode-group .mode-btn.mode-active, | ||
| 2819 | .view-group .mode-btn.mode-active { | ||
| 2820 | border-radius: 4px; | ||
| 2821 | } | 2911 | } |
| 2822 | } | 2912 | } |
| 2823 | 2913 | ||
| @@ -2934,4 +3024,98 @@ svg { | |||
| 2934 | user-select: none; | 3024 | user-select: none; |
| 2935 | background: transparent; | 3025 | background: transparent; |
| 2936 | } | 3026 | } |
| 3027 | |||
| 3028 | /* Settings toggle button — mobile only */ | ||
| 3029 | .settings-toggle-btn { | ||
| 3030 | display: none; | ||
| 3031 | } | ||
| 3032 | |||
| 3033 | @media (max-width: 767px) { | ||
| 3034 | .settings-toggle-btn { | ||
| 3035 | display: flex; | ||
| 3036 | border: none; | ||
| 3037 | border-radius: 5px; | ||
| 3038 | color: var(--vp-c-text-1); | ||
| 3039 | padding: 8px; | ||
| 3040 | } | ||
| 3041 | } | ||
| 3042 | |||
| 3043 | /* Settings popup card */ | ||
| 3044 | .search-settings-popup { | ||
| 3045 | position: fixed; | ||
| 3046 | z-index: 200; | ||
| 3047 | background: var(--vp-c-bg-elv); | ||
| 3048 | border: 1px solid var(--vp-c-divider); | ||
| 3049 | border-radius: 12px; | ||
| 3050 | padding: 12px; | ||
| 3051 | box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18); | ||
| 3052 | display: flex; | ||
| 3053 | flex-direction: column; | ||
| 3054 | gap: 10px; | ||
| 3055 | min-width: 175px; | ||
| 3056 | } | ||
| 3057 | |||
| 3058 | .settings-section { | ||
| 3059 | display: flex; | ||
| 3060 | flex-direction: column; | ||
| 3061 | gap: 6px; | ||
| 3062 | } | ||
| 3063 | |||
| 3064 | .settings-section-label { | ||
| 3065 | font-size: 0.7rem; | ||
| 3066 | font-weight: 600; | ||
| 3067 | text-transform: uppercase; | ||
| 3068 | letter-spacing: 0.06em; | ||
| 3069 | color: var(--vp-c-text-3); | ||
| 3070 | padding: 0 4px; | ||
| 3071 | } | ||
| 3072 | |||
| 3073 | .settings-options { | ||
| 3074 | display: flex; | ||
| 3075 | flex-direction: column; | ||
| 3076 | border: 1px solid var(--vp-c-divider); | ||
| 3077 | border-radius: 8px; | ||
| 3078 | overflow: hidden; | ||
| 3079 | } | ||
| 3080 | |||
| 3081 | .settings-option { | ||
| 3082 | display: flex; | ||
| 3083 | align-items: center; | ||
| 3084 | gap: 8px; | ||
| 3085 | padding: 9px 12px; | ||
| 3086 | background: transparent; | ||
| 3087 | border: none; | ||
| 3088 | cursor: pointer; | ||
| 3089 | color: var(--vp-c-text-2); | ||
| 3090 | font-size: 0.88rem; | ||
| 3091 | text-align: left; | ||
| 3092 | transition: background-color 0.15s, color 0.15s; | ||
| 3093 | width: 100%; | ||
| 3094 | } | ||
| 3095 | |||
| 3096 | .settings-option + .settings-option { | ||
| 3097 | border-top: 1px solid var(--vp-c-divider); | ||
| 3098 | } | ||
| 3099 | |||
| 3100 | .settings-option:hover { | ||
| 3101 | background: var(--vp-c-default-soft); | ||
| 3102 | color: var(--vp-c-text-1); | ||
| 3103 | } | ||
| 3104 | |||
| 3105 | .settings-option.active { | ||
| 3106 | color: var(--vp-c-brand-1); | ||
| 3107 | background: rgba(60, 120, 210, 0.1); | ||
| 3108 | } | ||
| 3109 | |||
| 3110 | .settings-popup-enter-active, | ||
| 3111 | .settings-popup-leave-active { | ||
| 3112 | transition: opacity 0.15s ease, transform 0.15s ease; | ||
| 3113 | transform-origin: top right; | ||
| 3114 | } | ||
| 3115 | |||
| 3116 | .settings-popup-enter-from, | ||
| 3117 | .settings-popup-leave-to { | ||
| 3118 | opacity: 0; | ||
| 3119 | transform: scale(0.92) translateY(-4px); | ||
| 3120 | } | ||
| 2937 | </style>\ No newline at end of file | 3121 | </style>\ No newline at end of file |