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', () => {
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')
renderPlayer()
await userEvent.click(screen.getByText('Start Playback'))
await openFullPlayer()
const lyricsButton = screen.getByRole('button', { name: 'View lyrics' })
await userEvent.click(lyricsButton)
const toggleButton = screen.getByRole('button', { name: 'Show lyrics' })
await userEvent.click(toggleButton)
const lyricsRegion = await screen.findByRole('region', { name: 'Lyrics' })
expect(lyricsRegion).toHaveTextContent('Line one')
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' }))
await waitFor(() => expect(lyricsButton).toHaveFocus())
// 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')
})
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')
renderPlayer()
await userEvent.click(screen.getByText('Start Playback'))
await openFullPlayer()
await userEvent.click(screen.getByRole('button', { name: 'View lyrics' }))
expect(await screen.findByText('Line one')).toBeInTheDocument()
await userEvent.click(screen.getByRole('button', { name: 'Show lyrics' }))
expect(await screen.findByRole('region', { name: 'Lyrics' })).toHaveTextContent('Line one')
await userEvent.click(screen.getByText('Switch To No-Lyrics Song'))
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')
function ProbeNoLyrics() {
......@@ -134,7 +139,7 @@ describe('FullPlayer', () => {
await userEvent.click(screen.getByText('Start Playback'))
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 () => {
......@@ -152,19 +157,19 @@ describe('FullPlayer', () => {
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')
renderPlayer()
await userEvent.click(screen.getByText('Start Playback'))
const openButton = await openFullPlayer()
await userEvent.click(screen.getByRole('button', { name: 'View lyrics' }))
await screen.findByText('Line one')
await userEvent.click(screen.getByRole('button', { name: 'Show lyrics' }))
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 waitFor(() => expect(dialog().getByRole('button', { name: 'Pause' })).toBeInTheDocument())
await waitFor(() => expect(screen.queryByRole('region', { name: 'Lyrics' })).not.toBeInTheDocument())
expect(screen.getByRole('dialog')).toBeInTheDocument()
await userEvent.keyboard('{Escape}')
......
......@@ -4,6 +4,7 @@ import {
ChevronDown,
ChevronLeft,
ChevronRight,
Disc3,
ListMusic,
Music2,
Pause,
......@@ -28,14 +29,14 @@ function formatTime(seconds: number): string {
return `${mins}:${secs.toString().padStart(2, '0')}`
}
type SecondaryView = 'lyrics' | 'queue' | null
/** Full-screen "Now Playing" view, opened from NowPlayingBar - mirrors Spotify's now-playing
* screen: cover art is always the primary view, with Lyrics and Queue reached as separate
* screens that slide in from the right (a push-navigation feel, not a tab switcher) and slide
* back out on their own back button. 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. 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. */
export function FullPlayer() {
const {
currentSong,
......@@ -56,11 +57,11 @@ export function FullPlayer() {
toggleShuffle,
cycleRepeat,
} = 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 collapseButtonRef = useRef<HTMLButtonElement>(null)
const secondaryBackButtonRef = useRef<HTMLButtonElement>(null)
const lyricsButtonRef = useRef<HTMLButtonElement>(null)
const queueBackButtonRef = useRef<HTMLButtonElement>(null)
const queueButtonRef = useRef<HTMLButtonElement>(null)
useEffect(() => {
......@@ -70,27 +71,33 @@ export function FullPlayer() {
// 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.
useEffect(() => {
if (!visible) setSecondaryView(null)
if (!visible) {
setShowLyrics(false)
setQueueOpen(false)
}
}, [visible])
useEffect(() => {
if (secondaryView) secondaryBackButtonRef.current?.focus()
}, [secondaryView])
if (queueOpen) queueBackButtonRef.current?.focus()
}, [queueOpen])
useEffect(() => {
if (!visible) return
function onKeyDown(e: globalThis.KeyboardEvent) {
if (e.key !== 'Escape') return
// Escape backs out one level at a time, same as the physical back button would.
setSecondaryView((current) => {
if (current) return null
// Escape backs out one level at a time: queue screen, then lyrics, then the player itself.
if (queueOpen) {
setQueueOpen(false)
queueButtonRef.current?.focus()
} else if (showLyrics) {
setShowLyrics(false)
} else {
collapse()
return current
})
}
}
document.addEventListener('keydown', onKeyDown)
return () => document.removeEventListener('keydown', onKeyDown)
}, [visible, collapse])
}, [visible, queueOpen, showLyrics, collapse])
useEffect(() => {
if (!visible) return
......@@ -103,21 +110,18 @@ export function FullPlayer() {
if (!mounted || !currentSong) return null
function openLyrics() {
setSecondaryView('lyrics')
}
function openQueue() {
setSecondaryView('queue')
setQueueOpen(true)
}
function closeSecondary() {
setSecondaryView(null)
;(secondaryView === 'lyrics' ? lyricsButtonRef : queueButtonRef).current?.focus()
function closeQueue() {
setQueueOpen(false)
queueButtonRef.current?.focus()
}
function jumpTo(song: PlayableSong) {
toggle(song, queue)
// 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.
setSecondaryView(null)
setQueueOpen(false)
collapseButtonRef.current?.focus()
}
......@@ -137,7 +141,7 @@ export function FullPlayer() {
{/* 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
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">
{currentSong.coverart && (
<img
......@@ -149,13 +153,13 @@ export function FullPlayer() {
<div className="absolute inset-0 bg-neutral-950/75" />
</div>
{/* Primary screen: cover art, transport, and (if available) a lyrics preview bar. Slides
left and out of view when a secondary screen is open. */}
{/* 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. */}
<div
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
className="relative flex items-center justify-between px-4 pt-4 sm:px-6"
......@@ -164,7 +168,7 @@ export function FullPlayer() {
<button
ref={collapseButtonRef}
onClick={collapse}
tabIndex={secondaryView ? -1 : 0}
tabIndex={queueOpen ? -1 : 0}
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"
>
......@@ -174,7 +178,7 @@ export function FullPlayer() {
<button
ref={queueButtonRef}
onClick={openQueue}
tabIndex={secondaryView ? -1 : 0}
tabIndex={queueOpen ? -1 : 0}
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"
>
......@@ -182,7 +186,15 @@ export function FullPlayer() {
</button>
</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 ? (
<img
src={currentSong.coverart}
......@@ -202,6 +214,27 @@ export function FullPlayer() {
)}
</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
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)' }}
......@@ -222,7 +255,7 @@ export function FullPlayer() {
step={0.1}
onChange={(e) => seek(Number(e.target.value))}
disabled={!duration}
tabIndex={secondaryView ? -1 : 0}
tabIndex={queueOpen ? -1 : 0}
aria-label="Seek"
aria-valuetext={`${formatTime(progress)} of ${formatTime(duration)}`}
className="seek-range w-full disabled:opacity-40"
......@@ -242,7 +275,7 @@ export function FullPlayer() {
<div className="mt-5 flex items-center justify-between">
<button
onClick={toggleShuffle}
tabIndex={secondaryView ? -1 : 0}
tabIndex={queueOpen ? -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-emerald-400 ${
......@@ -255,7 +288,7 @@ export function FullPlayer() {
<div className="flex items-center gap-8">
<button
onClick={previous}
tabIndex={secondaryView ? -1 : 0}
tabIndex={queueOpen ? -1 : 0}
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"
>
......@@ -264,7 +297,7 @@ export function FullPlayer() {
<button
onClick={() => toggle(currentSong)}
disabled={isLoading}
tabIndex={secondaryView ? -1 : 0}
tabIndex={queueOpen ? -1 : 0}
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"
>
......@@ -279,7 +312,7 @@ export function FullPlayer() {
<button
onClick={next}
disabled={!hasNext}
tabIndex={secondaryView ? -1 : 0}
tabIndex={queueOpen ? -1 : 0}
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"
>
......@@ -289,7 +322,7 @@ export function FullPlayer() {
<button
onClick={cycleRepeat}
tabIndex={secondaryView ? -1 : 0}
tabIndex={queueOpen ? -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-emerald-400 ${
......@@ -300,68 +333,60 @@ export function FullPlayer() {
</button>
</div>
{/* Lyrics preview bar - a single representative line, tappable to open the full
Lyrics screen. Only shown when the track actually has lyrics, matching Spotify
(which hides this row entirely rather than linking to an empty screen). */}
{/* 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
ref={lyricsButtonRef}
onClick={openLyrics}
tabIndex={secondaryView ? -1 : 0}
aria-label="View lyrics"
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-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" />
<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" />
</button>
)}
</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
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
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={secondaryBackButtonRef}
onClick={closeSecondary}
tabIndex={secondaryView ? 0 : -1}
ref={queueBackButtonRef}
onClick={closeQueue}
tabIndex={queueOpen ? 0 : -1}
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"
>
<ChevronLeft size={22} strokeWidth={2} />
</button>
<p className="text-sm font-semibold">{secondaryView === 'lyrics' ? 'Lyrics' : '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." />
)}
<p className="text-sm font-semibold">Queue</p>
</div>
)}
{secondaryView === 'queue' && (
<div className="relative mx-auto w-full max-w-md flex-1 overflow-y-auto px-4 py-4">
{queue.length === 0 ? (
<EmptyState icon={ListMusic} message="Nothing queued." />
......@@ -373,7 +398,7 @@ export function FullPlayer() {
<li key={song.id}>
<button
onClick={() => jumpTo(song)}
tabIndex={secondaryView === 'queue' ? 0 : -1}
tabIndex={queueOpen ? 0 : -1}
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 ${
isCurrent ? 'text-emerald-400' : 'text-neutral-300 hover:bg-white/5 hover:text-white'
......@@ -400,7 +425,6 @@ export function FullPlayer() {
</ul>
)}
</div>
)}
</div>
</div>
)
......
......@@ -3,7 +3,6 @@ import { Music2, Pause, Play } from 'lucide-react'
import { getLibrary, type LibrarySong } from '../api/library'
import { ApiError } from '../api/client'
import { Layout } from '../components/Layout'
import { Button } from '../components/ui/Button'
import { SkeletonRow } from '../components/ui/Skeleton'
import { EmptyState } from '../components/ui/EmptyState'
import { usePlayer, type PlayableSong } from '../context/PlayerContext'
......@@ -50,7 +49,16 @@ export function Library() {
{songs.map((song) => {
const isCurrent = currentSong?.id === song.id
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 ? (
<img src={song.coverart} alt="" className="h-12 w-12 shrink-0 rounded-md object-cover" />
) : (
......@@ -65,13 +73,7 @@ export function Library() {
{song.album ? ` · ${song.album}` : ''}
</p>
</div>
<Button
variant="secondary"
size="icon"
onClick={() => toggle(toPlayable(song), songs.map(toPlayable))}
disabled={isCurrent && streamLoading}
aria-label={isCurrent && isPlaying ? 'Pause' : 'Play'}
>
<span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-neutral-800 text-white">
{isCurrent && streamLoading ? (
<span className="h-3.5 w-3.5 animate-spin rounded-full border-2 border-neutral-600 border-t-white" />
) : isCurrent && isPlaying ? (
......@@ -79,7 +81,8 @@ export function Library() {
) : (
<Play size={16} strokeWidth={2} fill="currentColor" className="ml-0.5" />
)}
</Button>
</span>
</button>
</li>
)
})}
......
......@@ -78,18 +78,11 @@ export function Upload() {
{error && <p className="mt-4 text-sm text-red-400">{error}</p>}
{result && (
<div className="mt-6 flex gap-4 rounded-xl border border-neutral-800 bg-neutral-900 p-4">
{result.metadata.cover_art && (
<img src={result.metadata.cover_art} alt="" className="h-20 w-20 rounded-lg object-cover" />
)}
<div className="min-w-0 flex-1">
<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"
<div className="mt-6 rounded-xl border border-neutral-800 bg-neutral-900 p-3">
{/* Tapping anywhere on the card plays it, not just a small button - the icon on the
right is a status indicator rendered inside this same button. Download stays a
separate control below since it's a genuinely different action. */}
<button
onClick={() =>
toggle({
id: result.metadata.library_song_id,
......@@ -101,28 +94,41 @@ export function Upload() {
})
}
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 ? (
<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 ? (
<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'}
</Button>
</span>
</button>
<a
href={result.download_url}
target="_blank"
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
</a>
</div>
</div>
</div>
)}
</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