fix(phase3): custom tooltip for context icon

- Replace native title with custom tooltip similar to DAC/EXC badges
- Add hover state and styled tooltip with context info
- Add debug logs to investigate onClick callback issue

cp
This commit is contained in:
vicrodh committed 2026-01-18 04:58:35 -06:00
1 parent 12067d7a61
commit d96233730b
1 file changed
+51 -3
+51 -3
View File
@@ -14,12 +14,17 @@
let context = $state(getCurrentContext());
let displayInfo = $state(context ? getContextDisplayInfo() : null);
let showIcon = $state(getCachedPreferences().show_context_icon);
let isHovering = $state(false);
function handleClick(e: MouseEvent) {
e.stopPropagation();
e.preventDefault();
console.log('[StackIcon] Clicked, onClick=', onClick, 'typeof=', typeof onClick);
if (onClick) {
console.log('[StackIcon] Calling onClick callback');
onClick();
} else {
console.warn('[StackIcon] No onClick callback provided');
}
}
@@ -28,7 +33,6 @@
const unsubscribe = subscribe(() => {
const newContext = getCurrentContext();
const newDisplayInfo = newContext ? getContextDisplayInfo() : null;
console.log('[StackIcon] Context changed:', { newContext, newDisplayInfo });
context = newContext;
displayInfo = newDisplayInfo;
});
@@ -42,7 +46,6 @@
$effect(() => {
const unsubscribe = subscribePrefs(() => {
showIcon = getCachedPreferences().show_context_icon;
console.log('[StackIcon] Icon visibility:', showIcon);
});
return () => {
@@ -55,10 +58,19 @@
<button
class="stack-icon-wrapper {className}"
onclick={handleClick}
onmouseenter={() => isHovering = true}
onmouseleave={() => isHovering = false}
type="button"
title="Playing from {displayInfo} (click to navigate)"
>
<Layers size={size} strokeWidth={2} />
{#if isHovering}
<div class="context-tooltip">
<div class="tooltip-text">Playing from</div>
<div class="tooltip-context">{displayInfo}</div>
<div class="tooltip-hint">Click to navigate</div>
</div>
{/if}
</button>
{/if}
@@ -76,6 +88,7 @@
padding: 4px;
border-radius: 4px;
cursor: pointer;
position: relative;
}
.stack-icon-wrapper:hover {
@@ -87,4 +100,39 @@
.stack-icon-wrapper:active {
transform: scale(0.95);
}
.context-tooltip {
position: absolute;
bottom: calc(100% + 8px);
left: 50%;
transform: translateX(-50%);
background: rgba(20, 20, 20, 0.95);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 8px;
padding: 8px 12px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
white-space: nowrap;
z-index: 1000;
pointer-events: none;
}
.tooltip-text {
font-size: 11px;
color: rgba(255, 255, 255, 0.6);
margin-bottom: 2px;
}
.tooltip-context {
font-size: 13px;
font-weight: 500;
color: rgba(255, 255, 255, 0.9);
margin-bottom: 2px;
}
.tooltip-hint {
font-size: 11px;
color: rgba(255, 255, 255, 0.5);
font-style: italic;
}
</style>