feat: Add radio icon with pulse animation to StackIcon component
This commit is contained in:
1 parent
ba4f7af909
commit
343b82d772
1 file changed
+29
-2
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Layers } from 'lucide-svelte';
|
import { Layers, Radio } from 'lucide-svelte';
|
||||||
import { subscribe, getCurrentContext, getContextDisplayInfo } from '$lib/stores/playbackContextStore';
|
import { subscribe, getCurrentContext, getContextDisplayInfo } from '$lib/stores/playbackContextStore';
|
||||||
import { subscribe as subscribePrefs, getCachedPreferences } from '$lib/stores/playbackPreferencesStore';
|
import { subscribe as subscribePrefs, getCachedPreferences } from '$lib/stores/playbackPreferencesStore';
|
||||||
|
|
||||||
@@ -15,6 +15,9 @@
|
|||||||
let displayInfo = $state(context ? getContextDisplayInfo() : null);
|
let displayInfo = $state(context ? getContextDisplayInfo() : null);
|
||||||
let showIcon = $state(getCachedPreferences().show_context_icon);
|
let showIcon = $state(getCachedPreferences().show_context_icon);
|
||||||
|
|
||||||
|
// Check if the current context is radio
|
||||||
|
let isRadio = $derived(context?.type === 'radio');
|
||||||
|
|
||||||
function handleClick(e: MouseEvent) {
|
function handleClick(e: MouseEvent) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -52,12 +55,17 @@
|
|||||||
{#if context && displayInfo && showIcon}
|
{#if context && displayInfo && showIcon}
|
||||||
<button
|
<button
|
||||||
class="stack-icon-wrapper {className}"
|
class="stack-icon-wrapper {className}"
|
||||||
|
class:radio-active={isRadio}
|
||||||
onclick={handleClick}
|
onclick={handleClick}
|
||||||
title={displayInfo ? `Playing from: ${displayInfo}` : undefined}
|
title={displayInfo ? `Playing from: ${displayInfo}` : undefined}
|
||||||
aria-label={displayInfo ? `Playing from: ${displayInfo}` : 'Playback context'}
|
aria-label={displayInfo ? `Playing from: ${displayInfo}` : 'Playback context'}
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<Layers size={size} strokeWidth={2} />
|
{#if isRadio}
|
||||||
|
<Radio size={size} strokeWidth={2} />
|
||||||
|
{:else}
|
||||||
|
<Layers size={size} strokeWidth={2} />
|
||||||
|
{/if}
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
@@ -92,4 +100,23 @@
|
|||||||
outline: 2px solid var(--accent-primary);
|
outline: 2px solid var(--accent-primary);
|
||||||
outline-offset: 2px;
|
outline-offset: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Radio icon pulse animation */
|
||||||
|
.stack-icon-wrapper.radio-active {
|
||||||
|
animation: radio-pulse 2s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes radio-pulse {
|
||||||
|
0%, 100% {
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.stack-icon-wrapper.radio-active:hover {
|
||||||
|
animation: none;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
Reference in new issue
Block a user