feat(ui): compact variants for QualityBadge and QconnectBadge

QualityBadge.compact now keeps the icon + color tier identity and the
downgrade/bit-perfect indicators; drops the tier-label row and shortens
'24-bit / 96 kHz' to '24/96' so the badge fits ~70px. The old plain-
text compact mode (inline tracklist usage) is replaced by this richer
variant.

QconnectBadge.compact is a 36x36 icon-only button; popup and color
behavior are unchanged. Hover title still surfaces the full state.

Both variants are opt-in via a 'compact' prop so existing callers are
unaffected; NowPlayingBar will flip them when the bar collapses (next
commit).

cc
This commit is contained in:
vicrodh committed 2026-04-13 20:14:07 -06:00
1 parent cc21a82d6c
commit 160dc7a52a
2 files changed
+98 -17

No files matched your search

+25 -4
View File
@@ -9,6 +9,9 @@
sessionSnapshot: QconnectSessionSnapshot | null;
onToggleConnection: () => void | Promise<void>;
busy?: boolean;
/** Narrow-bar variant: icon-only square button, popup behavior unchanged.
* Used by NowPlayingBar when the bar collapses (issue #303). */
compact?: boolean;
}
let {
@@ -16,6 +19,7 @@
sessionSnapshot: sessionSnapshotProp = null,
onToggleConnection,
busy = false,
compact = false,
}: Props = $props();
// Local snapshot that can be refreshed independently of the prop
@@ -99,8 +103,10 @@
<button
class="qconnect-badge"
class:active={connected}
class:compact
onclick={togglePopup}
title={connected ? $t('qconnect.statusConnected') : $t('qconnect.statusDisconnected')}
aria-label={$t('qconnect.title')}
>
<span class="badge-icon">
{#if activeDeviceType === 'web'}
@@ -113,10 +119,12 @@
<Monitor size={16} />
{/if}
</span>
<span class="badge-text">
<span class="badge-label">{ $t('platforms.qobuz') }</span>
<span class="badge-label">Connect</span>
</span>
{#if !compact}
<span class="badge-text">
<span class="badge-label">{ $t('platforms.qobuz') }</span>
<span class="badge-label">Connect</span>
</span>
{/if}
</button>
{#if isPopupOpen}
@@ -234,6 +242,19 @@
opacity: 0.85;
}
/* Compact variant: icon-only square, matches height of surrounding controls. */
.qconnect-badge.compact {
flex-direction: row;
width: 36px;
height: 36px;
padding: 0;
gap: 0;
}
.qconnect-badge.compact .badge-icon {
flex: 0 0 auto;
}
.badge-icon {
display: flex;
align-items: center;
+73 -13
View File
@@ -170,12 +170,19 @@
return '16-bit / 44.1 kHz';
});
// Format the compact display text
// Format the compact display text (short form for narrow bar).
// Drops the "bit"/"kHz" suffixes so the badge fits in ~70px: "24/96", "16/44",
// "MP3". Hover tooltip still shows the full string via the title attr.
const compactText = $derived.by(() => {
if (tier === 'max' || tier === 'hires') {
const depth = bitDepth || 24;
const rate = samplingRate || (tier === 'max' ? 192 : 96);
return `${depth}bit/${rate}kHz`;
return `${depth}/${Math.round(rate)}`;
}
if (tier === 'cd') {
const depth = bitDepth || 16;
const rate = samplingRate || 44.1;
return `${depth}/${Math.round(rate)}`;
}
if (tier === 'mp3') {
return 'MP3';
@@ -203,9 +210,38 @@
</script>
{#if compact}
<span class="quality-badge-compact" title="{tierLabel}: {displayText}">
{compactText}
</span>
<!-- svelte-ignore a11y_no_static_element_interactions -->
<div
class="quality-badge compact"
class:downgraded={isDowngraded}
class:adjusted={isQualityAdjusted}
class:plughw={isPluginFallback}
class:bitperfect={isBitPerfect}
title={`${tierLabel}: ${displayText}`}
onmouseenter={() => { isHovering = true; }}
onmouseleave={() => { isHovering = false; }}
>
<div class="icon-container compact-icon">
<img
src={iconPath}
alt={tierLabel}
class="badge-icon"
class:hires={isHiRes}
/>
</div>
<div class="badge-text compact-text">
<span class="quality-info compact-quality">
{compactText}
<span
class="downgrade-indicator"
class:visible={isDowngraded || isQualityAdjusted || isPluginFallback}
class:adjusted={isQualityAdjusted}
class:plughw={isPluginFallback}
>↓</span>
<span class="bitperfect-indicator" class:visible={isBitPerfect}>✓</span>
</span>
</div>
</div>
{:else}
<!-- svelte-ignore a11y_no_static_element_interactions -->
<div
@@ -292,14 +328,38 @@
{/if}
<style>
/* Compact mode styles - simple text like TrackRow */
.quality-badge-compact {
display: inline-block;
font-size: 12px;
color: #666666;
width: 80px;
text-align: center;
white-space: nowrap;
/* Compact mode: keeps the icon + color identity of the full badge but drops
the tier label row and shortens "24-bit / 96 kHz" to "24/96" so the whole
badge fits around 70px. Used by NowPlayingBar in narrow layouts (issue
#303). Downgrade/bit-perfect indicators still render next to the text. */
.quality-badge.compact {
min-width: 0;
width: auto;
padding: 4px 6px;
gap: 4px;
}
.quality-badge.compact .icon-container {
width: 20px;
height: 20px;
}
.quality-badge.compact .badge-icon {
width: 14px;
height: 14px;
}
.quality-badge.compact .badge-icon.hires {
width: 20px;
height: 20px;
}
.quality-badge.compact .compact-quality {
font-size: 11px;
font-weight: 500;
color: var(--text-primary);
letter-spacing: 0.2px;
font-family: 'LINE Seed JP', var(--font-sans);
}
/* Full mode styles */