From 5f3b4631e676eed51fa4d53ee5a87e267b0ceff6 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Mon, 19 Jan 2026 13:26:56 -0600 Subject: [PATCH] Add ticker animation for long device names in badge tooltip Adds scrolling animation when device names overflow tooltip width, borrowed from AlbumCard component pattern. Also fixes accessibility warning by adding role and aria-label to badge container. --- src/lib/components/AudioOutputBadges.svelte | 57 ++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/src/lib/components/AudioOutputBadges.svelte b/src/lib/components/AudioOutputBadges.svelte index 5d9d82efb..04f8f11d9 100644 --- a/src/lib/components/AudioOutputBadges.svelte +++ b/src/lib/components/AudioOutputBadges.svelte @@ -45,6 +45,14 @@ let hardwareStatus = $state(null); let isHovering = $state(false); + // Ticker animation for long device names + let deviceNameRef: HTMLDivElement | null = $state(null); + let deviceNameTextRef: HTMLSpanElement | null = $state(null); + let deviceNameOverflow = $state(0); + const deviceNameOffset = $derived(deviceNameOverflow > 0 ? `-${deviceNameOverflow + 16}px` : '0px'); + const tickerSpeed = 80; // pixels per second + const deviceNameDuration = $derived(deviceNameOverflow > 0 ? `${(deviceNameOverflow + 16) / tickerSpeed}s` : '0s'); + // Derived state const currentDevice = $derived(outputStatus?.device_name ?? null); @@ -147,6 +155,23 @@ } } + // Update outputStatus when hovering to get fresh device name + $effect(() => { + if (isHovering && !outputStatus) { + invoke('get_audio_output_status') + .then(status => outputStatus = status) + .catch(() => {}); + } + }); + + // Calculate overflow for ticker animation when tooltip is visible + $effect(() => { + if (isHovering && deviceNameRef && deviceNameTextRef) { + const overflow = deviceNameTextRef.scrollWidth - deviceNameRef.clientWidth; + deviceNameOverflow = overflow > 0 ? overflow : 0; + } + }); + onMount(() => { loadStatus(); @@ -170,6 +195,8 @@
isHovering = true} onmouseleave={() => isHovering = false} > @@ -205,7 +232,16 @@
Output Device
-
{prettyDeviceName}
+
0} + style="--ticker-offset: {deviceNameOffset}; --ticker-duration: {deviceNameDuration};" + bind:this={deviceNameRef} + > + + {prettyDeviceName} + +
{#if currentDevice && currentDevice !== prettyDeviceName}
{currentDevice}
{/if} @@ -367,6 +403,25 @@ text-overflow: ellipsis; } + .tooltip-device.scrollable { + text-overflow: clip; + } + + .device-name-text { + display: inline-block; + white-space: nowrap; + } + + .device-tooltip:hover .tooltip-device.scrollable .device-name-text { + animation: device-name-ticker var(--ticker-duration) linear infinite; + will-change: transform; + } + + @keyframes device-name-ticker { + from { transform: translateX(0); } + to { transform: translateX(var(--ticker-offset)); } + } + .tooltip-raw { font-size: 9px; color: rgba(255, 255, 255, 0.3);