docs/.vitepress/theme/components/HomeFeatures.vue
1401 lines · 35907 bytes
1<script setup lang="ts">
2import { ArrowLeft } from 'lucide-vue-next'
3import { renderCardIcon } from './link-card/iconMarkup'
4import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
5import type { HomeCard } from '../../configs/constants'
6
7const props = defineProps<{ cards: HomeCard[] }>()
8
9const STORAGE_KEY = 'wotaku-home-cards-v3'
10const PREFS_KEY = 'wotaku-home-prefs-v1'
11
12interface CardState {
13 homepage: string[]
14}
15
16function defaultState(): CardState {
17 return {
18 homepage: props.cards.filter((c) => c.featured).map((c) => c.id)
19 }
20}
21
22function loadState(): CardState {
23 if (typeof window === 'undefined') return defaultState()
24 try {
25 const raw = localStorage.getItem(STORAGE_KEY)
26 if (!raw) return defaultState()
27 const parsed: CardState = JSON.parse(raw)
28 const allIds = new Set(props.cards.map((c) => c.id))
29 return { homepage: (parsed.homepage ?? []).filter((id) => allIds.has(id)) }
30 } catch { return defaultState() }
31}
32
33const mounted = ref(false)
34const state = ref<CardState>(defaultState())
35
36onMounted(() => {
37 state.value = loadState()
38 const prefs = loadPrefs()
39 columnMode.value = prefs.columnMode
40 viewMode.value = prefs.viewMode
41 mounted.value = true
42})
43
44function save() {
45 localStorage.setItem(STORAGE_KEY, JSON.stringify(state.value))
46}
47
48const cardMap = computed(() => new Map(props.cards.map((c) => [c.id, c])))
49
50const homepageSet = computed(() => new Set(state.value.homepage))
51
52const visibleCards = computed(() =>
53 state.value.homepage.map((id) => cardMap.value.get(id)!).filter(Boolean)
54)
55
56const grid = computed(() => {
57 const n = visibleCards.value.length
58 if (n === 0) return undefined
59 if (columnMode.value === 'max') return 'grid-max'
60 if (n === 2) return 'grid-2'
61 if (n === 3) return 'grid-3'
62 if (n % 3 === 0) return 'grid-6'
63 if (n > 3) return 'grid-4'
64 return undefined
65})
66
67const panelGrid = computed(() => {
68 if (columnMode.value === 'max') return 'grid-max'
69 const n = props.cards.length
70 if (n === 2) return 'grid-2'
71 if (n === 3) return 'grid-3'
72 if (n % 3 === 0) return 'grid-6'
73 if (n > 3) return 'grid-4'
74 return undefined
75})
76
77/* ── Manager panel ── */
78const panelOpen = ref(false)
79const dropdownOpen = ref(false)
80
81type HelpSection = 'view' | 'columns'
82const activeHelpSection = ref<HelpSection | null>(null)
83const helpPopupEl = ref<HTMLDivElement | null>(null)
84const settingsDropdownEl = ref<HTMLDivElement | null>(null)
85const helpPopupPos = ref({ top: -9999, left: -9999 })
86
87watch(dropdownOpen, (val) => {
88 if (!val) {
89 activeHelpSection.value = null
90 helpPopupPos.value = { top: -9999, left: -9999 }
91 }
92})
93
94const canHoverHelp = () =>
95 typeof window !== 'undefined' && window.matchMedia('(hover: hover)').matches
96
97function positionHelpPopup(btn: HTMLElement) {
98 helpPopupPos.value = { top: -9999, left: -9999 }
99 const rect = btn.getBoundingClientRect()
100 // Anchor to the dropdown's left edge so the popup sits beside it, not over it.
101 const menuRect = settingsDropdownEl.value?.getBoundingClientRect()
102 nextTick(() => {
103 const popupW = helpPopupEl.value?.offsetWidth || 260
104 const popupH = helpPopupEl.value?.offsetHeight || 200
105 const vw = window.innerWidth
106 const margin = 8
107 const isMobile = vw < 768
108 if (isMobile) {
109 const aboveTop = rect.top - popupH - margin
110 const belowTop = rect.bottom + margin
111 const top = aboveTop >= margin ? aboveTop : belowTop
112 const left = Math.max(margin, Math.min((vw - popupW) / 2, vw - popupW - margin))
113 helpPopupPos.value = { top, left }
114 } else {
115 const anchorLeft = menuRect ? menuRect.left : rect.left
116 helpPopupPos.value = {
117 left: Math.max(margin, anchorLeft - popupW - 16),
118 top: Math.max(margin, Math.min(rect.top, window.innerHeight - popupH - margin)),
119 }
120 }
121 })
122}
123
124function closeHelpSection() {
125 activeHelpSection.value = null
126 helpPopupPos.value = { top: -9999, left: -9999 }
127}
128
129function toggleHelpSection(section: HelpSection, e: MouseEvent) {
130 // Hover devices open/close via mouseenter/leave; touch devices toggle on tap.
131 if (canHoverHelp()) {
132 activeHelpSection.value = section
133 positionHelpPopup(e.currentTarget as HTMLElement)
134 return
135 }
136 if (activeHelpSection.value === section) {
137 closeHelpSection()
138 return
139 }
140 activeHelpSection.value = section
141 positionHelpPopup(e.currentTarget as HTMLElement)
142}
143
144function onHelpEnter(section: HelpSection, e: MouseEvent) {
145 if (!canHoverHelp()) return
146 activeHelpSection.value = section
147 positionHelpPopup(e.currentTarget as HTMLElement)
148}
149
150function onHelpLeave() {
151 if (!canHoverHelp()) return
152 closeHelpSection()
153}
154
155watch(panelOpen, (open) => {
156 if (typeof document !== 'undefined')
157 document.body.style.overflow = open ? 'hidden' : ''
158})
159
160function onKeydown(e: KeyboardEvent) {
161 if (e.key === 'Escape') {
162 panelOpen.value = false
163 cardTooltip.value = null
164 }
165}
166
167onMounted(() => document.addEventListener('keydown', onKeydown))
168onUnmounted(() => document.removeEventListener('keydown', onKeydown))
169
170function loadPrefs() {
171 if (typeof window === 'undefined') return { columnMode: 'default' as const, viewMode: 'default' as const }
172 try {
173 const p = JSON.parse(localStorage.getItem(PREFS_KEY) ?? '{}')
174 return {
175 columnMode: p.columnMode === 'max' ? 'max' as const : 'default' as const,
176 viewMode: p.viewMode === 'mini' ? 'mini' as const : 'default' as const
177 }
178 } catch { return { columnMode: 'default' as const, viewMode: 'default' as const } }
179}
180
181const columnMode = ref<'default' | 'max'>('default')
182const viewMode = ref<'default' | 'mini'>('default')
183
184watch([columnMode, viewMode], () => {
185 localStorage.setItem(PREFS_KEY, JSON.stringify({
186 columnMode: columnMode.value,
187 viewMode: viewMode.value
188 }))
189})
190
191const homepageSectionCards = computed(() =>
192 state.value.homepage.map((id) => cardMap.value.get(id)!).filter(Boolean)
193)
194
195const otherSections = computed(() => {
196 const sectionMap = new Map<string, HomeCard[]>()
197 for (const card of props.cards) {
198 const s = card.section ?? 'Pages'
199 if (!sectionMap.has(s)) sectionMap.set(s, [])
200 if (!homepageSet.value.has(card.id)) sectionMap.get(s)!.push(card)
201 }
202 return Array.from(sectionMap.entries()).map(([label, cards]) => ({ label, cards }))
203})
204
205function toggleCard(id: string) {
206 if (homepageSet.value.has(id)) {
207 state.value.homepage = state.value.homepage.filter((hid) => hid !== id)
208 } else {
209 state.value.homepage.push(id)
210 }
211 save()
212}
213
214function showAll() {
215 const current = new Set(state.value.homepage)
216 const toAdd = props.cards.filter((c) => !current.has(c.id)).map((c) => c.id)
217 state.value.homepage = [...state.value.homepage, ...toAdd]
218 save()
219}
220
221function hideAll() {
222 state.value.homepage = []
223 save()
224}
225
226function resetDefaults() {
227 state.value = defaultState()
228 columnMode.value = 'default'
229 viewMode.value = 'default'
230 save()
231}
232
233const cardTooltip = ref<{ text: string; x: number; y: number } | null>(null)
234
235function showCardTooltip(e: MouseEvent, title: string) {
236 if (!window.matchMedia('(hover: hover)').matches) return
237 const rect = (e.currentTarget as HTMLElement).getBoundingClientRect()
238 cardTooltip.value = { text: title, x: rect.left + rect.width / 2, y: rect.top }
239}
240
241function hideCardTooltip() {
242 cardTooltip.value = null
243}
244
245/* ── Drag-to-reorder (homepage only, pointer events) ── */
246const dragging = ref<string | null>(null)
247const dragTarget = ref<string | null>(null)
248const cardListEl = ref<HTMLElement | null>(null)
249const ghostPos = ref<{ x: number; y: number } | null>(null)
250
251function onHandlePointerDown(e: PointerEvent, id: string) {
252 e.preventDefault()
253 dragging.value = id
254 dragTarget.value = null
255 ghostPos.value = { x: e.clientX, y: e.clientY }
256 ;(e.currentTarget as HTMLElement).setPointerCapture(e.pointerId)
257}
258
259function onHandlePointerMove(e: PointerEvent) {
260 if (!dragging.value) return
261 ghostPos.value = { x: e.clientX, y: e.clientY }
262 const items = cardListEl.value?.querySelectorAll<HTMLElement>('[data-card-id]')
263 if (!items) return
264 for (const item of items) {
265 const rect = item.getBoundingClientRect()
266 if (
267 e.clientX >= rect.left && e.clientX <= rect.right &&
268 e.clientY >= rect.top && e.clientY <= rect.bottom
269 ) {
270 const id = item.dataset.cardId!
271 if (id !== dragging.value) dragTarget.value = id
272 break
273 }
274 }
275}
276
277function onHandlePointerUp() {
278 if (dragging.value && dragTarget.value) {
279 const order = [...state.value.homepage]
280 const from = order.indexOf(dragging.value)
281 const to = order.indexOf(dragTarget.value)
282 if (from !== -1 && to !== -1) {
283 order.splice(from, 1)
284 order.splice(to, 0, dragging.value)
285 state.value.homepage = order
286 save()
287 }
288 }
289 dragging.value = null
290 dragTarget.value = null
291 ghostPos.value = null
292}
293</script>
294
295<template>
296 <!-- ── Feature Grid ── -->
297 <div class="home-features" :class="{ 'is-mounted': mounted }">
298 <div class="container">
299 <div class="card-toolbar">
300 <button class="gear-btn" aria-label="Customize cards" @click="panelOpen = true">
301 <span class="i-lucide-ellipsis" />
302 </button>
303 </div>
304 <div class="items" :class="{ 'view-mini': viewMode === 'mini' }">
305 <div
306 v-for="card in visibleCards"
307 :key="card.id"
308 class="item"
309 :class="grid"
310 >
311 <a class="card" :href="card.link">
312 <article class="box">
313 <div class="icon" v-html="renderCardIcon(card.icon)" />
314 <h2 class="title">{{ card.title }}</h2>
315 <p class="details">{{ card.details }}</p>
316 </article>
317 </a>
318 </div>
319 </div>
320 </div>
321 </div>
322
323 <!-- ── Manager Panel ── -->
324 <Teleport to="body">
325 <Transition name="fade">
326 <div v-if="panelOpen" class="backdrop" @click.self="panelOpen = false">
327 <Transition name="slide-up" appear>
328 <div v-if="panelOpen" class="panel" role="dialog" aria-modal="true" aria-label="Customize cards">
329 <div class="panel-head">
330 <button class="panel-back" aria-label="Back" @click="panelOpen = false">
331 <ArrowLeft :size="18" :stroke-width="2" />
332 </button>
333 <span class="panel-title">Customize Cards</span>
334 <button class="close-btn" aria-label="Close" @click="panelOpen = false">
335 <span class="i-lucide-x" />
336 </button>
337 </div>
338
339 <div class="card-sections">
340 <!-- Homepage section (draggable) -->
341 <div class="section-label">Homepage</div>
342 <ul ref="cardListEl" class="card-list" :class="panelGrid">
343 <li v-if="homepageSectionCards.length === 0" class="empty-box">
344 <span class="empty-hint">No cards have been selected</span>
345 </li>
346 <li
347 v-for="card in homepageSectionCards"
348 :key="card.id"
349 :data-card-id="card.id"
350 class="card-row"
351 @mouseenter="showCardTooltip($event, card.title)"
352 @mouseleave="hideCardTooltip"
353 :class="{
354 'is-dragging': dragging === card.id,
355 'is-over': dragTarget === card.id && dragging !== card.id
356 }"
357 >
358 <span
359 class="row-handle"
360 aria-hidden="true"
361 @pointerdown="onHandlePointerDown($event, card.id)"
362 @pointermove="onHandlePointerMove"
363 @pointerup="onHandlePointerUp"
364 >
365 <span class="i-lucide-grip-vertical" />
366 </span>
367 <span class="row-icon" v-html="renderCardIcon(card.icon)" />
368 <span class="row-name">{{ card.title }}</span>
369 <button
370 class="row-toggle active"
371 aria-label="Remove from homepage"
372 @click="toggleCard(card.id)"
373 >
374 <span class="i-lucide-eye" />
375 </button>
376 </li>
377 </ul>
378
379 <!-- Other sections (Pages, Extensions, Other…) -->
380 <template v-for="section in otherSections" :key="section.label">
381 <div class="section-label">{{ section.label }}</div>
382 <ul class="card-list" :class="panelGrid">
383 <li v-if="section.cards.length === 0" class="empty-box">
384 <span class="empty-hint">All cards from this section have been selected</span>
385 </li>
386 <li
387 v-for="card in section.cards"
388 :key="card.id"
389 class="card-row card-row-unselected"
390 @mouseenter="showCardTooltip($event, card.title)"
391 @mouseleave="hideCardTooltip"
392 >
393 <span class="row-handle-spacer" aria-hidden="true" />
394 <span class="row-icon" v-html="renderCardIcon(card.icon)" />
395 <span class="row-name">{{ card.title }}</span>
396 <button
397 class="row-toggle"
398 aria-label="Add to homepage"
399 @click="toggleCard(card.id)"
400 >
401 <span class="i-lucide-eye-off" />
402 </button>
403 </li>
404 </ul>
405 </template>
406 </div>
407
408 <div class="panel-foot">
409 <div class="foot-group">
410 <button class="tool-btn" aria-label="Show all" @click="showAll">
411 <span class="i-lucide-eye" />
412 </button>
413 <button class="tool-btn" aria-label="Hide all" @click="hideAll">
414 <span class="i-lucide-eye-off" />
415 </button>
416 <button class="tool-btn" aria-label="Reset to default" @click="resetDefaults">
417 <span class="i-lucide-refresh-ccw" />
418 </button>
419 </div>
420 <div class="foot-group">
421 <div class="settings-wrap">
422 <div v-if="dropdownOpen" class="dropdown-overlay" @click="dropdownOpen = false" />
423 <div v-if="dropdownOpen" ref="settingsDropdownEl" class="settings-dropdown">
424 <div class="dropdown-section">
425 <div class="dropdown-section-header">
426 <span class="dropdown-label">
427 <span class="i-lucide-layout-list dropdown-label-icon" />
428 View
429 </span>
430 <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">
431 <span class="i-carbon:help-filled settings-help-icon" />
432 </button>
433 </div>
434 <div class="dropdown-group" :class="{ 'is-highlighted': activeHelpSection === 'view' }">
435 <button class="tool-btn" :class="{ 'is-active': viewMode === 'default' }" @click="viewMode = 'default'">Default</button>
436 <button class="tool-btn" :class="{ 'is-active': viewMode === 'mini' }" @click="viewMode = 'mini'">Mini</button>
437 </div>
438 </div>
439 <div class="dropdown-section">
440 <div class="dropdown-section-header">
441 <span class="dropdown-label">
442 <span class="i-lucide-columns-3-cog dropdown-label-icon" />
443 Columns
444 </span>
445 <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">
446 <span class="i-carbon:help-filled settings-help-icon" />
447 </button>
448 </div>
449 <div class="dropdown-group" :class="{ 'is-highlighted': activeHelpSection === 'columns' }">
450 <button class="tool-btn" :class="{ 'is-active': columnMode === 'default' }" @click="columnMode = 'default'">Default</button>
451 <button class="tool-btn" :class="{ 'is-active': columnMode === 'max' }" @click="columnMode = 'max'">Max</button>
452 </div>
453 </div>
454 </div>
455 <button
456 class="tool-btn"
457 :class="{ 'is-active': dropdownOpen }"
458 aria-label="Display settings"
459 @click.stop="dropdownOpen = !dropdownOpen"
460 >
461 <span class="i-lucide-settings" />
462 </button>
463 </div>
464 </div>
465 </div>
466 </div>
467 </Transition>
468 </div>
469 </Transition>
470
471 <div
472 v-if="cardTooltip"
473 class="card-tooltip"
474 :style="{ left: cardTooltip.x + 'px', top: cardTooltip.y + 'px' }"
475 >{{ cardTooltip.text }}</div>
476
477 <Transition name="help-popup-fade">
478 <div
479 v-if="activeHelpSection && dropdownOpen"
480 ref="helpPopupEl"
481 class="home-help-popup"
482 :style="{ top: helpPopupPos.top + 'px', left: helpPopupPos.left + 'px' }"
483 >
484 <template v-if="activeHelpSection === 'view'">
485 <h4 class="sh-title">
486 <span class="i-lucide-layout-list sh-title-icon" />
487 View
488 </h4>
489 <p class="sh-desc">Controls how cards are displayed on the homepage.</p>
490 <div class="sh-options">
491 <div class="sh-option">
492 <strong>
493 <span class="i-lucide-layout-grid sh-option-icon" />
494 Default
495 </strong>
496 <span>Full card with icon, title, and description.</span>
497 </div>
498 <div class="sh-option">
499 <strong>
500 <span class="i-lucide-rows-3 sh-option-icon" />
501 Mini
502 </strong>
503 <span>Compact row with icon and title only.</span>
504 </div>
505 </div>
506 </template>
507 <template v-else-if="activeHelpSection === 'columns'">
508 <h4 class="sh-title">
509 <span class="i-lucide-columns-3-cog sh-title-icon" />
510 Columns
511 </h4>
512 <p class="sh-desc">Controls how many columns the card grid uses.</p>
513 <div class="sh-options">
514 <div class="sh-option">
515 <strong>
516 <span class="i-lucide-columns-2 sh-option-icon" />
517 Default
518 </strong>
519 <span>Adapts automatically based on the number of cards.</span>
520 </div>
521 <div class="sh-option">
522 <strong>
523 <span class="i-lucide-columns-3 sh-option-icon" />
524 Max
525 </strong>
526 <span>Always uses the maximum number of columns based on screen resolution.</span>
527 </div>
528 </div>
529 </template>
530 </div>
531 </Transition>
532
533 <Transition name="ghost-fade">
534 <div
535 v-if="dragging && ghostPos"
536 class="drag-ghost"
537 :style="{ left: ghostPos.x + 'px', top: ghostPos.y + 'px' }"
538 >
539 <span class="row-icon" v-html="renderCardIcon(cardMap.get(dragging)!.icon)" />
540 <span class="drag-ghost-name">{{ cardMap.get(dragging)?.title }}</span>
541 </div>
542 </Transition>
543 </Teleport>
544</template>
545
546<style scoped>
547/* ── Grid ── */
548.home-features {
549 position: relative;
550 padding: 0 24px;
551}
552
553.home-features .container {
554 opacity: 0;
555 transition: opacity 0.15s ease;
556}
557
558.home-features.is-mounted .container {
559 opacity: 1;
560}
561
562@media (min-width: 640px) {
563 .home-features { padding: 0 48px; }
564}
565
566@media (min-width: 960px) {
567 .home-features { padding: 0 64px; }
568}
569
570.container {
571 position: relative;
572 margin: 0 auto;
573 max-width: 1152px;
574}
575
576.items {
577 display: flex;
578 flex-wrap: wrap;
579 margin: -8px;
580}
581
582.item {
583 padding: 8px;
584 width: 100%;
585}
586
587@media (min-width: 640px) {
588 .item.grid-2,
589 .item.grid-4,
590 .item.grid-6 { width: calc(100% / 2); }
591}
592
593@media (min-width: 768px) {
594 .item.grid-2,
595 .item.grid-4 { width: calc(100% / 2); }
596 .item.grid-3,
597 .item.grid-6 { width: calc(100% / 3); }
598}
599
600@media (min-width: 960px) {
601 .item.grid-4 { width: calc(100% / 4); }
602}
603
604@media (min-width: 640px) {
605 .item.grid-max { width: calc(100% / 2); }
606}
607
608@media (min-width: 768px) {
609 .item.grid-max { width: calc(100% / 3); }
610}
611
612@media (min-width: 960px) {
613 .item.grid-max { width: calc(100% / 4); }
614}
615
616/* ── Card ── */
617.card {
618 display: block;
619 border: 2px solid #3d3d3d;
620 border-radius: 12px;
621 height: 100%;
622 background-color: var(--vp-c-bg-soft);
623 transition: border-color 0.25s, background-color 0.25s;
624 text-decoration: none;
625 color: inherit;
626}
627
628.card:hover {
629 border-color: var(--vp-c-brand-1);
630}
631
632.card:active {
633 transform: none;
634}
635
636.box {
637 display: flex;
638 flex-direction: column;
639 padding: 24px;
640 height: 100%;
641}
642
643.icon {
644 display: flex;
645 justify-content: center;
646 align-items: center;
647 margin-bottom: 20px;
648 border-radius: 6px;
649 background-color: var(--vp-c-default-soft);
650 width: 48px;
651 height: 48px;
652 font-size: 27px;
653 transition: background-color 0.25s;
654}
655
656.title {
657 line-height: 24px;
658 font-size: 16px;
659 font-weight: 600;
660}
661
662.details {
663 flex-grow: 1;
664 padding-top: 8px;
665 line-height: 24px;
666 font-size: 14px;
667 font-weight: 500;
668 color: var(--vp-c-text-2);
669}
670
671/* ── Mini View ── */
672.view-mini .box {
673 flex-direction: row;
674 align-items: center;
675 padding: 12px 16px;
676 gap: 12px;
677}
678
679.view-mini .icon {
680 width: 32px;
681 height: 32px;
682 font-size: 18px;
683 margin-bottom: 0;
684 flex-shrink: 0;
685}
686
687.view-mini .title {
688 font-size: 14px;
689 line-height: 1.3;
690}
691
692.view-mini .details {
693 display: none;
694}
695
696/* ── Gear Button ── */
697.card-toolbar {
698 display: flex;
699 justify-content: flex-end;
700 margin-bottom: 4px;
701}
702
703.gear-btn {
704 background: none;
705 border: none;
706 padding: 4px;
707 color: var(--vp-c-text-2);
708 font-size: 18px;
709 cursor: pointer;
710 transition: color 0.2s, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
711 display: flex;
712 align-items: center;
713}
714
715.gear-btn:hover {
716 color: var(--vp-c-text-1);
717}
718
719.gear-btn:active {
720 transform: scale(0.94);
721}
722
723/* ── Backdrop ── */
724.backdrop {
725 position: fixed;
726 inset: 0;
727 z-index: 100;
728 display: flex;
729 align-items: center;
730 justify-content: center;
731 background: rgba(0, 0, 0, 0.5);
732 backdrop-filter: blur(4px);
733 overscroll-behavior: none;
734 touch-action: none;
735}
736
737@media (max-width: 767px) {
738 .backdrop {
739 align-items: stretch;
740 }
741}
742
743/* ── Panel ── */
744.panel {
745 width: min(520px, calc(100vw - 32px));
746 max-height: 85vh;
747 display: flex;
748 flex-direction: column;
749 border-radius: 16px;
750 border: 2px solid #3d3d3d;
751 background: var(--vp-c-bg);
752}
753
754@media (max-width: 767px) {
755 .panel {
756 width: 100vw;
757 height: 100vh;
758 height: 100dvh;
759 max-height: none;
760 border-radius: 0;
761 border: none;
762 }
763}
764
765@media (min-width: 768px) {
766 .panel { width: min(720px, calc(100vw - 32px)); }
767}
768
769@media (min-width: 960px) {
770 .panel { width: min(940px, calc(100vw - 32px)); }
771}
772
773.panel-head {
774 display: flex;
775 align-items: center;
776 justify-content: space-between;
777 padding: 10px 16px;
778 border-bottom: 1px solid var(--vp-c-divider);
779 flex-shrink: 0;
780}
781
782.panel-title {
783 font-size: 15px;
784 font-weight: 600;
785 color: var(--vp-c-text-1);
786}
787
788/* Phone-only back button. */
789.panel-back {
790 display: none;
791 align-items: center;
792 justify-content: center;
793 padding: 8px;
794 border: none;
795 background: transparent;
796 color: var(--vp-c-text-1);
797 font-size: 18px;
798 cursor: pointer;
799 transition: color 0.15s;
800}
801
802.panel-back:hover {
803 color: var(--vp-c-brand-1);
804}
805
806.close-btn {
807 position: relative;
808 display: flex;
809 align-items: center;
810 justify-content: center;
811 width: 28px;
812 height: 28px;
813 border-radius: 6px;
814 border: none;
815 background: transparent;
816 color: var(--vp-c-text-2);
817 font-size: 16px;
818 cursor: pointer;
819 transition: color 0.15s, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
820}
821
822.close-btn:hover {
823 color: var(--vp-c-text-1);
824}
825
826.close-btn:active {
827 transform: scale(0.94);
828}
829
830.close-btn::after {
831 content: attr(aria-label);
832 position: absolute;
833 top: calc(100% + 6px);
834 right: 0;
835 background: var(--vp-c-bg-soft);
836 color: var(--vp-c-text-1);
837 border: 1px solid var(--vp-c-divider);
838 border-radius: 5px;
839 padding: 3px 8px;
840 font-size: 11px;
841 white-space: nowrap;
842 pointer-events: none;
843 opacity: 0;
844 transition: opacity 0.15s;
845 z-index: 10;
846}
847
848@media (hover: hover) {
849 .close-btn:hover::after {
850 opacity: 1;
851 }
852}
853
854/* Phone: full-screen header (back arrow, no X). */
855@media (max-width: 767px) {
856 .panel-head {
857 height: 49px;
858 padding: 6px 8px;
859 justify-content: flex-start;
860 border-bottom-color: var(--wk-fs-header-divider);
861 }
862
863 .panel-back {
864 display: flex;
865 }
866
867 .close-btn {
868 display: none;
869 }
870}
871
872/* ── Card List ── */
873.card-sections {
874 overflow-y: auto;
875 min-height: 0;
876 padding: 8px;
877 display: flex;
878 flex-direction: column;
879 gap: 2px;
880 touch-action: pan-y;
881 overscroll-behavior: contain;
882}
883
884.section-label {
885 font-size: 11px;
886 font-weight: 600;
887 text-transform: uppercase;
888 letter-spacing: 0.06em;
889 color: var(--vp-c-text-3, var(--vp-c-text-2));
890 padding: 8px 10px 2px;
891}
892
893.section-label:first-child {
894 padding-top: 2px;
895}
896
897.card-list {
898 list-style: none;
899 margin: 0;
900 padding: 0;
901 display: grid;
902 grid-template-columns: 1fr;
903 gap: 2px;
904}
905
906@media (min-width: 640px) {
907 .card-list.grid-2,
908 .card-list.grid-4,
909 .card-list.grid-6,
910 .card-list.grid-max { grid-template-columns: 1fr 1fr; }
911}
912
913@media (min-width: 768px) {
914 .card-list.grid-3,
915 .card-list.grid-6,
916 .card-list.grid-max { grid-template-columns: 1fr 1fr 1fr; }
917}
918
919@media (min-width: 960px) {
920 .card-list.grid-4,
921 .card-list.grid-max { grid-template-columns: 1fr 1fr 1fr 1fr; }
922}
923
924.card-row {
925 display: flex;
926 align-items: center;
927 gap: 8px;
928 padding: 7px 10px;
929 border-radius: 8px;
930 transition: background 0.15s, opacity 0.15s;
931 user-select: none;
932 min-width: 0;
933}
934
935.card-row:hover {
936 background: var(--vp-c-bg-soft);
937}
938
939.card-row-unselected {
940 opacity: 0.45;
941}
942
943.card-row-unselected:hover {
944 opacity: 1;
945}
946
947.empty-box {
948 grid-column: 1 / -1;
949 list-style: none;
950 border-radius: 8px;
951 padding: 14px 16px;
952 display: flex;
953 align-items: center;
954 justify-content: center;
955 background-image:
956 linear-gradient(90deg, var(--vp-c-divider) 6px, transparent 6px),
957 linear-gradient(90deg, var(--vp-c-divider) 6px, transparent 6px),
958 linear-gradient(0deg, var(--vp-c-divider) 6px, transparent 6px),
959 linear-gradient(0deg, var(--vp-c-divider) 6px, transparent 6px);
960 background-size: 10px 1px, 10px 1px, 1px 10px, 1px 10px;
961 background-position: top left, bottom left, top left, top right;
962 background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
963}
964
965.empty-hint {
966 font-size: 13px;
967 color: var(--vp-c-text-3, var(--vp-c-text-2));
968 font-style: italic;
969}
970
971.card-tooltip {
972 position: fixed;
973 z-index: 9999;
974 transform: translate(-50%, calc(-100% - 6px));
975 background: var(--vp-c-bg-soft);
976 color: var(--vp-c-text-1);
977 border: 1px solid var(--vp-c-divider);
978 border-radius: 5px;
979 padding: 3px 8px;
980 font-size: 11px;
981 white-space: nowrap;
982 pointer-events: none;
983}
984
985.card-row.is-dragging {
986 opacity: 0.25;
987 cursor: grabbing;
988}
989
990.card-row.is-over {
991 background: var(--vp-c-brand-soft);
992 outline: 2px solid var(--vp-c-brand-1);
993 outline-offset: -2px;
994}
995
996.row-handle {
997 color: var(--vp-c-text-3, var(--vp-c-text-2));
998 font-size: 16px;
999 flex-shrink: 0;
1000 display: flex;
1001 align-items: center;
1002 cursor: grab;
1003 touch-action: none;
1004}
1005
1006.row-handle:active {
1007 cursor: grabbing;
1008}
1009
1010.row-handle-spacer {
1011 width: 16px;
1012 flex-shrink: 0;
1013}
1014
1015.row-icon {
1016 font-size: 18px;
1017 flex-shrink: 0;
1018 display: flex;
1019 align-items: center;
1020 width: 20px;
1021}
1022
1023.row-name {
1024 flex: 1;
1025 font-size: 14px;
1026 font-weight: 500;
1027 color: var(--vp-c-text-1);
1028 overflow: hidden;
1029 white-space: nowrap;
1030 text-overflow: ellipsis;
1031 min-width: 0;
1032}
1033
1034.row-toggle {
1035 display: flex;
1036 align-items: center;
1037 justify-content: center;
1038 width: 30px;
1039 height: 30px;
1040 border-radius: 6px;
1041 border: none;
1042 background: transparent;
1043 color: var(--vp-c-text-2);
1044 font-size: 16px;
1045 cursor: pointer;
1046 flex-shrink: 0;
1047 transition: color 0.15s, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
1048}
1049
1050.row-toggle:hover,
1051.row-toggle.active {
1052 color: var(--vp-c-text-1);
1053}
1054
1055.row-toggle:active {
1056 transform: scale(0.94);
1057}
1058
1059/* ── Panel Footer ── */
1060.panel-foot {
1061 display: flex;
1062 align-items: center;
1063 justify-content: space-between;
1064 padding: 5px 8px;
1065 border-top: 1px solid var(--vp-c-divider);
1066 flex-shrink: 0;
1067 gap: 8px;
1068}
1069
1070.foot-group {
1071 display: flex;
1072 align-items: center;
1073 gap: 4px;
1074}
1075
1076.tool-btn {
1077 position: relative;
1078 display: flex;
1079 align-items: center;
1080 gap: 5px;
1081 font-size: 14px;
1082 font-weight: 500;
1083 color: var(--vp-c-text-2);
1084 background: transparent;
1085 border: none;
1086 border-radius: 5px;
1087 padding: 5px 6px;
1088 cursor: pointer;
1089 transition: color 0.15s, background 0.15s, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
1090}
1091
1092.tool-btn[aria-label]::after {
1093 content: attr(aria-label);
1094 position: absolute;
1095 bottom: calc(100% + 6px);
1096 left: 50%;
1097 transform: translateX(-50%);
1098 background: var(--vp-c-bg-soft);
1099 color: var(--vp-c-text-1);
1100 border: 1px solid var(--vp-c-divider);
1101 border-radius: 5px;
1102 padding: 3px 8px;
1103 font-size: 11px;
1104 white-space: nowrap;
1105 pointer-events: none;
1106 opacity: 0;
1107 transition: opacity 0.15s;
1108 z-index: 10;
1109}
1110
1111@media (hover: hover) {
1112 .tool-btn[aria-label]:hover::after {
1113 opacity: 1;
1114 }
1115}
1116
1117.tool-btn:hover,
1118.tool-btn.is-active {
1119 color: var(--vp-c-text-1);
1120 background: transparent;
1121}
1122
1123.tool-btn:active {
1124 transform: scale(0.94);
1125}
1126
1127/* Respect the "effects off" preference */
1128html.effects-disabled .gear-btn,
1129html.effects-disabled .close-btn,
1130html.effects-disabled .tool-btn,
1131html.effects-disabled .row-toggle {
1132 transition: none;
1133}
1134
1135html.effects-disabled .gear-btn:active,
1136html.effects-disabled .close-btn:active,
1137html.effects-disabled .tool-btn:active,
1138html.effects-disabled .row-toggle:active {
1139 transform: none;
1140}
1141
1142/* ── Settings Help ── */
1143.dropdown-section-header {
1144 display: flex;
1145 align-items: center;
1146 justify-content: space-between;
1147 margin-bottom: 6px;
1148}
1149
1150.dropdown-section-header .dropdown-label {
1151 margin-bottom: 0;
1152}
1153
1154.settings-help-btn {
1155 display: flex;
1156 align-items: center;
1157 justify-content: center;
1158 padding: 3px;
1159 background: transparent;
1160 border: none;
1161 cursor: pointer;
1162 color: var(--vp-c-text-3);
1163 opacity: 0.5;
1164 transition: opacity 0.15s, color 0.15s;
1165 border-radius: 3px;
1166 line-height: 1;
1167}
1168
1169.settings-help-btn:hover,
1170.settings-help-btn.active {
1171 opacity: 1;
1172 color: var(--vp-c-text-1);
1173}
1174
1175.settings-help-icon {
1176 display: block;
1177 width: 16px;
1178 height: 16px;
1179}
1180
1181.home-help-popup {
1182 position: fixed;
1183 z-index: 9999;
1184 width: 280px;
1185 background: var(--vp-c-bg-elv);
1186 border: 1px solid var(--vp-c-divider);
1187 border-radius: 12px;
1188 padding: 16px;
1189 box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
1190 pointer-events: none;
1191}
1192
1193.help-popup-fade-enter-active,
1194.help-popup-fade-leave-active {
1195 transition: opacity 0.15s ease;
1196}
1197
1198.help-popup-fade-enter-from,
1199.help-popup-fade-leave-to {
1200 opacity: 0;
1201}
1202
1203.sh-title {
1204 display: flex;
1205 align-items: center;
1206 gap: 6px;
1207 font-size: 1rem;
1208 font-weight: 600;
1209 color: var(--vp-c-text-1);
1210 margin: 0 0 4px;
1211}
1212
1213.sh-title-icon {
1214 flex-shrink: 0;
1215 width: 16px;
1216 height: 16px;
1217 display: block;
1218}
1219
1220.sh-desc {
1221 font-size: 0.875rem;
1222 color: var(--vp-c-text-2);
1223 margin: 0 0 6px;
1224 line-height: 1.5;
1225}
1226
1227.sh-options {
1228 display: flex;
1229 flex-direction: column;
1230 gap: 5px;
1231}
1232
1233.sh-option {
1234 display: flex;
1235 flex-direction: column;
1236 gap: 4px;
1237 background: var(--wk-c-menu-bg);
1238 border-radius: 12px;
1239 padding: 10px 12px;
1240}
1241
1242.dark .sh-option {
1243 background: var(--wk-c-menu-bg);
1244}
1245
1246.sh-option strong {
1247 display: flex;
1248 align-items: center;
1249 gap: 4px;
1250 font-size: 0.875rem;
1251 font-weight: 600;
1252 color: var(--vp-c-text-1);
1253}
1254
1255.sh-option-icon {
1256 width: 14px;
1257 height: 14px;
1258 flex-shrink: 0;
1259}
1260
1261.sh-option span {
1262 font-size: 0.875rem;
1263 color: var(--vp-c-text-2);
1264 line-height: 1.4;
1265}
1266
1267/* ── Settings Dropdown ── */
1268.settings-wrap {
1269 position: relative;
1270}
1271
1272.dropdown-overlay {
1273 position: fixed;
1274 inset: 0;
1275 z-index: 1;
1276}
1277
1278.settings-dropdown {
1279 --seg-track: var(--wk-c-menu-bg);
1280 --seg-pill-bg: var(--vp-c-bg);
1281 --seg-pill-text: var(--vp-c-text-1);
1282 --seg-pill-shadow: 0 2px 4px 0 #bababa8c;
1283 position: absolute;
1284 bottom: calc(100% + 8px);
1285 right: 0;
1286 z-index: 2;
1287 min-width: 196px;
1288 background: var(--vp-c-bg-elv);
1289 border: 1px solid var(--vp-c-divider);
1290 border-radius: 12px;
1291 padding: 12px;
1292 box-shadow: var(--vp-shadow-3);
1293}
1294
1295.dark .settings-dropdown {
1296 --seg-track: var(--wk-c-menu-bg);
1297 --seg-pill-bg: var(--vp-c-text-1);
1298 --seg-pill-text: var(--vp-c-bg-elv);
1299 --seg-pill-shadow: 0 2px 4px 0 #535353db;
1300}
1301
1302.dropdown-section + .dropdown-section {
1303 border-top: 1px solid var(--vp-c-divider);
1304 margin-top: 8px;
1305 padding-top: 8px;
1306}
1307
1308.dropdown-label {
1309 display: flex;
1310 align-items: center;
1311 gap: 6px;
1312 font-size: 14px;
1313 font-weight: 500;
1314 color: var(--vp-c-text-1);
1315 margin-bottom: 0;
1316}
1317
1318.dropdown-label-icon {
1319 width: 14px;
1320 height: 14px;
1321 flex-shrink: 0;
1322}
1323
1324.dropdown-group {
1325 display: flex;
1326 gap: 4px;
1327 background: var(--seg-track);
1328 border-radius: 8px;
1329 padding: 4px;
1330 outline: 2px dashed transparent;
1331 outline-offset: 4px;
1332 transition: outline-color 0.2s ease;
1333}
1334
1335.dropdown-group.is-highlighted {
1336 outline-color: var(--vp-c-brand-1);
1337}
1338
1339.dropdown-group .tool-btn {
1340 flex: 1;
1341 justify-content: center;
1342 border-radius: 6px;
1343 color: var(--vp-c-text-1);
1344 transition: color 0.15s, background 0.15s, box-shadow 0.15s;
1345}
1346
1347.dropdown-group .tool-btn:hover,
1348.dropdown-group .tool-btn.is-active {
1349 color: var(--seg-pill-text);
1350 background: var(--seg-pill-bg);
1351 box-shadow: var(--seg-pill-shadow);
1352}
1353
1354.dropdown-group .tool-btn.is-active {
1355 font-weight: 700;
1356}
1357
1358/* ── Drag Ghost ── */
1359.drag-ghost {
1360 position: fixed;
1361 pointer-events: none;
1362 z-index: 9999;
1363 display: flex;
1364 align-items: center;
1365 gap: 8px;
1366 padding: 6px 12px 6px 10px;
1367 background: var(--vp-c-bg);
1368 border: 1px solid var(--vp-c-brand-1);
1369 border-radius: 8px;
1370 box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
1371 opacity: 0.88;
1372 font-size: 14px;
1373 font-weight: 500;
1374 color: var(--vp-c-text-1);
1375 white-space: nowrap;
1376 user-select: none;
1377 transform: translate(12px, -50%);
1378}
1379
1380.drag-ghost-name {
1381 font-size: 14px;
1382 font-weight: 500;
1383 color: var(--vp-c-text-1);
1384}
1385
1386.ghost-fade-enter-active,
1387.ghost-fade-leave-active { transition: opacity 0.1s ease; }
1388.ghost-fade-enter-from,
1389.ghost-fade-leave-to { opacity: 0; }
1390
1391/* ── Transitions ── */
1392.fade-enter-active,
1393.fade-leave-active { transition: opacity 0.2s ease; }
1394.fade-enter-from,
1395.fade-leave-to { opacity: 0; }
1396
1397.slide-up-enter-active { transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease; }
1398.slide-up-leave-active { transition: transform 0.2s ease, opacity 0.15s ease; }
1399.slide-up-enter-from { transform: translateY(20px); opacity: 0; }
1400.slide-up-leave-to { transform: translateY(10px); opacity: 0; }
1401</style>