diff --git a/src/components/player/Playlist.tsx b/src/components/player/Playlist.tsx index b65b838..9144253 100644 --- a/src/components/player/Playlist.tsx +++ b/src/components/player/Playlist.tsx @@ -1,10 +1,13 @@ +import { useState } from 'react' import { Badge } from '@/components/ui/badge' +import { Button } from '@/components/ui/button' +import { Input } from '@/components/ui/input' import { ScrollArea } from '@/components/ui/scroll-area' import { filesService } from '@/lib/api/services/files' import { type PlayerPlaylist } from '@/lib/api/services/player' import { cn } from '@/lib/utils' import { formatDuration } from '@/utils/format-duration' -import { Music, Play } from 'lucide-react' +import { Music, Play, Search, X } from 'lucide-react' interface PlaylistProps { playlist: PlayerPlaylist @@ -19,6 +22,12 @@ export function Playlist({ onTrackSelect, variant = 'normal', }: PlaylistProps) { + const [searchQuery, setSearchQuery] = useState('') + + const filteredSounds = playlist.sounds.filter((sound) => + sound.name.toLowerCase().includes(searchQuery.toLowerCase()) + ) + return (
{/* Header */} @@ -29,28 +38,52 @@ export function Playlist({
+ {/* Search */} +
+ + setSearchQuery(e.target.value)} + className="h-8 pl-8 pr-8 text-xs" + /> + {searchQuery && ( + + )} +
+ {/* Track List */}
- {playlist.sounds.map((sound, index) => ( -
onTrackSelect(index)} - > - {/* Track number/play icon - 1 column */} -
- {currentIndex === index ? ( - - ) : ( - {index + 1} + {filteredSounds.map((sound) => { + const originalIndex = playlist.sounds.findIndex((s) => s.id === sound.id) + return ( +
+ onClick={() => onTrackSelect(originalIndex)} + > + {/* Track number/play icon - 1 column */} +
+ {currentIndex === originalIndex ? ( + + ) : ( + {originalIndex + 1} + )} +
{/* Thumbnail - 1 column */}
@@ -78,7 +111,7 @@ export function Playlist({ className={cn( 'font-medium truncate block', variant === 'maximized' ? 'text-sm' : 'text-xs', - currentIndex === index ? 'text-primary' : 'text-foreground', + currentIndex === originalIndex ? 'text-primary' : 'text-foreground', )} > {sound.name} @@ -92,7 +125,7 @@ export function Playlist({
- ))} + )})}