Commit b3a07d39 authored by Aryan Noshirvnai's avatar Aryan Noshirvnai

Make lyrics fluid (no navigation) and rows tap-anywhere-to-play

Lyrics no longer push to a separate screen with its own back button -
tapping the lyrics bar crossfades the same central area between cover
art and lyrics text in place, with the header, title, seek bar, and
transport controls staying exactly where they are the whole time.
Queue stays a dedicated screen (jumping to an arbitrary track is a
genuinely different action), reached via its own icon.

Library rows and the Upload result card now play on tap anywhere in
the row/card, not just the small icon button - the icon is a status
indicator inside the same button now, not a separate control.

Verified end-to-end against the real running app with Playwright (not
just unit tests): tap-to-play on both Library and Upload, the fluid
lyrics crossfade, queue jump, shuffle/repeat, and re-uploading the
same file twice correctly staying at one library row instead of
creating a duplicate. Zero console errors across a full click-through
of every page at both mobile and desktop viewports.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
parent e292025b
Pipeline #1049 failed with stage
...@@ -81,41 +81,46 @@ describe('FullPlayer', () => { ...@@ -81,41 +81,46 @@ describe('FullPlayer', () => {
expect(dialog().getByRole('button', { name: 'Open queue' })).toBeInTheDocument() expect(dialog().getByRole('button', { name: 'Open queue' })).toBeInTheDocument()
}) })
it('opens Lyrics via the preview bar, and Back returns to the cover screen with focus restored', async () => { it('toggles lyrics in place (crossfade) rather than navigating to a separate screen', async () => {
vi.spyOn(streamApi, 'fetchStreamUrl').mockResolvedValue('blob:fake-url') vi.spyOn(streamApi, 'fetchStreamUrl').mockResolvedValue('blob:fake-url')
renderPlayer() renderPlayer()
await userEvent.click(screen.getByText('Start Playback')) await userEvent.click(screen.getByText('Start Playback'))
await openFullPlayer() await openFullPlayer()
const lyricsButton = screen.getByRole('button', { name: 'View lyrics' }) const toggleButton = screen.getByRole('button', { name: 'Show lyrics' })
await userEvent.click(lyricsButton) await userEvent.click(toggleButton)
const lyricsRegion = await screen.findByRole('region', { name: 'Lyrics' }) const lyricsRegion = await screen.findByRole('region', { name: 'Lyrics' })
expect(lyricsRegion).toHaveTextContent('Line one') expect(lyricsRegion).toHaveTextContent('Line one')
expect(lyricsRegion).toHaveTextContent('Line two') expect(lyricsRegion).toHaveTextContent('Line two')
await waitFor(() => expect(screen.getByRole('button', { name: 'Back to now playing' })).toHaveFocus()) // 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()
await userEvent.click(screen.getByRole('button', { name: 'Back to now playing' })) // Same button, toggled the other way.
await waitFor(() => expect(lyricsButton).toHaveFocus()) expect(toggleButton).toHaveAttribute('aria-label', 'Show cover art')
await userEvent.click(toggleButton)
expect(toggleButton).toHaveAttribute('aria-label', 'Show lyrics')
}) })
it('falls back to an empty state if the current song changes to one with no lyrics while the Lyrics screen is open', async () => { it('falls back to an empty state if the current song changes to one with no lyrics while lyrics are showing', async () => {
vi.spyOn(streamApi, 'fetchStreamUrl').mockResolvedValue('blob:fake-url') vi.spyOn(streamApi, 'fetchStreamUrl').mockResolvedValue('blob:fake-url')
renderPlayer() renderPlayer()
await userEvent.click(screen.getByText('Start Playback')) await userEvent.click(screen.getByText('Start Playback'))
await openFullPlayer() await openFullPlayer()
await userEvent.click(screen.getByRole('button', { name: 'View lyrics' })) await userEvent.click(screen.getByRole('button', { name: 'Show lyrics' }))
expect(await screen.findByText('Line one')).toBeInTheDocument() expect(await screen.findByRole('region', { name: 'Lyrics' })).toHaveTextContent('Line one')
await userEvent.click(screen.getByText('Switch To No-Lyrics Song')) await userEvent.click(screen.getByText('Switch To No-Lyrics Song'))
expect(await screen.findByText('No lyrics available for this track.')).toBeInTheDocument() expect(await screen.findByText('No lyrics available for this track.')).toBeInTheDocument()
}) })
it('does not show a lyrics preview bar at all for a track with no lyrics', async () => { it('does not show a lyrics toggle bar at all for a track with no lyrics', async () => {
vi.spyOn(streamApi, 'fetchStreamUrl').mockResolvedValue('blob:fake-url') vi.spyOn(streamApi, 'fetchStreamUrl').mockResolvedValue('blob:fake-url')
function ProbeNoLyrics() { function ProbeNoLyrics() {
...@@ -134,7 +139,7 @@ describe('FullPlayer', () => { ...@@ -134,7 +139,7 @@ describe('FullPlayer', () => {
await userEvent.click(screen.getByText('Start Playback')) await userEvent.click(screen.getByText('Start Playback'))
await openFullPlayer() await openFullPlayer()
expect(screen.queryByRole('button', { name: 'View lyrics' })).not.toBeInTheDocument() expect(screen.queryByRole('button', { name: 'Show lyrics' })).not.toBeInTheDocument()
}) })
it('opens the Queue via its icon and can jump straight to a queued track', async () => { it('opens the Queue via its icon and can jump straight to a queued track', async () => {
...@@ -152,19 +157,19 @@ describe('FullPlayer', () => { ...@@ -152,19 +157,19 @@ describe('FullPlayer', () => {
await screen.findByRole('dialog', { name: /Now playing: Instrumental by Test Artist/ }) await screen.findByRole('dialog', { name: /Now playing: Instrumental by Test Artist/ })
}) })
it('closes on Escape (one level at a time) and returns focus to the control that opened it', async () => { it('closes on Escape (backing out of lyrics first, then the player) and returns focus to the control that opened it', async () => {
vi.spyOn(streamApi, 'fetchStreamUrl').mockResolvedValue('blob:fake-url') vi.spyOn(streamApi, 'fetchStreamUrl').mockResolvedValue('blob:fake-url')
renderPlayer() renderPlayer()
await userEvent.click(screen.getByText('Start Playback')) await userEvent.click(screen.getByText('Start Playback'))
const openButton = await openFullPlayer() const openButton = await openFullPlayer()
await userEvent.click(screen.getByRole('button', { name: 'View lyrics' })) await userEvent.click(screen.getByRole('button', { name: 'Show lyrics' }))
await screen.findByText('Line one') await screen.findByRole('region', { name: 'Lyrics' })
// First Escape only backs out of the Lyrics screen, not the whole player. // First Escape only reverts the lyrics crossfade, not the whole player.
await userEvent.keyboard('{Escape}') await userEvent.keyboard('{Escape}')
await waitFor(() => expect(dialog().getByRole('button', { name: 'Pause' })).toBeInTheDocument()) await waitFor(() => expect(screen.queryByRole('region', { name: 'Lyrics' })).not.toBeInTheDocument())
expect(screen.getByRole('dialog')).toBeInTheDocument() expect(screen.getByRole('dialog')).toBeInTheDocument()
await userEvent.keyboard('{Escape}') await userEvent.keyboard('{Escape}')
......
...@@ -4,6 +4,7 @@ import { ...@@ -4,6 +4,7 @@ import {
ChevronDown, ChevronDown,
ChevronLeft, ChevronLeft,
ChevronRight, ChevronRight,
Disc3,
ListMusic, ListMusic,
Music2, Music2,
Pause, Pause,
...@@ -28,14 +29,14 @@ function formatTime(seconds: number): string { ...@@ -28,14 +29,14 @@ function formatTime(seconds: number): string {
return `${mins}:${secs.toString().padStart(2, '0')}` return `${mins}:${secs.toString().padStart(2, '0')}`
} }
type SecondaryView = 'lyrics' | 'queue' | null /** 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
/** Full-screen "Now Playing" view, opened from NowPlayingBar - mirrors Spotify's now-playing * area between cover art and lyrics text in place (no navigation, no back button), which is
* screen: cover art is always the primary view, with Lyrics and Queue reached as separate * what "fluid" means here. Queue is still a dedicated screen reached via its own icon, since
* screens that slide in from the right (a push-navigation feel, not a tab switcher) and slide * jumping to an arbitrary track in a list is a genuinely different kind of action. Stays
* back out on their own back button. Stays mounted for one extra animation frame after closing * mounted for one extra animation frame after closing so the exit transition can play (see
* so the exit transition can play (see useMountTransition), and is otherwise absent from the * useMountTransition), and is otherwise absent from the DOM - no hidden-but-focusable controls
* DOM - no hidden-but-focusable controls left behind. */ * left behind. */
export function FullPlayer() { export function FullPlayer() {
const { const {
currentSong, currentSong,
...@@ -56,11 +57,11 @@ export function FullPlayer() { ...@@ -56,11 +57,11 @@ export function FullPlayer() {
toggleShuffle, toggleShuffle,
cycleRepeat, cycleRepeat,
} = usePlayer() } = usePlayer()
const [secondaryView, setSecondaryView] = useState<SecondaryView>(null) const [showLyrics, setShowLyrics] = useState(false)
const [queueOpen, setQueueOpen] = useState(false)
const { mounted, visible } = useMountTransition(isExpanded && !!currentSong, ANIMATION_MS) const { mounted, visible } = useMountTransition(isExpanded && !!currentSong, ANIMATION_MS)
const collapseButtonRef = useRef<HTMLButtonElement>(null) const collapseButtonRef = useRef<HTMLButtonElement>(null)
const secondaryBackButtonRef = useRef<HTMLButtonElement>(null) const queueBackButtonRef = useRef<HTMLButtonElement>(null)
const lyricsButtonRef = useRef<HTMLButtonElement>(null)
const queueButtonRef = useRef<HTMLButtonElement>(null) const queueButtonRef = useRef<HTMLButtonElement>(null)
useEffect(() => { useEffect(() => {
...@@ -70,27 +71,33 @@ export function FullPlayer() { ...@@ -70,27 +71,33 @@ export function FullPlayer() {
// Reset to the cover view every time the player is closed, so reopening it doesn't // Reset to the cover view every time the player is closed, so reopening it doesn't
// surprise you by landing back on Lyrics or Queue from last time. // surprise you by landing back on Lyrics or Queue from last time.
useEffect(() => { useEffect(() => {
if (!visible) setSecondaryView(null) if (!visible) {
setShowLyrics(false)
setQueueOpen(false)
}
}, [visible]) }, [visible])
useEffect(() => { useEffect(() => {
if (secondaryView) secondaryBackButtonRef.current?.focus() if (queueOpen) queueBackButtonRef.current?.focus()
}, [secondaryView]) }, [queueOpen])
useEffect(() => { useEffect(() => {
if (!visible) return if (!visible) return
function onKeyDown(e: globalThis.KeyboardEvent) { function onKeyDown(e: globalThis.KeyboardEvent) {
if (e.key !== 'Escape') return if (e.key !== 'Escape') return
// Escape backs out one level at a time, same as the physical back button would. // Escape backs out one level at a time: queue screen, then lyrics, then the player itself.
setSecondaryView((current) => { if (queueOpen) {
if (current) return null setQueueOpen(false)
queueButtonRef.current?.focus()
} else if (showLyrics) {
setShowLyrics(false)
} else {
collapse() collapse()
return current }
})
} }
document.addEventListener('keydown', onKeyDown) document.addEventListener('keydown', onKeyDown)
return () => document.removeEventListener('keydown', onKeyDown) return () => document.removeEventListener('keydown', onKeyDown)
}, [visible, collapse]) }, [visible, queueOpen, showLyrics, collapse])
useEffect(() => { useEffect(() => {
if (!visible) return if (!visible) return
...@@ -103,21 +110,18 @@ export function FullPlayer() { ...@@ -103,21 +110,18 @@ export function FullPlayer() {
if (!mounted || !currentSong) return null if (!mounted || !currentSong) return null
function openLyrics() {
setSecondaryView('lyrics')
}
function openQueue() { function openQueue() {
setSecondaryView('queue') setQueueOpen(true)
} }
function closeSecondary() { function closeQueue() {
setSecondaryView(null) setQueueOpen(false)
;(secondaryView === 'lyrics' ? lyricsButtonRef : queueButtonRef).current?.focus() queueButtonRef.current?.focus()
} }
function jumpTo(song: PlayableSong) { function jumpTo(song: PlayableSong) {
toggle(song, queue) toggle(song, queue)
// Selecting a track from the queue returns to the main now-playing screen (matching // Selecting a track from the queue returns to the main now-playing screen (matching
// Spotify), rather than leaving you stranded on the queue list you just picked from. // Spotify), rather than leaving you stranded on the queue list you just picked from.
setSecondaryView(null) setQueueOpen(false)
collapseButtonRef.current?.focus() collapseButtonRef.current?.focus()
} }
...@@ -137,7 +141,7 @@ export function FullPlayer() { ...@@ -137,7 +141,7 @@ export function FullPlayer() {
{/* Large, blurred backdrop of the current cover art - fills the otherwise-empty space {/* Large, blurred backdrop of the current cover art - fills the otherwise-empty space
around a centered album cover with something alive, rather than flat black (the around a centered album cover with something alive, rather than flat black (the
Spotify/Apple Music "now playing" convention). Purely decorative, shared by both the Spotify/Apple Music "now playing" convention). Purely decorative, shared by both the
primary and secondary screens beneath them. */} main and queue screens beneath them. */}
<div className="pointer-events-none absolute inset-0" aria-hidden="true"> <div className="pointer-events-none absolute inset-0" aria-hidden="true">
{currentSong.coverart && ( {currentSong.coverart && (
<img <img
...@@ -149,13 +153,13 @@ export function FullPlayer() { ...@@ -149,13 +153,13 @@ export function FullPlayer() {
<div className="absolute inset-0 bg-neutral-950/75" /> <div className="absolute inset-0 bg-neutral-950/75" />
</div> </div>
{/* Primary screen: cover art, transport, and (if available) a lyrics preview bar. Slides {/* Main screen: cover/lyrics (crossfaded in place), transport, and a lyrics toggle bar.
left and out of view when a secondary screen is open. */} Slides left and out of view when the Queue screen is open. */}
<div <div
className={`absolute inset-0 flex flex-col transition-transform duration-300 ease-out motion-reduce:transition-none ${ className={`absolute inset-0 flex flex-col transition-transform duration-300 ease-out motion-reduce:transition-none ${
secondaryView ? '-translate-x-1/4 opacity-0' : 'translate-x-0 opacity-100' queueOpen ? '-translate-x-1/4 opacity-0' : 'translate-x-0 opacity-100'
}`} }`}
aria-hidden={!!secondaryView} aria-hidden={queueOpen}
> >
<div <div
className="relative flex items-center justify-between px-4 pt-4 sm:px-6" className="relative flex items-center justify-between px-4 pt-4 sm:px-6"
...@@ -164,7 +168,7 @@ export function FullPlayer() { ...@@ -164,7 +168,7 @@ export function FullPlayer() {
<button <button
ref={collapseButtonRef} ref={collapseButtonRef}
onClick={collapse} onClick={collapse}
tabIndex={secondaryView ? -1 : 0} tabIndex={queueOpen ? -1 : 0}
aria-label="Minimize player" aria-label="Minimize player"
className="flex h-10 w-10 items-center justify-center rounded-full text-neutral-400 transition-colors hover:bg-white/10 hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400" className="flex h-10 w-10 items-center justify-center rounded-full text-neutral-400 transition-colors hover:bg-white/10 hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400"
> >
...@@ -174,7 +178,7 @@ export function FullPlayer() { ...@@ -174,7 +178,7 @@ export function FullPlayer() {
<button <button
ref={queueButtonRef} ref={queueButtonRef}
onClick={openQueue} onClick={openQueue}
tabIndex={secondaryView ? -1 : 0} tabIndex={queueOpen ? -1 : 0}
aria-label="Open queue" aria-label="Open queue"
className="flex h-10 w-10 items-center justify-center rounded-full text-neutral-400 transition-colors hover:bg-white/10 hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400" className="flex h-10 w-10 items-center justify-center rounded-full text-neutral-400 transition-colors hover:bg-white/10 hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400"
> >
...@@ -182,7 +186,15 @@ export function FullPlayer() { ...@@ -182,7 +186,15 @@ export function FullPlayer() {
</button> </button>
</div> </div>
<div className="relative mx-auto flex w-full max-w-md flex-1 items-center justify-center px-8 py-4"> {/* 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={`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}
>
{currentSong.coverart ? ( {currentSong.coverart ? (
<img <img
src={currentSong.coverart} src={currentSong.coverart}
...@@ -202,6 +214,27 @@ export function FullPlayer() { ...@@ -202,6 +214,27 @@ export function FullPlayer() {
)} )}
</div> </div>
<div
role="region"
aria-label="Lyrics"
aria-hidden={!showLyrics}
className={`absolute inset-0 overflow-y-auto rounded-2xl bg-white/5 px-5 py-6 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)',
}}
>
{currentSong.lyrics ? (
<p className="whitespace-pre-wrap text-[17px] leading-loose text-neutral-200">{currentSong.lyrics}</p>
) : (
<EmptyState icon={ScrollText} message="No lyrics available for this track." />
)}
</div>
</div>
<div <div
className="relative mx-auto w-full max-w-md px-6 pb-6 sm:pb-8" className="relative mx-auto w-full max-w-md px-6 pb-6 sm:pb-8"
style={{ paddingBottom: 'calc(env(safe-area-inset-bottom) + 1.5rem)' }} style={{ paddingBottom: 'calc(env(safe-area-inset-bottom) + 1.5rem)' }}
...@@ -222,7 +255,7 @@ export function FullPlayer() { ...@@ -222,7 +255,7 @@ export function FullPlayer() {
step={0.1} step={0.1}
onChange={(e) => seek(Number(e.target.value))} onChange={(e) => seek(Number(e.target.value))}
disabled={!duration} disabled={!duration}
tabIndex={secondaryView ? -1 : 0} tabIndex={queueOpen ? -1 : 0}
aria-label="Seek" aria-label="Seek"
aria-valuetext={`${formatTime(progress)} of ${formatTime(duration)}`} aria-valuetext={`${formatTime(progress)} of ${formatTime(duration)}`}
className="seek-range w-full disabled:opacity-40" className="seek-range w-full disabled:opacity-40"
...@@ -242,7 +275,7 @@ export function FullPlayer() { ...@@ -242,7 +275,7 @@ export function FullPlayer() {
<div className="mt-5 flex items-center justify-between"> <div className="mt-5 flex items-center justify-between">
<button <button
onClick={toggleShuffle} onClick={toggleShuffle}
tabIndex={secondaryView ? -1 : 0} tabIndex={queueOpen ? -1 : 0}
aria-label="Shuffle" aria-label="Shuffle"
aria-pressed={isShuffled} aria-pressed={isShuffled}
className={`rounded-full p-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400 ${ className={`rounded-full p-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400 ${
...@@ -255,7 +288,7 @@ export function FullPlayer() { ...@@ -255,7 +288,7 @@ export function FullPlayer() {
<div className="flex items-center gap-8"> <div className="flex items-center gap-8">
<button <button
onClick={previous} onClick={previous}
tabIndex={secondaryView ? -1 : 0} tabIndex={queueOpen ? -1 : 0}
aria-label="Previous" aria-label="Previous"
className="rounded-full p-1 text-neutral-300 transition-colors hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400" className="rounded-full p-1 text-neutral-300 transition-colors hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400"
> >
...@@ -264,7 +297,7 @@ export function FullPlayer() { ...@@ -264,7 +297,7 @@ export function FullPlayer() {
<button <button
onClick={() => toggle(currentSong)} onClick={() => toggle(currentSong)}
disabled={isLoading} disabled={isLoading}
tabIndex={secondaryView ? -1 : 0} tabIndex={queueOpen ? -1 : 0}
aria-label={isPlaying ? 'Pause' : 'Play'} aria-label={isPlaying ? 'Pause' : 'Play'}
className="flex h-16 w-16 items-center justify-center rounded-full bg-white text-neutral-950 transition-transform duration-150 ease-out active:scale-90 disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400 focus-visible:ring-offset-2 focus-visible:ring-offset-neutral-950" className="flex h-16 w-16 items-center justify-center rounded-full bg-white text-neutral-950 transition-transform duration-150 ease-out active:scale-90 disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400 focus-visible:ring-offset-2 focus-visible:ring-offset-neutral-950"
> >
...@@ -279,7 +312,7 @@ export function FullPlayer() { ...@@ -279,7 +312,7 @@ export function FullPlayer() {
<button <button
onClick={next} onClick={next}
disabled={!hasNext} disabled={!hasNext}
tabIndex={secondaryView ? -1 : 0} tabIndex={queueOpen ? -1 : 0}
aria-label="Next" aria-label="Next"
className="rounded-full p-1 text-neutral-300 transition-colors hover:text-white disabled:opacity-30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400" className="rounded-full p-1 text-neutral-300 transition-colors hover:text-white disabled:opacity-30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400"
> >
...@@ -289,7 +322,7 @@ export function FullPlayer() { ...@@ -289,7 +322,7 @@ export function FullPlayer() {
<button <button
onClick={cycleRepeat} onClick={cycleRepeat}
tabIndex={secondaryView ? -1 : 0} tabIndex={queueOpen ? -1 : 0}
aria-label={`Repeat: ${repeatMode}`} aria-label={`Repeat: ${repeatMode}`}
aria-pressed={repeatMode !== 'off'} aria-pressed={repeatMode !== 'off'}
className={`rounded-full p-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400 ${ className={`rounded-full p-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400 ${
...@@ -300,68 +333,60 @@ export function FullPlayer() { ...@@ -300,68 +333,60 @@ export function FullPlayer() {
</button> </button>
</div> </div>
{/* Lyrics preview bar - a single representative line, tappable to open the full {/* Single toggle bar for the fluid cover/lyrics crossfade above - same control both
Lyrics screen. Only shown when the track actually has lyrics, matching Spotify ways, so there's never a dead end. Only shown when the track actually has lyrics,
(which hides this row entirely rather than linking to an empty screen). */} matching Spotify (which hides this row entirely rather than linking to an empty
screen). */}
{lyricsPreview && ( {lyricsPreview && (
<button <button
ref={lyricsButtonRef} onClick={() => setShowLyrics((v) => !v)}
onClick={openLyrics} tabIndex={queueOpen ? -1 : 0}
tabIndex={secondaryView ? -1 : 0} aria-label={showLyrics ? 'Show cover art' : 'Show lyrics'}
aria-label="View lyrics" aria-pressed={showLyrics}
className="mt-5 flex w-full items-center gap-2 rounded-xl bg-white/5 px-4 py-3 text-left transition-colors hover:bg-white/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400" className="mt-5 flex w-full items-center gap-2 rounded-xl bg-white/5 px-4 py-3 text-left transition-colors hover:bg-white/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400"
> >
{showLyrics ? (
<>
<Disc3 size={15} strokeWidth={2} className="shrink-0 text-neutral-400" />
<span className="min-w-0 flex-1 truncate text-sm text-neutral-300">Cover art</span>
</>
) : (
<>
<ScrollText size={15} strokeWidth={2} className="shrink-0 text-neutral-400" /> <ScrollText size={15} strokeWidth={2} className="shrink-0 text-neutral-400" />
<span className="min-w-0 flex-1 truncate text-sm text-neutral-300">{lyricsPreview}</span> <span className="min-w-0 flex-1 truncate text-sm text-neutral-300">{lyricsPreview}</span>
</>
)}
<ChevronRight size={16} strokeWidth={2} className="shrink-0 text-neutral-500" /> <ChevronRight size={16} strokeWidth={2} className="shrink-0 text-neutral-500" />
</button> </button>
)} )}
</div> </div>
</div> </div>
{/* Secondary screen: Lyrics or Queue, pushed in from the right with its own header. */} {/* Queue screen: still a dedicated push-navigation screen with its own header, since
jumping to an arbitrary track in a list is a genuinely different action from viewing
lyrics for the track that's already playing. */}
<div <div
className={`absolute inset-0 flex flex-col transition-transform duration-300 ease-out motion-reduce:transition-none ${ className={`absolute inset-0 flex flex-col transition-transform duration-300 ease-out motion-reduce:transition-none ${
secondaryView ? 'translate-x-0' : 'translate-x-full' queueOpen ? 'translate-x-0' : 'translate-x-full'
}`} }`}
aria-hidden={!secondaryView} aria-hidden={!queueOpen}
> >
<div <div
className="relative flex items-center gap-3 px-4 pt-4 sm:px-6" className="relative flex items-center gap-3 px-4 pt-4 sm:px-6"
style={{ paddingTop: 'calc(env(safe-area-inset-top) + 1rem)' }} style={{ paddingTop: 'calc(env(safe-area-inset-top) + 1rem)' }}
> >
<button <button
ref={secondaryBackButtonRef} ref={queueBackButtonRef}
onClick={closeSecondary} onClick={closeQueue}
tabIndex={secondaryView ? 0 : -1} tabIndex={queueOpen ? 0 : -1}
aria-label="Back to now playing" aria-label="Back to now playing"
className="flex h-10 w-10 items-center justify-center rounded-full text-neutral-400 transition-colors hover:bg-white/10 hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400" className="flex h-10 w-10 items-center justify-center rounded-full text-neutral-400 transition-colors hover:bg-white/10 hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400"
> >
<ChevronLeft size={22} strokeWidth={2} /> <ChevronLeft size={22} strokeWidth={2} />
</button> </button>
<p className="text-sm font-semibold">{secondaryView === 'lyrics' ? 'Lyrics' : 'Queue'}</p> <p className="text-sm font-semibold">Queue</p>
</div>
{secondaryView === 'lyrics' && (
<div
role="region"
aria-label="Lyrics"
className="relative mx-auto w-full max-w-md flex-1 overflow-y-auto px-6 py-6"
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)',
}}
>
{currentSong.lyrics ? (
<p className="whitespace-pre-wrap text-[17px] leading-loose text-neutral-200">{currentSong.lyrics}</p>
) : (
<EmptyState icon={ScrollText} message="No lyrics available for this track." />
)}
</div> </div>
)}
{secondaryView === 'queue' && (
<div className="relative mx-auto w-full max-w-md flex-1 overflow-y-auto px-4 py-4"> <div className="relative mx-auto w-full max-w-md flex-1 overflow-y-auto px-4 py-4">
{queue.length === 0 ? ( {queue.length === 0 ? (
<EmptyState icon={ListMusic} message="Nothing queued." /> <EmptyState icon={ListMusic} message="Nothing queued." />
...@@ -373,7 +398,7 @@ export function FullPlayer() { ...@@ -373,7 +398,7 @@ export function FullPlayer() {
<li key={song.id}> <li key={song.id}>
<button <button
onClick={() => jumpTo(song)} onClick={() => jumpTo(song)}
tabIndex={secondaryView === 'queue' ? 0 : -1} tabIndex={queueOpen ? 0 : -1}
aria-current={isCurrent ? 'true' : undefined} aria-current={isCurrent ? 'true' : undefined}
className={`flex w-full items-center gap-3 rounded-lg px-2 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400 ${ className={`flex w-full items-center gap-3 rounded-lg px-2 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400 ${
isCurrent ? 'text-emerald-400' : 'text-neutral-300 hover:bg-white/5 hover:text-white' isCurrent ? 'text-emerald-400' : 'text-neutral-300 hover:bg-white/5 hover:text-white'
...@@ -400,7 +425,6 @@ export function FullPlayer() { ...@@ -400,7 +425,6 @@ export function FullPlayer() {
</ul> </ul>
)} )}
</div> </div>
)}
</div> </div>
</div> </div>
) )
......
...@@ -3,7 +3,6 @@ import { Music2, Pause, Play } from 'lucide-react' ...@@ -3,7 +3,6 @@ import { Music2, Pause, Play } from 'lucide-react'
import { getLibrary, type LibrarySong } from '../api/library' import { getLibrary, type LibrarySong } from '../api/library'
import { ApiError } from '../api/client' import { ApiError } from '../api/client'
import { Layout } from '../components/Layout' import { Layout } from '../components/Layout'
import { Button } from '../components/ui/Button'
import { SkeletonRow } from '../components/ui/Skeleton' import { SkeletonRow } from '../components/ui/Skeleton'
import { EmptyState } from '../components/ui/EmptyState' import { EmptyState } from '../components/ui/EmptyState'
import { usePlayer, type PlayableSong } from '../context/PlayerContext' import { usePlayer, type PlayableSong } from '../context/PlayerContext'
...@@ -50,7 +49,16 @@ export function Library() { ...@@ -50,7 +49,16 @@ export function Library() {
{songs.map((song) => { {songs.map((song) => {
const isCurrent = currentSong?.id === song.id const isCurrent = currentSong?.id === song.id
return ( return (
<li key={song.id} className="flex items-center gap-4 py-3"> <li key={song.id}>
{/* The whole row plays the song, not just the little icon on the right - the
icon is now a status indicator rendered inside this same button, not a
separate control. */}
<button
onClick={() => toggle(toPlayable(song), songs.map(toPlayable))}
disabled={isCurrent && streamLoading}
aria-label={isCurrent && isPlaying ? 'Pause' : 'Play'}
className="-mx-2 flex w-full items-center gap-4 rounded-lg px-2 py-3 text-left transition-colors hover:bg-white/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400 disabled:cursor-not-allowed"
>
{song.coverart ? ( {song.coverart ? (
<img src={song.coverart} alt="" className="h-12 w-12 shrink-0 rounded-md object-cover" /> <img src={song.coverart} alt="" className="h-12 w-12 shrink-0 rounded-md object-cover" />
) : ( ) : (
...@@ -65,13 +73,7 @@ export function Library() { ...@@ -65,13 +73,7 @@ export function Library() {
{song.album ? ` · ${song.album}` : ''} {song.album ? ` · ${song.album}` : ''}
</p> </p>
</div> </div>
<Button <span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-neutral-800 text-white">
variant="secondary"
size="icon"
onClick={() => toggle(toPlayable(song), songs.map(toPlayable))}
disabled={isCurrent && streamLoading}
aria-label={isCurrent && isPlaying ? 'Pause' : 'Play'}
>
{isCurrent && streamLoading ? ( {isCurrent && streamLoading ? (
<span className="h-3.5 w-3.5 animate-spin rounded-full border-2 border-neutral-600 border-t-white" /> <span className="h-3.5 w-3.5 animate-spin rounded-full border-2 border-neutral-600 border-t-white" />
) : isCurrent && isPlaying ? ( ) : isCurrent && isPlaying ? (
...@@ -79,7 +81,8 @@ export function Library() { ...@@ -79,7 +81,8 @@ export function Library() {
) : ( ) : (
<Play size={16} strokeWidth={2} fill="currentColor" className="ml-0.5" /> <Play size={16} strokeWidth={2} fill="currentColor" className="ml-0.5" />
)} )}
</Button> </span>
</button>
</li> </li>
) )
})} })}
......
...@@ -78,18 +78,11 @@ export function Upload() { ...@@ -78,18 +78,11 @@ export function Upload() {
{error && <p className="mt-4 text-sm text-red-400">{error}</p>} {error && <p className="mt-4 text-sm text-red-400">{error}</p>}
{result && ( {result && (
<div className="mt-6 flex gap-4 rounded-xl border border-neutral-800 bg-neutral-900 p-4"> <div className="mt-6 rounded-xl border border-neutral-800 bg-neutral-900 p-3">
{result.metadata.cover_art && ( {/* Tapping anywhere on the card plays it, not just a small button - the icon on the
<img src={result.metadata.cover_art} alt="" className="h-20 w-20 rounded-lg object-cover" /> right is a status indicator rendered inside this same button. Download stays a
)} separate control below since it's a genuinely different action. */}
<div className="min-w-0 flex-1"> <button
<p className="font-semibold text-white">{result.metadata.title}</p>
<p className="text-sm text-neutral-400">
{result.metadata.artist} · {result.metadata.album} · {result.metadata.genre}
</p>
<div className="mt-3 flex items-center gap-3">
<Button
size="sm"
onClick={() => onClick={() =>
toggle({ toggle({
id: result.metadata.library_song_id, id: result.metadata.library_song_id,
...@@ -101,28 +94,41 @@ export function Upload() { ...@@ -101,28 +94,41 @@ export function Upload() {
}) })
} }
disabled={isCurrent && streamLoading} disabled={isCurrent && streamLoading}
className="gap-1.5" aria-label={isCurrent && isPlaying ? 'Pause' : 'Play'}
className="flex w-full items-center gap-4 rounded-lg p-1 text-left transition-colors hover:bg-white/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400 disabled:cursor-not-allowed"
> >
{result.metadata.cover_art ? (
<img src={result.metadata.cover_art} alt="" className="h-16 w-16 shrink-0 rounded-lg object-cover" />
) : (
<div className="flex h-16 w-16 shrink-0 items-center justify-center rounded-lg bg-neutral-800 text-neutral-600">
<Play size={20} strokeWidth={1.75} />
</div>
)}
<div className="min-w-0 flex-1">
<p className="truncate font-semibold text-white">{result.metadata.title}</p>
<p className="truncate text-sm text-neutral-400">
{result.metadata.artist} · {result.metadata.album} · {result.metadata.genre}
</p>
</div>
<span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-neutral-800 text-white">
{isCurrent && streamLoading ? ( {isCurrent && streamLoading ? (
<span className="h-3.5 w-3.5 animate-spin rounded-full border-2 border-white/40 border-t-white" /> <span className="h-3.5 w-3.5 animate-spin rounded-full border-2 border-neutral-600 border-t-white" />
) : isCurrent && isPlaying ? ( ) : isCurrent && isPlaying ? (
<Pause size={14} strokeWidth={2} fill="currentColor" /> <Pause size={16} strokeWidth={2} fill="currentColor" />
) : ( ) : (
<Play size={14} strokeWidth={2} fill="currentColor" /> <Play size={16} strokeWidth={2} fill="currentColor" className="ml-0.5" />
)} )}
{isCurrent && isPlaying ? 'Pause' : 'Play'} </span>
</Button> </button>
<a <a
href={result.download_url} href={result.download_url}
target="_blank" target="_blank"
rel="noreferrer" rel="noreferrer"
className="text-sm text-neutral-400 hover:text-white hover:underline" className="mt-1 block px-1 text-sm text-neutral-400 hover:text-white hover:underline"
> >
Download tagged file Download tagged file
</a> </a>
</div> </div>
</div>
</div>
)} )}
</Layout> </Layout>
) )
......
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