Commit 95b835fc authored by Aryan Noshirvnai's avatar Aryan Noshirvnai

Rebuild FullPlayer lyrics to match Spotify's actual current pattern

Researched how Spotify actually surfaces lyrics rather than guessing:
the live synced line plays right under the cover art on the main Now
Playing screen at all times, no tap needed, and the full scrollable
view is a step deeper reached by swiping up (with a tap on the line
itself kept as a focusable fallback, since Spotify keeps one too).

Replaces the previous "tap a bar to crossfade cover/lyrics in place"
implementation, which showed a static first line rather than the
actually-playing one and still needed an explicit tap to see anything
at all. Lyrics is now a real slide-up screen (mirroring Queue's own
push-navigation pattern) with its own back control, swipe-down close,
Escape, and system back support.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
parent 7c321a44
Pipeline #1160 passed with stage
in 5 minutes and 45 seconds
import { render, screen, waitFor, within } from '@testing-library/react'
import { fireEvent, render, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { PlayerProvider, usePlayer, type PlayableSong } from '../context/PlayerContext'
......@@ -64,6 +64,19 @@ function dialog() {
return within(screen.getByRole('dialog'))
}
// The inline lyric line under the cover art - its accessible name always starts with "Lyrics:"
// (see FullPlayer's aria-label), followed by whatever line is currently showing, so tests that
// don't care about the exact text match on the prefix instead.
function lyricsLineButton() {
return screen.getByRole('button', { name: /^Lyrics:/ })
}
// Fires the pointer sequence FullPlayer's swipe-up/swipe-down handlers listen for.
function verticalSwipe(target: HTMLElement, fromY: number, toY: number) {
fireEvent.pointerDown(target, { clientY: fromY, pointerId: 1 })
fireEvent.pointerUp(target, { clientY: toY, pointerId: 1 })
}
describe('FullPlayer', () => {
beforeEach(() => {
// Default: no synced timing available - matches the plain-text-only fallback path most
......@@ -88,28 +101,77 @@ describe('FullPlayer', () => {
expect(dialog().getByRole('button', { name: 'Open queue' })).toBeInTheDocument()
})
it('toggles lyrics in place (crossfade) rather than navigating to a separate screen', async () => {
it('shows the live lyric line right under the cover art, with no tap needed to see it', async () => {
vi.spyOn(streamApi, 'fetchStreamUrl').mockResolvedValue('blob:fake-url')
renderPlayer()
await userEvent.click(screen.getByText('Start Playback'))
await openFullPlayer()
const toggleButton = screen.getByRole('button', { name: 'Show lyrics' })
await userEvent.click(toggleButton)
// No synced timing in this test (beforeEach's default) - falls back to the first non-empty
// plain line, but it's already visible without any interaction.
expect(screen.getByRole('button', { name: 'Lyrics: Line one' })).toBeInTheDocument()
expect(screen.queryByRole('region', { name: 'Lyrics' })).not.toBeInTheDocument()
})
it('prefers the live synced line over the plain-text fallback once synced timing loads', async () => {
vi.spyOn(streamApi, 'fetchStreamUrl').mockResolvedValue('blob:fake-url')
vi.spyOn(libraryApi, 'getLyrics').mockResolvedValue({
status: 'success',
lyrics: 'First\nSecond',
synced_lyrics: [
[0, 'First'],
[10, 'Second'],
],
})
renderPlayer()
await userEvent.click(screen.getByText('Start Playback'))
await openFullPlayer()
// Playback position starts at 0, and the first synced line's own timestamp is 0 too, so
// it's already the active line - the inline preview shows it directly, not "First" read as
// a plain-text guess but as the genuinely active synced line.
expect(await screen.findByRole('button', { name: 'Lyrics: First' })).toBeInTheDocument()
})
it('opens the full lyrics screen from the live line, as a real deeper screen rather than an in-place crossfade', async () => {
vi.spyOn(streamApi, 'fetchStreamUrl').mockResolvedValue('blob:fake-url')
renderPlayer()
await userEvent.click(screen.getByText('Start Playback'))
await openFullPlayer()
await userEvent.click(lyricsLineButton())
const lyricsRegion = await screen.findByRole('region', { name: 'Lyrics' })
expect(lyricsRegion).toHaveTextContent('Line one')
expect(lyricsRegion).toHaveTextContent('Line two')
// No navigation happened - transport controls are still right there, and there's no
// separate "back" control for lyrics (only Queue has one).
expect(dialog().getByRole('button', { name: 'Pause' })).toBeInTheDocument()
expect(screen.queryByRole('button', { name: 'Back to now playing' })).not.toBeInTheDocument()
// Unlike the old in-place crossfade, this is a real screen with its own back control.
expect(screen.getByRole('button', { name: 'Back to now playing' })).toBeInTheDocument()
await userEvent.click(screen.getByRole('button', { name: 'Back to now playing' }))
await waitFor(() => expect(screen.queryByRole('region', { name: 'Lyrics' })).not.toBeInTheDocument())
// Back on the main screen, with focus returned to the line that opened it.
expect(lyricsLineButton()).toHaveFocus()
})
it('opens the lyrics screen on swipe-up over the cover, and closes it on swipe-down', async () => {
vi.spyOn(streamApi, 'fetchStreamUrl').mockResolvedValue('blob:fake-url')
renderPlayer()
await userEvent.click(screen.getByText('Start Playback'))
await openFullPlayer()
// Same button, toggled the other way.
expect(toggleButton).toHaveAttribute('aria-label', 'Show cover art')
await userEvent.click(toggleButton)
expect(toggleButton).toHaveAttribute('aria-label', 'Show lyrics')
// Test song has no coverart, so this renders the placeholder tile - the swipeable wrapper
// around it (not the tile itself) is what carries the pointer handlers, identified by its
// distinctive layout classes since it has no role/label of its own.
const cover = document.querySelector('.flex-1.items-center.justify-center') as HTMLElement
verticalSwipe(cover, 400, 300)
const lyricsRegion = await screen.findByRole('region', { name: 'Lyrics' })
verticalSwipe(lyricsRegion.parentElement as HTMLElement, 300, 400)
await waitFor(() => expect(screen.queryByRole('region', { name: 'Lyrics' })).not.toBeInTheDocument())
})
it('shows a real-time synced lyrics view when the song has line timing', async () => {
......@@ -126,7 +188,7 @@ describe('FullPlayer', () => {
await userEvent.click(screen.getByText('Start Playback'))
await openFullPlayer()
await userEvent.click(screen.getByRole('button', { name: 'Show lyrics' }))
await userEvent.click(lyricsLineButton())
const lyricsRegion = await screen.findByRole('region', { name: 'Lyrics' })
expect(within(lyricsRegion).getByText('First')).toBeInTheDocument()
......@@ -147,7 +209,7 @@ describe('FullPlayer', () => {
await userEvent.click(screen.getByText('Start Playback'))
await openFullPlayer()
await userEvent.click(screen.getByRole('button', { name: 'Show lyrics' }))
await userEvent.click(lyricsLineButton())
const lyricsRegion = await screen.findByRole('region', { name: 'Lyrics' })
await userEvent.click(within(lyricsRegion).getByText('Second'))
......@@ -165,21 +227,21 @@ describe('FullPlayer', () => {
await userEvent.click(screen.getByText('Start Playback'))
await openFullPlayer()
await userEvent.click(screen.getByRole('button', { name: 'Show lyrics' }))
await userEvent.click(lyricsLineButton())
const lyricsRegion = await screen.findByRole('region', { name: 'Lyrics' })
expect(lyricsRegion).toHaveTextContent('Line one')
expect(lyricsRegion).toHaveTextContent('Line two')
})
it('falls back to an empty state if the current song changes to one with no lyrics while lyrics are showing', async () => {
it('falls back to an empty state if the current song changes to one with no lyrics while the lyrics screen is open', async () => {
vi.spyOn(streamApi, 'fetchStreamUrl').mockResolvedValue('blob:fake-url')
renderPlayer()
await userEvent.click(screen.getByText('Start Playback'))
await openFullPlayer()
await userEvent.click(screen.getByRole('button', { name: 'Show lyrics' }))
await userEvent.click(lyricsLineButton())
expect(await screen.findByRole('region', { name: 'Lyrics' })).toHaveTextContent('Line one')
await userEvent.click(screen.getByText('Switch To No-Lyrics Song'))
......@@ -187,7 +249,7 @@ describe('FullPlayer', () => {
expect(await screen.findByText('No lyrics available for this track.')).toBeInTheDocument()
})
it('does not show a lyrics toggle bar at all for a track with no lyrics', async () => {
it('does not show a lyrics line at all for a track with no lyrics', async () => {
vi.spyOn(streamApi, 'fetchStreamUrl').mockResolvedValue('blob:fake-url')
function ProbeNoLyrics() {
......@@ -206,7 +268,7 @@ describe('FullPlayer', () => {
await userEvent.click(screen.getByText('Start Playback'))
await openFullPlayer()
expect(screen.queryByRole('button', { name: 'Show lyrics' })).not.toBeInTheDocument()
expect(screen.queryByRole('button', { name: /^Lyrics:/ })).not.toBeInTheDocument()
})
it('opens the Queue via its icon and can jump straight to a queued track', async () => {
......@@ -224,17 +286,17 @@ describe('FullPlayer', () => {
await screen.findByRole('dialog', { name: /Now playing: Instrumental by Test Artist/ })
})
it('closes on Escape (backing out of lyrics first, then the player) and returns focus to the control that opened it', async () => {
it('closes on Escape (backing out of the lyrics screen first, then the player) and returns focus to the control that opened it', async () => {
vi.spyOn(streamApi, 'fetchStreamUrl').mockResolvedValue('blob:fake-url')
renderPlayer()
await userEvent.click(screen.getByText('Start Playback'))
const openButton = await openFullPlayer()
await userEvent.click(screen.getByRole('button', { name: 'Show lyrics' }))
await userEvent.click(lyricsLineButton())
await screen.findByRole('region', { name: 'Lyrics' })
// First Escape only reverts the lyrics crossfade, not the whole player.
// First Escape only backs out of the lyrics screen, not the whole player.
await userEvent.keyboard('{Escape}')
await waitFor(() => expect(screen.queryByRole('region', { name: 'Lyrics' })).not.toBeInTheDocument())
expect(screen.getByRole('dialog')).toBeInTheDocument()
......
......@@ -3,8 +3,6 @@ import {
AudioLines,
ChevronDown,
ChevronLeft,
ChevronRight,
Disc3,
ListMusic,
Music2,
Pause,
......@@ -31,14 +29,16 @@ function formatTime(seconds: number): string {
return `${mins}:${secs.toString().padStart(2, '0')}`
}
/** Full-screen "Now Playing" view, opened from NowPlayingBar. Cover art is always the primary
* view; Lyrics is not a separate screen - tapping the lyrics bar crossfades the same central
* area between cover art and lyrics text in place (no navigation, no back button), which is
* what "fluid" means here. Queue is still a dedicated screen reached via its own icon, since
* jumping to an arbitrary track in a list is a genuinely different kind of action. Stays
* mounted for one extra animation frame after closing so the exit transition can play (see
* useMountTransition), and is otherwise absent from the DOM - no hidden-but-focusable controls
* left behind. */
/** Full-screen "Now Playing" view, opened from NowPlayingBar. Matches Spotify's actual current
* lyrics pattern (not the older "tap a bar to swap cover for lyrics" one): the live synced
* line plays right under the cover art on the main screen at all times, no tap needed, and the
* full scrollable lyrics view is a step deeper - reached by swiping up on the cover (or tapping
* the live line, kept as a focusable/keyboard-reachable fallback for the same gesture) - rather
* than living behind a persistent toggle control. Queue is a second, unrelated deeper screen
* reached via its own icon, since jumping to an arbitrary track in a list is a genuinely
* different action from either of those. Stays mounted for one extra animation frame after
* closing so the exit transition can play (see useMountTransition), and is otherwise absent
* from the DOM - no hidden-but-focusable controls left behind. */
export function FullPlayer() {
const {
currentSong,
......@@ -59,14 +59,19 @@ export function FullPlayer() {
toggleShuffle,
cycleRepeat,
} = usePlayer()
const [showLyrics, setShowLyrics] = useState(false)
const [lyricsOpen, setLyricsOpen] = useState(false)
const [queueOpen, setQueueOpen] = useState(false)
const [syncedLyrics, setSyncedLyrics] = useState<[number, string][] | null>(null)
const { mounted, visible } = useMountTransition(isExpanded && !!currentSong, ANIMATION_MS)
const collapseButtonRef = useRef<HTMLButtonElement>(null)
const queueBackButtonRef = useRef<HTMLButtonElement>(null)
const queueButtonRef = useRef<HTMLButtonElement>(null)
const lyricsBackButtonRef = useRef<HTMLButtonElement>(null)
const lyricsLineButtonRef = useRef<HTMLButtonElement>(null)
const activeLineRef = useRef<HTMLParagraphElement | null>(null)
// Shared by both swipe-up-to-open (on the cover) and swipe-down-to-close (on the lyrics
// screen) - only one of those two areas is ever interactive at a time, so one ref is enough.
const swipeStartYRef = useRef<number | null>(null)
// Real synced timing lives behind its own endpoint (see api/library.ts's getLyrics), not on
// the lightweight PlayableSong every page constructs - only fetched here, once, per song.
......@@ -94,7 +99,7 @@ export function FullPlayer() {
// surprise you by landing back on Lyrics or Queue from last time.
useEffect(() => {
if (!visible) {
setShowLyrics(false)
setLyricsOpen(false)
setQueueOpen(false)
}
}, [visible])
......@@ -103,23 +108,28 @@ export function FullPlayer() {
if (queueOpen) queueBackButtonRef.current?.focus()
}, [queueOpen])
useEffect(() => {
if (lyricsOpen) lyricsBackButtonRef.current?.focus()
}, [lyricsOpen])
useEffect(() => {
if (!visible) return
function onKeyDown(e: globalThis.KeyboardEvent) {
if (e.key !== 'Escape') return
// Escape backs out one level at a time: queue screen, then lyrics, then the player itself.
// Escape backs out one level at a time: whichever deeper screen (queue or lyrics) is
// open, then the player itself. Queue and lyrics are never both open at once.
if (queueOpen) {
setQueueOpen(false)
queueButtonRef.current?.focus()
} else if (showLyrics) {
setShowLyrics(false)
} else if (lyricsOpen) {
closeLyrics()
} else {
collapse()
}
}
document.addEventListener('keydown', onKeyDown)
return () => document.removeEventListener('keydown', onKeyDown)
}, [visible, queueOpen, showLyrics, collapse])
}, [visible, queueOpen, lyricsOpen, collapse])
useEffect(() => {
if (!visible) return
......@@ -139,15 +149,14 @@ export function FullPlayer() {
: -1
useEffect(() => {
if (showLyrics) activeLineRef.current?.scrollIntoView({ behavior: 'smooth', block: 'center' })
}, [activeLineIndex, showLyrics])
if (lyricsOpen) activeLineRef.current?.scrollIntoView({ behavior: 'smooth', block: 'center' })
}, [activeLineIndex, lyricsOpen])
// Two nested back-button levels, matching the two real navigation states here (the player
// itself, and the Queue screen pushed on top of it). Lyrics deliberately doesn't get one - as
// the comment on this component explains, it's an in-place crossfade, not a navigation, and
// Escape already backs out of it above.
// Three nested back-button levels: the player itself, plus its two deeper screens (Queue and
// Lyrics), each pushed on top of it the same way.
useBackButtonClose(visible, collapse)
useBackButtonClose(queueOpen, closeQueue)
useBackButtonClose(lyricsOpen, closeLyrics)
if (!mounted || !currentSong) return null
......@@ -165,10 +174,42 @@ export function FullPlayer() {
setQueueOpen(false)
collapseButtonRef.current?.focus()
}
function openLyrics() {
setLyricsOpen(true)
}
function closeLyrics() {
setLyricsOpen(false)
lyricsLineButtonRef.current?.focus()
}
// Swipe up on the cover opens the full lyrics screen; swipe down while it's open closes it -
// the same vertical gesture, read in each direction, on whichever of the two areas is
// currently on screen. 60px is a deliberate-drag threshold, not a hair-trigger on any touch.
function handleCoverPointerDown(e: React.PointerEvent) {
swipeStartYRef.current = e.clientY
}
function handleCoverPointerUp(e: React.PointerEvent) {
const startY = swipeStartYRef.current
swipeStartYRef.current = null
if (startY !== null && startY - e.clientY > 60) openLyrics()
}
function handleLyricsPointerDown(e: React.PointerEvent) {
swipeStartYRef.current = e.clientY
}
function handleLyricsPointerUp(e: React.PointerEvent) {
const startY = swipeStartYRef.current
swipeStartYRef.current = null
if (startY !== null && e.clientY - startY > 60) closeLyrics()
}
const pct = duration > 0 ? Math.min(100, (progress / duration) * 100) : 0
const RepeatIcon = repeatMode === 'one' ? Repeat1 : Repeat
// The live synced line (once one is active) is what makes this feel like Spotify's actual
// current pattern - a snippet that plays right under the cover with no tap needed. Before the
// first synced timestamp, or for a song with only plain (unsynced) lyrics, this falls back to
// the first non-empty plain line instead of showing nothing.
const liveLyricLine = syncedLyrics && activeLineIndex >= 0 ? syncedLyrics[activeLineIndex][1] : null
const lyricsPreview = currentSong.lyrics?.split('\n').find((line) => line.trim().length > 0)
const inlineLyricText = liveLyricLine ?? lyricsPreview ?? null
return (
<div
......@@ -194,18 +235,18 @@ export function FullPlayer() {
<div className="absolute inset-0 bg-background/75" />
</div>
{/* Main screen: cover/lyrics (crossfaded in place), transport, and a lyrics toggle bar.
Slides left and out of view when the Queue screen is open. will-change-transform
{/* Main screen: cover art with the live lyric line right underneath, then transport.
Slides left and out of view when the Queue or Lyrics screen is open. will-change-transform
promotes this to its own compositor layer proactively (rather than mid-transition) -
without it, Android's predictive-back gesture preview (which rasterizes the page for
its own animated preview) can catch this element mid-slide and leave the transition
visually stuck even though the underlying queueOpen state and classes are already
visually stuck even though the underlying open-state and classes are already
correct - a real device-only rendering issue, not a logic bug in this component. */}
<div
className={`absolute inset-0 flex flex-col will-change-transform transition-transform duration-300 ease-out motion-reduce:transition-none ${
queueOpen ? '-translate-x-1/4 opacity-0' : 'translate-x-0 opacity-100'
queueOpen || lyricsOpen ? '-translate-x-1/4 opacity-0' : 'translate-x-0 opacity-100'
}`}
aria-hidden={queueOpen}
aria-hidden={queueOpen || lyricsOpen}
>
<div
className="relative flex items-center justify-between px-4 pt-4 sm:px-6"
......@@ -214,7 +255,7 @@ export function FullPlayer() {
<button
ref={collapseButtonRef}
onClick={collapse}
tabIndex={queueOpen ? -1 : 0}
tabIndex={queueOpen || lyricsOpen ? -1 : 0}
aria-label="Minimize player"
className="flex h-10 w-10 items-center justify-center rounded-full text-on-surface-variant transition-colors hover:bg-surface-container-high hover:text-on-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"
>
......@@ -224,7 +265,7 @@ export function FullPlayer() {
<button
ref={queueButtonRef}
onClick={openQueue}
tabIndex={queueOpen ? -1 : 0}
tabIndex={queueOpen || lyricsOpen ? -1 : 0}
aria-label="Open queue"
className="flex h-10 w-10 items-center justify-center rounded-full text-on-surface-variant transition-colors hover:bg-surface-container-high hover:text-on-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"
>
......@@ -232,14 +273,14 @@ export function FullPlayer() {
</button>
</div>
{/* Cover and lyrics occupy the same space and crossfade between each other - this is
what makes lyrics feel like part of this screen rather than a screen of its own. */}
<div className="relative mx-auto w-full max-w-md flex-1 px-8 py-4">
<div className="relative mx-auto flex w-full max-w-md flex-1 flex-col px-8 py-4">
{/* Swipe up here to open the full lyrics screen (Spotify's actual gesture) - the
live line right below is the tap fallback, so the same action stays reachable
without a swipe for keyboard/screen-reader use. */}
<div
className={`absolute inset-8 flex items-center justify-center transition-opacity duration-300 ease-out motion-reduce:transition-none ${
showLyrics ? 'pointer-events-none opacity-0' : 'opacity-100'
}`}
aria-hidden={showLyrics}
onPointerDown={inlineLyricText ? handleCoverPointerDown : undefined}
onPointerUp={inlineLyricText ? handleCoverPointerUp : undefined}
className="flex flex-1 items-center justify-center"
>
{currentSong.coverart ? (
<img
......@@ -260,47 +301,22 @@ export function FullPlayer() {
)}
</div>
<div
role="region"
aria-label="Lyrics"
aria-hidden={!showLyrics}
className={`absolute inset-0 overflow-y-auto rounded-2xl bg-surface-container px-5 py-6 will-change-transform transition-opacity duration-300 ease-out motion-reduce:transition-none ${
showLyrics ? 'opacity-100' : 'pointer-events-none opacity-0'
}`}
style={{
maskImage: 'linear-gradient(to bottom, transparent, black 24px, black calc(100% - 24px), transparent)',
WebkitMaskImage:
'linear-gradient(to bottom, transparent, black 24px, black calc(100% - 24px), transparent)',
}}
>
{syncedLyrics ? (
// Real line-by-line sync: past/future lines dim, the currently-playing one is
// full-brightness and bold, auto-scrolled to center (Spotify's actual signature
// lyrics behavior, not an approximation of it).
<div className="space-y-4 py-[40%]">
{syncedLyrics.map(([time, text], i) => {
const active = i === activeLineIndex
return (
<p
key={time}
ref={active ? activeLineRef : undefined}
onClick={() => seek(time)}
aria-current={active ? 'true' : undefined}
className={`cursor-pointer text-[19px] leading-snug transition-all duration-200 ${
active ? 'font-bold text-on-surface' : 'text-on-surface-variant/50 hover:text-on-surface-variant'
}`}
>
{text}
</p>
)
})}
</div>
) : currentSong.lyrics ? (
<p className="whitespace-pre-wrap text-[17px] leading-loose text-on-surface">{currentSong.lyrics}</p>
) : (
<EmptyState icon={ScrollText} message="No lyrics available for this track." />
)}
</div>
{/* The live synced line, not a static "tap for lyrics" bar - this is what makes it
feel like part of the Now Playing screen rather than a separate lyrics feature.
Still a real button (not just a swipe target) so it's reachable without a
touchscreen. Only rendered once there's something to show, matching Spotify
(which hides this row entirely rather than linking to an empty screen). */}
{inlineLyricText && (
<button
ref={lyricsLineButtonRef}
onClick={openLyrics}
tabIndex={queueOpen || lyricsOpen ? -1 : 0}
aria-label={`Lyrics: ${inlineLyricText}`}
className="mt-4 truncate rounded-lg px-2 py-1 text-center text-sm text-on-surface-variant transition-colors hover:text-on-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"
>
{inlineLyricText}
</button>
)}
</div>
<div
......@@ -323,7 +339,7 @@ export function FullPlayer() {
step={0.1}
onChange={(e) => seek(Number(e.target.value))}
disabled={!duration}
tabIndex={queueOpen ? -1 : 0}
tabIndex={queueOpen || lyricsOpen ? -1 : 0}
aria-label="Seek"
aria-valuetext={`${formatTime(progress)} of ${formatTime(duration)}`}
className="seek-range w-full disabled:opacity-40"
......@@ -345,7 +361,7 @@ export function FullPlayer() {
<div className="mt-5 flex items-center justify-between">
<button
onClick={toggleShuffle}
tabIndex={queueOpen ? -1 : 0}
tabIndex={queueOpen || lyricsOpen ? -1 : 0}
aria-label="Shuffle"
aria-pressed={isShuffled}
className={`rounded-full p-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ${
......@@ -358,7 +374,7 @@ export function FullPlayer() {
<div className="flex items-center gap-8">
<button
onClick={previous}
tabIndex={queueOpen ? -1 : 0}
tabIndex={queueOpen || lyricsOpen ? -1 : 0}
aria-label="Previous"
className="rounded-full p-1 text-on-surface transition-colors hover:text-on-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"
>
......@@ -367,7 +383,7 @@ export function FullPlayer() {
<button
onClick={() => toggle(currentSong)}
disabled={isLoading}
tabIndex={queueOpen ? -1 : 0}
tabIndex={queueOpen || lyricsOpen ? -1 : 0}
aria-label={isPlaying ? 'Pause' : 'Play'}
className="flex h-16 w-16 items-center justify-center rounded-full bg-primary text-on-primary transition-transform duration-150 ease-out active:scale-90 disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background"
>
......@@ -382,7 +398,7 @@ export function FullPlayer() {
<button
onClick={next}
disabled={!hasNext}
tabIndex={queueOpen ? -1 : 0}
tabIndex={queueOpen || lyricsOpen ? -1 : 0}
aria-label="Next"
className="rounded-full p-1 text-on-surface transition-colors hover:text-on-surface disabled:opacity-30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"
>
......@@ -392,7 +408,7 @@ export function FullPlayer() {
<button
onClick={cycleRepeat}
tabIndex={queueOpen ? -1 : 0}
tabIndex={queueOpen || lyricsOpen ? -1 : 0}
aria-label={`Repeat: ${repeatMode}`}
aria-pressed={repeatMode !== 'off'}
className={`rounded-full p-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ${
......@@ -402,32 +418,73 @@ export function FullPlayer() {
<RepeatIcon size={18} strokeWidth={2} />
</button>
</div>
</div>
</div>
{/* Single toggle bar for the fluid cover/lyrics crossfade above - same control both
ways, so there's never a dead end. Only shown when the track actually has lyrics,
matching Spotify (which hides this row entirely rather than linking to an empty
screen). */}
{lyricsPreview && (
<button
onClick={() => setShowLyrics((v) => !v)}
tabIndex={queueOpen ? -1 : 0}
aria-label={showLyrics ? 'Show cover art' : 'Show lyrics'}
aria-pressed={showLyrics}
className="mt-5 flex w-full items-center gap-2 rounded-xl bg-surface-container px-4 py-3 text-left transition-colors hover:bg-surface-container-high focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"
>
{showLyrics ? (
<>
<Disc3 size={15} strokeWidth={2} className="shrink-0 text-on-surface-variant" />
<span className="min-w-0 flex-1 truncate text-sm text-on-surface">Cover art</span>
</>
) : (
<>
<ScrollText size={15} strokeWidth={2} className="shrink-0 text-on-surface-variant" />
<span className="min-w-0 flex-1 truncate text-sm text-on-surface">{lyricsPreview}</span>
</>
)}
<ChevronRight size={16} strokeWidth={2} className="shrink-0 text-outline" />
</button>
{/* Lyrics screen: slides up from the bottom, matching the swipe-up gesture that (along
with the tap fallback above) opens it - a deeper view for the full scrollable lyrics,
not the primary way lyrics are surfaced (that's the always-visible live line on the
main screen). Closed by swipe-down here, the back chevron, Escape, or system back. */}
<div
className={`absolute inset-0 flex flex-col will-change-transform transition-transform duration-300 ease-out motion-reduce:transition-none ${
lyricsOpen ? 'translate-y-0' : 'translate-y-full'
}`}
aria-hidden={!lyricsOpen}
onPointerDown={handleLyricsPointerDown}
onPointerUp={handleLyricsPointerUp}
>
<div
className="relative flex items-center gap-3 px-4 pt-4 sm:px-6"
style={{ paddingTop: 'calc(env(safe-area-inset-top) + 1rem)' }}
>
<button
ref={lyricsBackButtonRef}
onClick={closeLyrics}
tabIndex={lyricsOpen ? 0 : -1}
aria-label="Back to now playing"
className="flex h-10 w-10 items-center justify-center rounded-full text-on-surface-variant transition-colors hover:bg-surface-container-high hover:text-on-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"
>
<ChevronDown size={22} strokeWidth={2} />
</button>
<p className="text-sm font-semibold">Lyrics</p>
</div>
<div
role="region"
aria-label="Lyrics"
className="relative mx-auto w-full max-w-md flex-1 overflow-y-auto px-5 py-4"
style={{
maskImage: 'linear-gradient(to bottom, transparent, black 24px, black calc(100% - 24px), transparent)',
WebkitMaskImage:
'linear-gradient(to bottom, transparent, black 24px, black calc(100% - 24px), transparent)',
}}
>
{syncedLyrics ? (
// Real line-by-line sync: past/future lines dim, the currently-playing one is
// full-brightness and bold, auto-scrolled to center (Spotify's actual signature
// lyrics behavior, not an approximation of it).
<div className="space-y-4 py-[40%]">
{syncedLyrics.map(([time, text], i) => {
const active = i === activeLineIndex
return (
<p
key={time}
ref={active ? activeLineRef : undefined}
onClick={() => seek(time)}
aria-current={active ? 'true' : undefined}
className={`cursor-pointer text-[19px] leading-snug transition-all duration-200 ${
active ? 'font-bold text-on-surface' : 'text-on-surface-variant/50 hover:text-on-surface-variant'
}`}
>
{text}
</p>
)
})}
</div>
) : currentSong.lyrics ? (
<p className="whitespace-pre-wrap text-[17px] leading-loose text-on-surface">{currentSong.lyrics}</p>
) : (
<EmptyState icon={ScrollText} message="No lyrics available for this track." />
)}
</div>
</div>
......
......@@ -188,6 +188,7 @@ const FRONTEND_DONE: DoneGroup[] = [
items: [
'Library page with playback',
'Real-time synced lyrics in the full-screen player (2026-08-31): line-by-line highlight follows playback position (last line whose timestamp has passed), auto-scrolls the active line to center, tapping a line seeks there - Spotify\'s actual signature lyrics behavior, not an approximation. Falls back to the existing static full-text view when a song has plain lyrics but no synced timing, and to the empty state when it has neither. Fixed same day: the synced-lyrics lookup was only attempted when the identification candidate itself had no plain lyrics already - but Shazam and Gemini can both independently return a plain snippet, which was silently skipping the sync fetch (and any real timing that existed) whenever that happened. Now always attempted, with synced data winning over the candidate\'s own plain text when found; existing library songs were backfilled',
'Lyrics presentation rebuilt to match Spotify\'s actual current pattern, not the "tap a bar to swap cover for lyrics" one from 08-31 (2026-09-01, researched via web search rather than guessed at): the live synced line now plays right under the cover art on the main Now Playing screen at all times - no tap needed to see it, matching what Spotify itself shipped as its headline update here. The full scrollable lyrics view is a step deeper, reached by swiping up on the cover (Spotify\'s real gesture) or tapping the live line (kept as a focusable fallback for keyboard/screen-reader use, since Spotify itself keeps a tappable entry point alongside the swipe) - a real slide-up screen with its own back control, closed by swipe-down, the back button, Escape, or system back, not the previous in-place crossfade toggle.',
'Universal search box: separate Songs and Albums result sections while searching (an album expands to show/play its tracks) - replaces the plain list rather than filtering it in place',
'Spotify-style default (non-search) view (2026-09-01): an Albums grid of cover-art cards above an always-on All Songs list covering the full library. The (album, artist) grouping is derived client-side from the already-loaded song list (mirroring /library/search\'s own grouping) rather than adding a second backend endpoint that would return the same shape - deletions and new songs update both sections for free since All Songs and the album groups both derive from the same one songs array. Tapping a card expands its tracks below the grid, same interaction as search\'s album rows.',
'Playlists page: list, create, view tracks, playback',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment