From 7a6288cc0214e7e1563bcc2a0855b5ef2d65f525 Mon Sep 17 00:00:00 2001 From: JSC Date: Sat, 4 Oct 2025 21:55:20 +0200 Subject: [PATCH] feat: update PlayNextQueue component and integrate it into Player; adjust layout in Playlist for improved UI --- src/components/player/CompactPlayer.tsx | 1 + src/components/player/PlayNextQueue.tsx | 147 +++++++++++++----------- src/components/player/Player.tsx | 12 +- src/components/player/Playlist.tsx | 2 +- 4 files changed, 88 insertions(+), 74 deletions(-) diff --git a/src/components/player/CompactPlayer.tsx b/src/components/player/CompactPlayer.tsx index c9888ce..46fb115 100644 --- a/src/components/player/CompactPlayer.tsx +++ b/src/components/player/CompactPlayer.tsx @@ -22,6 +22,7 @@ export function CompactPlayer({ className }: CompactPlayerProps) { volume: 80, previous_volume: 80, position: 0, + play_next_queue: [], }) const [isLoading, setIsLoading] = useState(false) diff --git a/src/components/player/PlayNextQueue.tsx b/src/components/player/PlayNextQueue.tsx index 89ab6a1..6bf6e53 100644 --- a/src/components/player/PlayNextQueue.tsx +++ b/src/components/player/PlayNextQueue.tsx @@ -1,92 +1,105 @@ import { Badge } from '@/components/ui/badge' import { ScrollArea } from '@/components/ui/scroll-area' +import { + Popover, + PopoverContent, + PopoverTrigger, +} from '@/components/ui/popover' import { filesService } from '@/lib/api/services/files' import { type PlayerSound } from '@/lib/api/services/player' -import { cn } from '@/lib/utils' import { formatDuration } from '@/utils/format-duration' import { Music, ListPlus } from 'lucide-react' interface PlayNextQueueProps { queue: PlayerSound[] - variant?: 'normal' | 'maximized' } -export function PlayNextQueue({ queue, variant = 'normal' }: PlayNextQueueProps) { +export function PlayNextQueue({ queue }: PlayNextQueueProps) { if (queue.length === 0) { return null } + // Calculate total duration + const totalDuration = queue.reduce((sum, sound) => sum + sound.duration, 0) + return ( -
- {/* Header */} -
-
- -

Play Next

+ + +
+
+ + Play Next +
+ + {queue.length} {queue.length === 1 ? 'track' : 'tracks'} +
- - {queue.length} {queue.length === 1 ? 'track' : 'tracks'} - -
+ + +
+ {/* Header - Fixed */} +
+

Play Next Queue

+ + {queue.length} + +
- {/* Track List */} - -
- {queue.map((sound, index) => ( -
0 && 'mt-1', - )} - > - {/* Queue position - 1 column */} -
- {index + 1} -
- - {/* Thumbnail - 1 column */} -
+ {/* Track List - Scrollable */} + +
+ {queue.map((sound, index) => (
- {sound.thumbnail ? ( - - ) : ( - - )} + {/* Queue position - 1 column */} +
+ {index + 1} +
+ + {/* Thumbnail - 1 column */} +
+
+ {sound.thumbnail ? ( + + ) : ( + + )} +
+
+ + {/* Track name - 6 columns */} +
+ + {sound.name} + +
+ + {/* Duration - 2 columns */} +
+ + {formatDuration(sound.duration)} + +
-
- - {/* Track name - 6 columns */} -
- - {sound.name} - -
- - {/* Duration - 2 columns */} -
- - {formatDuration(sound.duration)} - -
+ ))}
- ))} + + + {/* Footer - Fixed */} +
+
+ Total playtime + {formatDuration(totalDuration)} +
+
- -
+ + ) } diff --git a/src/components/player/Player.tsx b/src/components/player/Player.tsx index 2ce3bb2..ff23f7a 100644 --- a/src/components/player/Player.tsx +++ b/src/components/player/Player.tsx @@ -378,7 +378,7 @@ export function Player({ className, onPlayerModeChange }: PlayerProps) { {/* Play Next Queue */} {state.play_next_queue.length > 0 && ( -
+
)} @@ -448,14 +448,14 @@ export function Player({ className, onPlayerModeChange }: PlayerProps) { {/* Playlist Sidebar */} {state.playlist && ( -
-
+
+

Playlist

{state.playlist.sounds.length} tracks

-
+
0 && ( -
- +
+
)}
diff --git a/src/components/player/Playlist.tsx b/src/components/player/Playlist.tsx index 5b59275..e434842 100644 --- a/src/components/player/Playlist.tsx +++ b/src/components/player/Playlist.tsx @@ -76,7 +76,7 @@ export function Playlist({ {/* Track List */}
{filteredSounds.map((sound) => {