Skip to content

Commit c78d0d9

Browse files
committed
feat: Add track index and total tracks to PlayerWidget navigation
1 parent cf3b5af commit c78d0d9

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/components/ListenToPlayer/PlayerWidget/index.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ interface PlayerWidgetProps {
3030
handleCloseWidget: () => void
3131
isExpanded: boolean
3232
setIsExpanded: (isExpanded: boolean) => void
33+
currentTrackIndex: number
34+
totalTracks: number
3335
}
3436

3537
const PlayerWidget = ({
@@ -48,6 +50,8 @@ const PlayerWidget = ({
4850
handleCloseWidget,
4951
isExpanded,
5052
setIsExpanded,
53+
currentTrackIndex,
54+
totalTracks,
5155
}: PlayerWidgetProps) => {
5256
const [isDragging, setIsDragging] = useState(false)
5357
const scrubBarRef = useRef<HTMLDivElement>(null)
@@ -195,7 +199,10 @@ const PlayerWidget = ({
195199
</div>
196200
<Tooltip content={"Previous"}>
197201
<button
198-
className="cursor-pointer text-2xl text-disabled hover:text-body"
202+
className={cn(
203+
"cursor-pointer text-2xl hover:text-primary",
204+
currentTrackIndex === 0 ? "text-disabled" : "text-body-medium"
205+
)}
199206
onClick={handlePrevious}
200207
title="Previous"
201208
aria-label={"Previous"}
@@ -215,7 +222,12 @@ const PlayerWidget = ({
215222
</Tooltip>
216223
<Tooltip content={"Next"}>
217224
<button
218-
className="cursor-pointer text-2xl text-disabled hover:text-body"
225+
className={cn(
226+
"cursor-pointer text-2xl hover:text-primary",
227+
currentTrackIndex === totalTracks - 1
228+
? "text-disabled"
229+
: "text-body-medium"
230+
)}
219231
onClick={handleNext}
220232
title="Next"
221233
aria-label={"Next"}

src/components/ListenToPlayer/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ const ListenToPlayer = ({ slug }: { slug: string }) => {
245245
playbackSpeed={playbackSpeed}
246246
handlePlaybackSpeed={handlePlaybackSpeed}
247247
handleCloseWidget={handleCloseWidget}
248+
currentTrackIndex={currentTrackIndex}
249+
totalTracks={playlist.length}
248250
/>
249251
</div>
250252
</div>

0 commit comments

Comments
 (0)