fix(css): remove $t() from $derived() to fix PostCSS extraction

ImmersiveHeader splitTabs used $t() inside $derived(), causing
vite-plugin-svelte CSS extraction to receive raw script content
instead of CSS — cascading PostCSS errors to unrelated components.

ShortcutInput had the same pattern for displayShortcut.

Both now use the labelKey/function pattern instead.
This commit is contained in:
vicrodh committed 2026-02-07 12:13:24 -06:00
1 parent 28742fa19e
commit ecd006d176
2 files changed
+15 -11

No files matched your search

+9 -6
View File
@@ -30,11 +30,14 @@
let inputElement: HTMLButtonElement | null = $state(null);
const isModified = $derived(currentShortcut !== defaultShortcut);
const displayShortcut = $derived(
isRecording
? (recordedShortcut || $t('keybindings.pressKeys') || 'Press keys...')
: formatShortcutDisplay(currentShortcut)
);
// Never call $t() inside $derived() — use a function instead
function getDisplayShortcut(): string {
if (isRecording) {
return recordedShortcut || $t('keybindings.pressKeys') || 'Press keys...';
}
return formatShortcutDisplay(currentShortcut);
}
function startRecording() {
isRecording = true;
@@ -121,7 +124,7 @@
onkeydown={handleKeydown}
onblur={handleBlur}
>
<span class="shortcut-text">{displayShortcut}</span>
<span class="shortcut-text">{getDisplayShortcut()}</span>
{#if isModified && !isRecording}
<span class="modified-indicator" title={$t('keybindings.modified') || 'Modified'}>*</span>
{/if}
@@ -75,11 +75,12 @@
}
// Split mode tabs
// Use labelKey pattern — never call $t() inside $derived()
const splitTabs = $derived([
{ id: 'lyrics' as const, label: $t('player.lyrics'), icon: Music2, enabled: hasLyrics },
{ id: 'trackInfo' as const, label: $t('player.trackInfo') || 'Track Info', icon: Info, enabled: hasTrackInfo },
{ id: 'suggestions' as const, label: $t('player.suggestions') || 'Suggestions', icon: Radio, enabled: hasSuggestions },
{ id: 'queue' as const, label: $t('player.queue') || 'Queue', icon: ListMusic, enabled: true },
{ id: 'lyrics' as const, labelKey: 'player.lyrics', icon: Music2, enabled: hasLyrics },
{ id: 'trackInfo' as const, labelKey: 'player.trackInfo', icon: Info, enabled: hasTrackInfo },
{ id: 'suggestions' as const, labelKey: 'player.suggestions', icon: Radio, enabled: hasSuggestions },
{ id: 'queue' as const, labelKey: 'player.queue', icon: ListMusic, enabled: true },
].filter(tab => tab.enabled));
// Focus mode tabs
@@ -134,7 +135,7 @@
onclick={() => onTabChange(tab.id)}
>
<tab.icon size={16} />
<span class="tab-label">{tab.label}</span>
<span class="tab-label">{$t(tab.labelKey)}</span>
</button>
{/each}
{/if}