feat(lyrics-ui): add isolated lyrics UI components

This commit is contained in:
vicrodh committed 2026-01-10 06:19:36 -06:00
1 parent 489d73496a
commit f0748910c2
3 files changed
+351

No files matched your search

@@ -0,0 +1,78 @@
<script lang="ts">
import LyricsLines from './LyricsLines.svelte';
interface LyricsLine {
text: string;
}
interface Props {
lines: LyricsLine[];
activeIndex?: number;
activeProgress?: number;
align?: 'left' | 'center';
title?: string;
artist?: string;
}
let {
lines,
activeIndex = -1,
activeProgress = 0,
align = 'center',
title = '',
artist = ''
}: Props = $props();
const isCenter = $derived(align === 'center');
</script>
<section class="lyrics-immersive" class:center={isCenter}>
<div class="header">
{#if title || artist}
<div class="title">{title}</div>
<div class="artist">{artist}</div>
{/if}
</div>
<LyricsLines
{lines}
{activeIndex}
{activeProgress}
center={isCenter}
compact={false}
/>
</section>
<style>
.lyrics-immersive {
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
padding: 40px 48px;
color: var(--text-primary);
background: radial-gradient(circle at top right, rgba(120, 74, 40, 0.35), transparent 55%),
linear-gradient(120deg, rgba(14, 12, 10, 0.9), rgba(44, 32, 22, 0.85));
}
.lyrics-immersive.center {
align-items: center;
}
.header {
margin-bottom: 24px;
}
.title {
font-size: 14px;
text-transform: uppercase;
letter-spacing: 0.16em;
color: var(--text-muted);
}
.artist {
font-size: 18px;
font-weight: 600;
color: var(--text-primary);
}
</style>
@@ -0,0 +1,132 @@
<script lang="ts">
import { onMount } from 'svelte';
interface LyricsLine {
text: string;
}
interface Props {
lines: LyricsLine[];
activeIndex?: number;
activeProgress?: number;
dimInactive?: boolean;
center?: boolean;
compact?: boolean;
scrollToActive?: boolean;
}
let {
lines,
activeIndex = -1,
activeProgress = 0,
dimInactive = true,
center = false,
compact = false,
scrollToActive = true
}: Props = $props();
let container: HTMLDivElement | null = null;
function scrollActiveIntoView() {
if (!container || activeIndex < 0) return;
const target = container.querySelector<HTMLElement>(`[data-line-index=\"${activeIndex}\"]`);
if (!target) return;
target.scrollIntoView({ block: 'center', behavior: 'smooth' });
}
onMount(() => {
if (scrollToActive) {
scrollActiveIntoView();
}
});
$effect(() => {
if (scrollToActive) {
scrollActiveIntoView();
}
});
</script>
<div
class="lyrics-lines"
class:compact={compact}
class:center={center}
bind:this={container}
>
{#if lines.length === 0}
<div class="lyrics-empty">No lyrics available</div>
{:else}
{#each lines as line, index}
<div
class="lyrics-line"
class:active={index === activeIndex}
class:dimmed={dimInactive && index !== activeIndex}
style={index === activeIndex ? `--line-progress: ${Math.max(0, Math.min(1, activeProgress))}` : undefined}
data-line-index={index}
>
<span class="line-text">{line.text}</span>
</div>
{/each}
{/if}
</div>
<style>
.lyrics-lines {
display: flex;
flex-direction: column;
gap: 16px;
padding: 12px 16px 24px 16px;
overflow-y: auto;
height: 100%;
scroll-behavior: smooth;
}
.lyrics-lines.center {
text-align: center;
}
.lyrics-lines.compact {
gap: 10px;
}
.lyrics-line {
color: var(--lyrics-color, var(--text-muted));
font-family: var(--lyrics-font-family, var(--font-sans));
font-size: var(--lyrics-font-size, 18px);
line-height: var(--lyrics-line-height, 1.45);
letter-spacing: 0.01em;
transition: color 180ms ease, opacity 180ms ease, transform 180ms ease;
position: relative;
}
.lyrics-line.dimmed {
opacity: var(--lyrics-dimmed-opacity, 0.45);
}
.lyrics-line.active {
color: var(--lyrics-active-color, var(--text-primary));
font-size: var(--lyrics-active-size, 24px);
font-weight: 600;
opacity: 1;
transform: translateX(0);
text-shadow: var(--lyrics-shadow, 0 10px 30px rgba(0, 0, 0, 0.45));
}
.lyrics-line.active .line-text {
background: linear-gradient(
90deg,
var(--lyrics-active-color, var(--text-primary)) calc(var(--line-progress, 0) * 100%),
rgba(255, 255, 255, 0.35) calc(var(--line-progress, 0) * 100%)
);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
.lyrics-empty {
color: var(--text-muted);
font-size: 14px;
text-align: center;
padding: 24px 0;
}
</style>
@@ -0,0 +1,141 @@
<script lang="ts">
import { Mic2 } from 'lucide-svelte';
import LyricsLines from './LyricsLines.svelte';
interface LyricsLine {
text: string;
}
interface Props {
title?: string;
artist?: string;
provider?: string;
lines: LyricsLine[];
activeIndex?: number;
activeProgress?: number;
isLoading?: boolean;
error?: string | null;
}
let {
title = '',
artist = '',
provider,
lines,
activeIndex = -1,
activeProgress = 0,
isLoading = false,
error = null
}: Props = $props();
</script>
<aside class="lyrics-sidebar">
<div class="header">
<div class="header-icon">
<Mic2 size={18} />
</div>
<div class="header-text">
<div class="header-title">Lyrics</div>
{#if title || artist}
<div class="header-meta">{title}{title && artist ? ' - ' : ''}{artist}</div>
{/if}
</div>
{#if provider}
<div class="header-provider">{provider}</div>
{/if}
</div>
<div class="panel">
{#if isLoading}
<div class="state">Loading lyrics...</div>
{:else if error}
<div class="state error">{error}</div>
{:else}
<LyricsLines
{lines}
{activeIndex}
{activeProgress}
compact={true}
center={false}
/>
{/if}
</div>
</aside>
<style>
.lyrics-sidebar {
width: var(--lyrics-sidebar-width, 320px);
height: calc(100vh - 80px);
display: flex;
flex-direction: column;
border-left: 1px solid rgba(255, 255, 255, 0.06);
background: linear-gradient(160deg, rgba(54, 44, 34, 0.8), rgba(23, 21, 18, 0.9));
color: var(--text-primary);
backdrop-filter: blur(14px);
}
.header {
display: flex;
align-items: center;
gap: 12px;
padding: 18px 16px 10px 16px;
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.header-icon {
width: 34px;
height: 34px;
display: grid;
place-items: center;
background: rgba(255, 255, 255, 0.08);
border-radius: 10px;
color: var(--accent-primary);
}
.header-text {
flex: 1;
min-width: 0;
}
.header-title {
font-size: 14px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.16em;
color: var(--text-muted);
}
.header-meta {
font-size: 13px;
color: var(--text-primary);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.header-provider {
font-size: 11px;
font-weight: 600;
color: var(--text-muted);
border: 1px solid rgba(255, 255, 255, 0.1);
padding: 4px 8px;
border-radius: 999px;
text-transform: uppercase;
letter-spacing: 0.08em;
}
.panel {
flex: 1;
position: relative;
}
.state {
padding: 24px 16px;
font-size: 14px;
color: var(--text-muted);
}
.state.error {
color: #f4a1a1;
}
</style>