From f142054a7b62d479f25931f5305800259ccc7d7a Mon Sep 17 00:00:00 2001 From: yude Date: Tue, 23 Jan 2024 07:55:34 +0900 Subject: [PATCH] Add Spotify Now Playing --- src/components/Card.tsx | 21 +++++++++++----- src/components/NowPlaying.tsx | 47 +++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 src/components/NowPlaying.tsx diff --git a/src/components/Card.tsx b/src/components/Card.tsx index fcc3147..18f1cb7 100644 --- a/src/components/Card.tsx +++ b/src/components/Card.tsx @@ -3,6 +3,9 @@ import { faEnvelope } from '@fortawesome/free-regular-svg-icons' import { faPhone } from '@fortawesome/free-solid-svg-icons' import { faXTwitter, faDiscord, faGithub } from '@fortawesome/free-brands-svg-icons' +import NowPlaying from "./NowPlaying" +import Logo from "./Logo" + export default function Card() { return ( <> @@ -12,26 +15,32 @@ export default function Card() {

- yude +

+

- i@yude.jp + {" "} + i@yude.jp

- +81 70-8909-1949 + {" "} + +81 70-8909-1949

- @yude_jp + {" "} + @yude_jp

- yude + {" "} + yude

- yude + {" "} + yude

diff --git a/src/components/NowPlaying.tsx b/src/components/NowPlaying.tsx new file mode 100644 index 0000000..3c7fe3c --- /dev/null +++ b/src/components/NowPlaying.tsx @@ -0,0 +1,47 @@ +import { useState, useEffect } from 'react'; + +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +import { faMusic } from '@fortawesome/free-solid-svg-icons' + +export interface NowPlaying { + album?: string + artist?: string + isPlaying: boolean + title?: string + link?: string + album_art?: string + } + + +export default function NowPlaying() { + const [np, setNp] = useState(); + + useEffect(() => { + fetch( + "https://vercel-spotify-api.vercel.app/api/Spotify" + ) + .then(res => res.json()) + .then(data => { + if (data) { + setNp(data) + } + }) + }) + + return ( + <> + {np && np.isPlaying && +
+
+ +
+
+ {np.artist} +

{np.title}

+
+
+ } + + ) + } + \ No newline at end of file