From 246ce335927f040e211178c29e69a69f6d16979b Mon Sep 17 00:00:00 2001 From: skidoodle Date: Thu, 28 Dec 2023 16:09:11 +0100 Subject: [PATCH] spotify: +progress bar --- src/components/SpotifyCard.tsx | 68 +++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/src/components/SpotifyCard.tsx b/src/components/SpotifyCard.tsx index 740651e..e4bbd77 100644 --- a/src/components/SpotifyCard.tsx +++ b/src/components/SpotifyCard.tsx @@ -11,6 +11,8 @@ interface SpotifyData { title: string url: string image: string + progress: number + length: number } } @@ -29,33 +31,55 @@ export const NowPlayingCard = () => { } }, []) + const calcProgress = () => { + if (spotify.song && spotify.song.length > 0) { + const progressPercentage = + (spotify.song.progress / spotify.song.length) * 100 + return `${progressPercentage}%` + } + return '0%' + } + return (
{spotify.song ? ( - Song cover art + <> + Song cover art +
+
+ Listening to{' '} + + + {truncate(`${spotify.song.title}`, 20)} + + +
+
+
+
+
+ ) : ( - + <> + +
+
+ Not listening to anything +
+
+ )} -
-
- Listening to{' '} - {spotify.song ? ( - - {truncate(`${spotify.song.title}`, 20)} - - ) : ( - nothing - )} -
-
) }