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}')
......
This diff is collapsed.
...@@ -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