fix(context): add custom tooltip and pass onClick callback

- Implemented custom tooltip for StackIcon (similar to AudioOutputBadges)
- Shows 'Playing from', context name, and 'Click to navigate' hint
- Added onContextClick={handleContextNavigation} to ExpandedPlayer
- Fixed onClick prop not being passed, enabling navigation

cp
This commit is contained in:
vicrodh committed 2026-01-18 04:34:42 -06:00
1 parent 0feb1e1b4a
commit 92f1644601
2 files changed
+76 -7

No files matched your search

+75 -7
View File
@@ -14,6 +14,7 @@
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();
@@ -58,17 +59,35 @@
</script>
{#if context && displayInfo && showIcon}
<button
class="stack-icon-wrapper {className}"
title="Click to go to: {displayInfo}"
onclick={handleClick}
type="button"
<div
class="stack-icon-container {className}"
onmouseenter={() => isHovering = true}
onmouseleave={() => isHovering = false}
>
<Layers size={size} strokeWidth={2} />
</button>
<button
class="stack-icon-wrapper"
onclick={handleClick}
type="button"
>
<Layers size={size} strokeWidth={2} />
</button>
{#if isHovering}
<div class="context-tooltip">
<div class="tooltip-label">Playing from</div>
<div class="tooltip-value">{displayInfo}</div>
<div class="tooltip-hint">Click to navigate</div>
</div>
{/if}
</div>
{/if}
<style>
.stack-icon-container {
position: relative;
display: inline-flex;
}
.stack-icon-wrapper {
display: inline-flex;
align-items: center;
@@ -93,4 +112,53 @@
.stack-icon-wrapper:active {
transform: scale(0.95);
}
.context-tooltip {
position: absolute;
bottom: calc(100% + 8px);
left: 50%;
transform: translateX(-50%);
background: rgba(24, 24, 28, 0.98);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 6px;
padding: 8px 12px;
min-width: 140px;
max-width: 220px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
z-index: 9999;
animation: tooltip-appear 150ms ease;
pointer-events: none;
white-space: nowrap;
}
@keyframes tooltip-appear {
from {
opacity: 0;
transform: translateX(-50%) translateY(4px);
}
to {
opacity: 1;
transform: translateX(-50%) translateY(0);
}
}
.tooltip-label {
font-size: 9px;
text-transform: uppercase;
letter-spacing: 0.5px;
color: rgba(255, 255, 255, 0.4);
margin-bottom: 4px;
}
.tooltip-value {
font-size: 12px;
font-weight: 500;
color: white;
}
.tooltip-hint {
font-size: 10px;
color: rgba(255, 255, 255, 0.5);
margin-top: 4px;
}
</style>