Compare commits
4
Commits
No files matched your search
@@ -31,7 +31,7 @@ export function PageHeader({
|
||||
<header
|
||||
className={cn(
|
||||
"flex shrink-0 items-center gap-2 border-b px-4 py-3",
|
||||
!title && !openApp && "md:hidden"
|
||||
!title && "md:hidden"
|
||||
)}
|
||||
>
|
||||
<MobileSidebarTrigger />
|
||||
|
||||
@@ -13,7 +13,7 @@ export function OpenAppButton() {
|
||||
<button
|
||||
type="button"
|
||||
onClick={openApp}
|
||||
className="ml-auto inline-flex shrink-0 items-center gap-1 text-sm font-medium hover:underline focus-visible:outline-2 focus-visible:outline-offset-4"
|
||||
className="ml-auto inline-flex shrink-0 items-center gap-1 text-sm font-medium hover:underline focus-visible:outline-2 focus-visible:outline-offset-4 md:hidden"
|
||||
>
|
||||
Open App
|
||||
<ArrowUpRight aria-hidden className="size-4" />
|
||||
|
||||
@@ -76,8 +76,8 @@ export function PlayerBar() {
|
||||
queueOpen && !isMobile && "right-72"
|
||||
)}
|
||||
>
|
||||
<div className="pointer-events-auto flex w-full max-w-6xl items-center gap-2 rounded-full border border-foreground/20 bg-(--player-background) px-3 py-2 text-card-foreground shadow-lg [--player-background:var(--card)] @min-[640px]:gap-5 @min-[640px]:px-5 @min-[640px]:py-3 dark:border-white/20 dark:text-white dark:[--player-background:#303033]">
|
||||
<div className="flex shrink-0 items-center gap-0 @min-[640px]:gap-1 [&_button]:size-7 @min-[640px]:[&_button]:size-10 [&_svg]:size-4 @min-[640px]:[&_svg]:size-6">
|
||||
<div className="pointer-events-auto flex w-full max-w-[40rem] items-center gap-2 rounded-full border border-foreground/20 bg-(--player-background) px-3 py-2 text-card-foreground shadow-lg [--player-background:var(--card)] md:gap-3 md:py-1.5 dark:border-white/20 dark:text-white dark:[--player-background:#303033]">
|
||||
<div className="flex shrink-0 items-center gap-0 md:gap-0.5 [&_button]:size-7 [&_svg]:size-4">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
@@ -91,7 +91,7 @@ export function PlayerBar() {
|
||||
)}
|
||||
onClick={() => void toggleShuffle()}
|
||||
>
|
||||
<Shuffle className="size-4 @min-[640px]:size-6" />
|
||||
<Shuffle className="size-4" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
@@ -100,7 +100,7 @@ export function PlayerBar() {
|
||||
disabled={!hasQueue}
|
||||
onClick={() => void skipPrevious()}
|
||||
>
|
||||
<SkipBack className="size-4 fill-current @min-[640px]:size-6" />
|
||||
<SkipBack className="size-4 fill-current" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
@@ -110,9 +110,9 @@ export function PlayerBar() {
|
||||
onClick={() => setIsPlaying(!isPlaying)}
|
||||
>
|
||||
{isPlaying ? (
|
||||
<Pause className="size-5! fill-current @min-[640px]:size-8!" />
|
||||
<Pause className="size-5! fill-current" />
|
||||
) : (
|
||||
<Play className="size-5! fill-current @min-[640px]:size-8!" />
|
||||
<Play className="size-5! fill-current" />
|
||||
)}
|
||||
</Button>
|
||||
<Button
|
||||
@@ -122,7 +122,7 @@ export function PlayerBar() {
|
||||
disabled={!hasQueue}
|
||||
onClick={() => void skipNext()}
|
||||
>
|
||||
<SkipForward className="size-4 fill-current @min-[640px]:size-6" />
|
||||
<SkipForward className="size-4 fill-current" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
@@ -138,33 +138,33 @@ export function PlayerBar() {
|
||||
onClick={() => void cycleRepeat()}
|
||||
>
|
||||
{repeatEnabled === "once" ? (
|
||||
<Repeat1 className="size-4 @min-[640px]:size-6" />
|
||||
<Repeat1 className="size-4" />
|
||||
) : (
|
||||
<Repeat className="size-4 @min-[640px]:size-6" />
|
||||
<Repeat className="size-4" />
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="relative flex h-11 min-w-0 flex-1 items-center gap-2 pb-2 @min-[640px]:h-16 @min-[640px]:gap-3">
|
||||
<div className="relative flex h-11 min-w-0 flex-1 items-center gap-2 pb-2 md:h-9 md:pb-1">
|
||||
{currentSong ? (
|
||||
<>
|
||||
<div className="relative size-9 shrink-0 overflow-hidden rounded @min-[640px]:size-14">
|
||||
<div className="relative size-9 shrink-0 overflow-hidden rounded md:size-8">
|
||||
<Image
|
||||
src={albumCoverUrl(currentSong.album.id)}
|
||||
alt={currentSong.album.title}
|
||||
fill
|
||||
sizes="56px"
|
||||
sizes="36px"
|
||||
className="object-cover"
|
||||
/>
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<Link
|
||||
href={`/album/${currentSong.album.id}`}
|
||||
className="block truncate text-sm font-semibold hover:underline @min-[640px]:text-xl"
|
||||
className="block truncate text-sm font-semibold hover:underline md:text-[13px] md:leading-4"
|
||||
>
|
||||
{currentSong.title}
|
||||
</Link>
|
||||
<p className="truncate text-xs @min-[640px]:text-lg">
|
||||
<p className="truncate text-xs">
|
||||
<Link
|
||||
href={`/artist/${currentSong.artist.id}`}
|
||||
className="hover:underline"
|
||||
@@ -200,7 +200,7 @@ export function PlayerBar() {
|
||||
<div className="absolute inset-x-0 -bottom-1">
|
||||
<Slider
|
||||
className={cn(
|
||||
"h-3 flex-1 [&_[data-slot=slider-range]]:bg-current/80 [&_[data-slot=slider-thumb]]:size-2 [&_[data-slot=slider-thumb]]:border-current [&_[data-slot=slider-thumb]]:bg-current [&_[data-slot=slider-thumb]]:opacity-0 focus-within:[&_[data-slot=slider-thumb]]:opacity-100 hover:[&_[data-slot=slider-thumb]]:opacity-100 [&_[data-slot=slider-track]]:h-[3px] [&_[data-slot=slider-track]]:bg-current/30",
|
||||
"h-3 flex-1 [&_[data-slot=slider-range]]:bg-current/80 [&_[data-slot=slider-thumb]]:size-2 [&_[data-slot=slider-thumb]]:border-current [&_[data-slot=slider-thumb]]:bg-current [&_[data-slot=slider-thumb]]:opacity-0 focus-within:[&_[data-slot=slider-thumb]]:opacity-100 hover:[&_[data-slot=slider-thumb]]:opacity-100 [&_[data-slot=slider-track]]:h-[3px] [&_[data-slot=slider-track]]:bg-current/30 md:[&_[data-slot=slider-track]]:h-0.5",
|
||||
!hasActiveSong && "[&_[data-slot=slider-thumb]]:hidden"
|
||||
)}
|
||||
min={0}
|
||||
@@ -222,7 +222,7 @@ export function PlayerBar() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex shrink-0 items-center gap-0 @min-[640px]:gap-2 [&_button]:size-7 @min-[640px]:[&_button]:size-10 [&_svg]:size-4 @min-[640px]:[&_svg]:size-6">
|
||||
<div className="flex shrink-0 items-center gap-0 md:gap-1 [&_button]:size-7 [&_svg]:size-4">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
@@ -230,7 +230,7 @@ export function PlayerBar() {
|
||||
aria-label="Lyrics"
|
||||
disabled
|
||||
>
|
||||
<MessageSquareQuote className="size-4 @min-[640px]:size-6" />
|
||||
<MessageSquareQuote className="size-4" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
@@ -240,12 +240,12 @@ export function PlayerBar() {
|
||||
className={cn(queueOpen && "text-primary")}
|
||||
onClick={toggleQueueOpen}
|
||||
>
|
||||
<ListMusic className="size-4 @min-[640px]:size-6" />
|
||||
<ListMusic className="size-4" />
|
||||
</Button>
|
||||
<Popover>
|
||||
<PopoverTrigger asChild>
|
||||
<Button variant="ghost" size="icon" aria-label="Volume">
|
||||
<Volume2 className="size-4 @min-[640px]:size-6" />
|
||||
<Volume2 className="size-4" />
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent side="top" align="end" className="w-40">
|
||||
|
||||
@@ -6,7 +6,7 @@ import * as React from "react"
|
||||
import Image from "next/image"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { useMutation } from "convex/react"
|
||||
import { Play, Share2, Shuffle, Star, Trash2 } from "lucide-react"
|
||||
import { Play, SearchIcon, Share2, Shuffle, Star, Trash2 } from "lucide-react"
|
||||
import { toast } from "sonner"
|
||||
|
||||
import { useAddToPlaylist } from "@/components/add-to-playlist-provider"
|
||||
@@ -305,6 +305,19 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) {
|
||||
const songs = isFavorites
|
||||
? playlist.songs.filter((song) => !hiddenFavoriteIds.has(song.id))
|
||||
: playlistSongs
|
||||
const [searchQuery, setSearchQuery] = React.useState("")
|
||||
const normalizedQuery = searchQuery.trim().toLowerCase()
|
||||
const filteredSongs = React.useMemo(
|
||||
() =>
|
||||
normalizedQuery
|
||||
? songs.filter((song) =>
|
||||
[song.title, song.artist.name, song.album.title].some((value) =>
|
||||
value.toLowerCase().includes(normalizedQuery)
|
||||
)
|
||||
)
|
||||
: songs,
|
||||
[songs, normalizedQuery]
|
||||
)
|
||||
const playlistSongIds = React.useMemo(
|
||||
() => songs.map((song) => song.id as Id<"songs">),
|
||||
[songs]
|
||||
@@ -327,7 +340,8 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) {
|
||||
handleSelect,
|
||||
handlePointerDown,
|
||||
prepareContextMenu,
|
||||
} = useTrackSelection(songs)
|
||||
clearSelection,
|
||||
} = useTrackSelection(filteredSongs)
|
||||
|
||||
const selectedStationArtistId = React.useMemo(
|
||||
() => stationArtistId(songs, selectedIds),
|
||||
@@ -335,8 +349,12 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) {
|
||||
)
|
||||
|
||||
const selectionPositions = React.useMemo(
|
||||
() => getSelectionRangePositions(songs.map((song) => song.id), selectedIds),
|
||||
[songs, selectedIds]
|
||||
() =>
|
||||
getSelectionRangePositions(
|
||||
filteredSongs.map((song) => song.id),
|
||||
selectedIds
|
||||
),
|
||||
[filteredSongs, selectedIds]
|
||||
)
|
||||
const totalDurationSeconds = React.useMemo(
|
||||
() => sumDurationSeconds(songs),
|
||||
@@ -461,7 +479,13 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) {
|
||||
}
|
||||
|
||||
function handleDrop(targetIndex: number) {
|
||||
if (isFavorites || !isOwner || dragIndex === null || dragIndex === targetIndex) {
|
||||
if (
|
||||
normalizedQuery ||
|
||||
isFavorites ||
|
||||
!isOwner ||
|
||||
dragIndex === null ||
|
||||
dragIndex === targetIndex
|
||||
) {
|
||||
setDragIndex(null)
|
||||
return
|
||||
}
|
||||
@@ -633,13 +657,31 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{songs.length > 0 ? (
|
||||
songs.map((song, index) => (
|
||||
<div className="px-6 pb-4">
|
||||
<div className="relative max-w-sm">
|
||||
<SearchIcon className="pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground" />
|
||||
<input
|
||||
type="search"
|
||||
aria-label="Search playlist"
|
||||
placeholder="Search playlist"
|
||||
value={searchQuery}
|
||||
onChange={(event) => {
|
||||
setSearchQuery(event.target.value)
|
||||
clearSelection()
|
||||
setActiveTrackId("")
|
||||
setDragIndex(null)
|
||||
}}
|
||||
className="h-10 w-full min-w-0 rounded-full border border-input bg-input/30 pr-3 pl-9 text-sm text-foreground transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{filteredSongs.length > 0 ? (
|
||||
filteredSongs.map((song, index) => (
|
||||
<PlaylistSongRow
|
||||
key={song.id}
|
||||
song={song}
|
||||
index={index}
|
||||
isOwner={isOwner && !isFavorites}
|
||||
isOwner={isOwner && !isFavorites && !normalizedQuery}
|
||||
canRemove={isFavorites || isOwner}
|
||||
showFavoriteInMenu={!isFavorites}
|
||||
removeLabel={
|
||||
@@ -679,14 +721,14 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) {
|
||||
onMediaAction={handleMediaAction}
|
||||
onRemove={() => handleRemoveSong(song.id)}
|
||||
onDragStart={(event) => {
|
||||
if (isFavorites || !isOwner) {
|
||||
if (normalizedQuery || isFavorites || !isOwner) {
|
||||
return
|
||||
}
|
||||
setDragIndex(index)
|
||||
event.dataTransfer.effectAllowed = "move"
|
||||
}}
|
||||
onDragOver={(event) => {
|
||||
if (isFavorites || !isOwner) {
|
||||
if (normalizedQuery || isFavorites || !isOwner) {
|
||||
return
|
||||
}
|
||||
event.preventDefault()
|
||||
@@ -707,7 +749,9 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) {
|
||||
))
|
||||
) : (
|
||||
<p className="px-6 py-8 text-sm text-muted-foreground">
|
||||
This playlist has no songs yet.
|
||||
{normalizedQuery
|
||||
? "No songs found."
|
||||
: "This playlist has no songs yet."}
|
||||
</p>
|
||||
)}
|
||||
<MediaCollectionFooter
|
||||
|
||||
Reference in new issue
Block a user