feat(lyrics-ui): refine layouts and add mini view

This commit is contained in:
vicrodh committed 2026-01-10 06:19:40 -06:00
1 parent f0748910c2
commit a3a766ba34
4 files changed
+309 -29

No files matched your search

@@ -12,6 +12,8 @@
align?: 'left' | 'center';
title?: string;
artist?: string;
artwork?: string;
backgroundUrl?: string;
}
let {
@@ -20,47 +22,110 @@
activeProgress = 0,
align = 'center',
title = '',
artist = ''
artist = '',
artwork,
backgroundUrl
}: Props = $props();
const isCenter = $derived(align === 'center');
const hasArtwork = $derived(!!artwork);
const backgroundStyle = $derived(
backgroundUrl ? `--lyrics-artwork-bg: url('${backgroundUrl}')` : undefined
);
</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>
<section
class="lyrics-immersive"
class:center={isCenter}
class:no-artwork={!hasArtwork}
style={backgroundStyle}
>
{#if hasArtwork}
<div class="artwork-pane">
<div class="artwork-frame">
<img src={artwork} alt={title || 'Artwork'} />
</div>
</div>
{/if}
<LyricsLines
{lines}
{activeIndex}
{activeProgress}
center={isCenter}
compact={false}
/>
<div class="lyrics-pane">
<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}
/>
</div>
</section>
<style>
.lyrics-immersive {
display: flex;
flex-direction: column;
display: grid;
grid-template-columns: minmax(260px, 40%) minmax(0, 60%);
gap: 48px;
height: 100%;
width: 100%;
padding: 40px 48px;
padding: 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));
background-image:
radial-gradient(circle at top right, rgba(148, 92, 48, 0.35), transparent 55%),
linear-gradient(120deg, rgba(12, 10, 9, 0.92), rgba(44, 30, 20, 0.9)),
var(--lyrics-artwork-bg, none);
background-size: cover;
background-position: center;
--lyrics-font-size: 20px;
--lyrics-active-size: 28px;
--lyrics-line-gap: 18px;
--lyrics-line-height: 1.5;
--lyrics-dimmed-opacity: 0.38;
--lyrics-highlight-muted: rgba(255, 255, 255, 0.2);
}
.lyrics-immersive.no-artwork {
grid-template-columns: 1fr;
}
.lyrics-immersive.center {
align-items: center;
}
.artwork-pane {
display: flex;
align-items: center;
justify-content: center;
}
.artwork-frame {
width: min(420px, 100%);
aspect-ratio: 1 / 1;
border-radius: 18px;
overflow: hidden;
box-shadow: 0 28px 60px rgba(0, 0, 0, 0.55);
border: 1px solid rgba(255, 255, 255, 0.08);
}
.artwork-frame img {
width: 100%;
height: 100%;
object-fit: cover;
}
.lyrics-pane {
display: flex;
flex-direction: column;
min-height: 0;
}
.header {
margin-bottom: 24px;
margin-bottom: 20px;
}
.title {
@@ -71,7 +136,7 @@
}
.artist {
font-size: 18px;
font-size: 20px;
font-weight: 600;
color: var(--text-primary);
}
+5 -4
View File
@@ -74,7 +74,7 @@
.lyrics-lines {
display: flex;
flex-direction: column;
gap: 16px;
gap: var(--lyrics-line-gap, 16px);
padding: 12px 16px 24px 16px;
overflow-y: auto;
height: 100%;
@@ -95,12 +95,13 @@
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;
transition: color 180ms ease, opacity 180ms ease, transform 180ms ease, filter 180ms ease;
position: relative;
}
.lyrics-line.dimmed {
opacity: var(--lyrics-dimmed-opacity, 0.45);
opacity: var(--lyrics-dimmed-opacity, 0.4);
filter: blur(var(--lyrics-dimmed-blur, 0px));
}
.lyrics-line.active {
@@ -116,7 +117,7 @@
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%)
var(--lyrics-highlight-muted, rgba(255, 255, 255, 0.25)) calc(var(--line-progress, 0) * 100%)
);
-webkit-background-clip: text;
background-clip: text;
+206
View File
@@ -0,0 +1,206 @@
<script lang="ts">
import { Pause, Play, SkipBack, SkipForward } from 'lucide-svelte';
import LyricsLines from './LyricsLines.svelte';
interface LyricsLine {
text: string;
}
interface Props {
lines: LyricsLine[];
activeIndex?: number;
activeProgress?: number;
title?: string;
artist?: string;
artwork?: string;
isPlaying?: boolean;
onTogglePlay?: () => void;
onSkipBack?: () => void;
onSkipForward?: () => void;
}
let {
lines,
activeIndex = -1,
activeProgress = 0,
title = '',
artist = '',
artwork,
isPlaying = false,
onTogglePlay,
onSkipBack,
onSkipForward
}: Props = $props();
const canToggle = $derived(!!onTogglePlay);
const canSkipBack = $derived(!!onSkipBack);
const canSkipForward = $derived(!!onSkipForward);
</script>
<div class="lyrics-mini">
<div class="lyrics-mini-body">
<LyricsLines
{lines}
{activeIndex}
{activeProgress}
compact={true}
center={false}
/>
</div>
<div class="lyrics-mini-player">
<div class="track-info">
<div class="artwork">
{#if artwork}
<img src={artwork} alt={title || 'Artwork'} />
{:else}
<div class="artwork-placeholder"></div>
{/if}
</div>
<div class="meta">
<div class="track-title">{title || 'Unknown track'}</div>
<div class="track-artist">{artist || 'Unknown artist'}</div>
</div>
</div>
<div class="controls">
<button class="control-btn" onclick={onSkipBack} disabled={!canSkipBack}>
<SkipBack size={18} />
</button>
<button class="control-btn primary" onclick={onTogglePlay} disabled={!canToggle}>
{#if isPlaying}
<Pause size={18} />
{:else}
<Play size={18} />
{/if}
</button>
<button class="control-btn" onclick={onSkipForward} disabled={!canSkipForward}>
<SkipForward size={18} />
</button>
</div>
</div>
</div>
<style>
.lyrics-mini {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
background: linear-gradient(160deg, rgba(69, 46, 26, 0.95), rgba(30, 20, 12, 0.98));
color: var(--text-primary);
border-radius: 18px;
overflow: hidden;
--lyrics-font-size: 16px;
--lyrics-active-size: 22px;
--lyrics-line-gap: 12px;
--lyrics-line-height: 1.4;
--lyrics-dimmed-opacity: 0.35;
--lyrics-highlight-muted: rgba(255, 255, 255, 0.22);
}
.lyrics-mini-body {
flex: 1;
min-height: 0;
padding: 18px 18px 8px 18px;
overflow: hidden;
}
.lyrics-mini-body :global(.lyrics-lines) {
padding: 0;
}
.lyrics-mini-player {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 12px 16px;
background: rgba(0, 0, 0, 0.35);
border-top: 1px solid rgba(255, 255, 255, 0.08);
backdrop-filter: blur(12px);
}
.track-info {
display: flex;
align-items: center;
gap: 12px;
min-width: 0;
}
.artwork {
width: 44px;
height: 44px;
border-radius: 10px;
overflow: hidden;
background: rgba(255, 255, 255, 0.08);
display: grid;
place-items: center;
}
.artwork img {
width: 100%;
height: 100%;
object-fit: cover;
}
.artwork-placeholder {
width: 60%;
height: 60%;
border-radius: 8px;
background: rgba(255, 255, 255, 0.12);
}
.meta {
min-width: 0;
}
.track-title {
font-size: 14px;
font-weight: 600;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.track-artist {
font-size: 12px;
color: rgba(255, 255, 255, 0.7);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.controls {
display: flex;
align-items: center;
gap: 8px;
}
.control-btn {
width: 32px;
height: 32px;
display: grid;
place-items: center;
border: none;
border-radius: 10px;
background: rgba(255, 255, 255, 0.08);
color: var(--text-primary);
cursor: pointer;
transition: background 160ms ease, transform 160ms ease, opacity 160ms ease;
}
.control-btn.primary {
background: rgba(255, 255, 255, 0.2);
}
.control-btn:disabled {
cursor: default;
opacity: 0.4;
}
.control-btn:not(:disabled):hover {
background: rgba(255, 255, 255, 0.2);
transform: translateY(-1px);
}
</style>
+11 -3
View File
@@ -29,7 +29,7 @@
}: Props = $props();
</script>
<aside class="lyrics-sidebar">
<aside class="lyrics-sidebar">
<div class="header">
<div class="header-icon">
<Mic2 size={18} />
@@ -65,20 +65,28 @@
<style>
.lyrics-sidebar {
width: var(--lyrics-sidebar-width, 320px);
min-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));
background: linear-gradient(160deg, rgba(52, 38, 26, 0.92), rgba(22, 17, 12, 0.95));
color: var(--text-primary);
backdrop-filter: blur(14px);
--lyrics-font-size: 15px;
--lyrics-active-size: 20px;
--lyrics-line-gap: 12px;
--lyrics-line-height: 1.5;
--lyrics-dimmed-opacity: 0.35;
--lyrics-highlight-muted: rgba(255, 255, 255, 0.22);
--lyrics-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}
.header {
display: flex;
align-items: center;
gap: 12px;
padding: 18px 16px 10px 16px;
padding: 18px 16px 12px 16px;
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}