Commit 49b7f7506c
Unsigned
Layout: unified · split
docs/.vitepress/theme/Layout.vue +41 −1
| @@ -283,6 +283,46 @@ const reloadTakodachi = () => { | |||
| 283 | onMounted(() => { | 283 | onMounted(() => { |
| 284 | if (import.meta.env.SSR) return | 284 | if (import.meta.env.SSR) return |
| 285 | 285 | ||
| 286 | // Icon tooltip: fixed-position popup appended to <body> to escape table overflow clipping | ||
| 287 | const tooltipEl = document.createElement('div') | ||
| 288 | tooltipEl.className = 'icon-tip-popup' | ||
| 289 | document.body.appendChild(tooltipEl) | ||
| 290 | |||
| 291 | const showTooltip = (e: MouseEvent) => { | ||
| 292 | const target = (e.target as HTMLElement).closest('.icon-tip') as HTMLElement | null | ||
| 293 | if (!target) return | ||
| 294 | const tip = target.dataset.tip | ||
| 295 | if (!tip) return | ||
| 296 | |||
| 297 | tooltipEl.textContent = tip | ||
| 298 | tooltipEl.classList.add('visible') | ||
| 299 | |||
| 300 | const rect = target.getBoundingClientRect() | ||
| 301 | const tipWidth = tooltipEl.offsetWidth | ||
| 302 | const tipHeight = tooltipEl.offsetHeight | ||
| 303 | let left = rect.left + rect.width / 2 - tipWidth / 2 | ||
| 304 | left = Math.max(8, Math.min(left, window.innerWidth - tipWidth - 8)) | ||
| 305 | const top = rect.top - tipHeight - 6 | ||
| 306 | |||
| 307 | tooltipEl.style.left = `${left}px` | ||
| 308 | tooltipEl.style.top = `${top}px` | ||
| 309 | } | ||
| 310 | |||
| 311 | const hideTooltip = () => { | ||
| 312 | tooltipEl.classList.remove('visible') | ||
| 313 | } | ||
| 314 | |||
| 315 | document.addEventListener('mouseover', showTooltip) | ||
| 316 | document.addEventListener('mouseout', hideTooltip) | ||
| 317 | document.addEventListener('scroll', hideTooltip, true) | ||
| 318 | |||
| 319 | onUnmounted(() => { | ||
| 320 | document.removeEventListener('mouseover', showTooltip) | ||
| 321 | document.removeEventListener('mouseout', hideTooltip) | ||
| 322 | document.removeEventListener('scroll', hideTooltip, true) | ||
| 323 | tooltipEl.remove() | ||
| 324 | }) | ||
| 325 | |||
| 286 | // Arrow key scrolling + Escape close for sidebars and content | 326 | // Arrow key scrolling + Escape close for sidebars and content |
| 287 | let activeScrollTarget: HTMLElement | Window = window | 327 | let activeScrollTarget: HTMLElement | Window = window |
| 288 | 328 | ||
| @@ -487,4 +527,4 @@ onUnmounted(() => { | |||
| 487 | </span> | 527 | </span> |
| 488 | </template> | 528 | </template> |
| 489 | </Layout> | 529 | </Layout> |
| 490 | </template> | 530 | </template>\ No newline at end of file |
docs/.vitepress/theme/styles/style.scss +18 −22
| @@ -1471,29 +1471,25 @@ html.reduce-blur-effects { | |||
| 1471 | display: inline-block; | 1471 | display: inline-block; |
| 1472 | vertical-align: -0.125em; | 1472 | vertical-align: -0.125em; |
| 1473 | cursor: help; | 1473 | cursor: help; |
| 1474 | } | ||
| 1474 | 1475 | ||
| 1475 | &::after { | 1476 | /* Fixed-position tooltip rendered into <body> by JS to escape table overflow clipping */ |
| 1476 | content: attr(data-tip); | 1477 | .icon-tip-popup { |
| 1477 | position: absolute; | 1478 | position: fixed; |
| 1478 | bottom: calc(100% + 6px); | 1479 | padding: 4px 8px; |
| 1479 | left: 50%; | 1480 | border-radius: 6px; |
| 1480 | transform: translateX(-50%); | 1481 | background: var(--vp-c-bg-elv); |
| 1481 | padding: 4px 8px; | 1482 | color: var(--vp-c-text-1); |
| 1482 | border-radius: 6px; | 1483 | font-size: 12px; |
| 1483 | background: var(--vp-c-bg-elv); | 1484 | line-height: 1.4; |
| 1484 | color: var(--vp-c-text-1); | 1485 | white-space: nowrap; |
| 1485 | font-size: 12px; | 1486 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); |
| 1486 | line-height: 1.4; | 1487 | pointer-events: none; |
| 1487 | white-space: nowrap; | 1488 | z-index: 9999; |
| 1488 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); | 1489 | opacity: 0; |
| 1489 | pointer-events: none; | 1490 | transition: opacity 0.15s; |
| 1490 | opacity: 0; | 1491 | |
| 1491 | transition: opacity 0.15s; | 1492 | &.visible { |
| 1492 | z-index: 10; | ||
| 1493 | } | ||
| 1494 | |||
| 1495 | &:hover::after, | ||
| 1496 | &:focus::after { | ||
| 1497 | opacity: 1; | 1493 | opacity: 1; |
| 1498 | } | 1494 | } |
| 1499 | } | 1495 | } |