add listen stuff, fix header responsiveness

This commit is contained in:
2024-07-21 15:11:00 -04:00
parent 00a65440ca
commit d88f72e297
6 changed files with 115 additions and 13 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ export default function Footer() {
}, [mailState])
return (
<div className="lg:w-1/2 md:w-full mx-auto rounded-lg text-center text-white bottom-0 left-0 right-0 p-4 select-none">
<div className="lg:w-1/2 bg-gray-500 md:w-full mx-auto rounded-lg text-center text-white bottom-0 left-0 right-0 p-4 select-none">
<h1 className="font-bold">&copy; {new Date().getFullYear()}, Alex Frantz. All Rights Reserved</h1>
<p>All logos & images on this page belong to their respective owners.</p>
+4 -3
View File
@@ -1,9 +1,10 @@
export default function Header() {
return (
<div className="text-white pt-4 mx-auto lg:w-1/2 sm:w-full">
<h1 className="font-bold text-2xl">Alex Frantz</h1>
<div className="text-white pt-4 mx-auto w-full sm:w-1/2 text-center sm:text-left">
<h1 className="text-2xl font-bold">Alex Frantz</h1>
<p>Professional button clicker & word typer</p>
<hr className="my-4" />
</div>
)
@@ -0,0 +1,90 @@
import { useState, useEffect } from 'react';
type MusicAPIResponse = {
data: {
tracks: MusicData[]
}
}
type MusicData = {
artist: {
mbid: string,
"#text": string
},
mbid: string,
album: {
mbid: string,
"#text": string,
},
name: string,
url: string,
image: MusicImage[]
}
type MusicImage = {
size: string,
"#text": string
}
export default function RecentListens() {
const [ data, setData ] = useState<MusicData[]>();
const [ errorState, setErrorState ] = useState<string>("");
const [ loading, setLoading ] = useState<boolean>(true);
useEffect(() => {
fetch("https://api.alexav.gg/v4/social/music", {
method: "get"
})
.then(async (res) => {
if (res.ok) {
const data = await res.json() as MusicAPIResponse
setData(data.data.tracks);
} else {
setErrorState("Failed to load! :(")
}
})
.catch((e: Error) => {
setErrorState(e.message)
})
setLoading(false);
}, []);
if (data) {
return (
<a href={data[0].url} target="_blank">
<div className="bg-white text-black p-4">
{
(loading) ? (
<h1>Loading..</h1>
) : (!errorState && data) ? (
<div className="flex items-center">
<img
src={data[0].image.filter((v) => v.size === "large")[0]['#text']}
width="100"
/>
<div className="flex flex-wrap mx-2">
<h1 className="w-full font-bold">{data[0].name}</h1>
<h1>{data[0].artist['#text']}</h1>
</div>
</div>
) : (
<>
<h1 className="font-bold text-2xl">Failed to fetch :(</h1>
<p>Check out <a className="underline" href="https://last.fm/user/lulawex" target="_blank">last.fm/lulawex</a> if this isn't working.</p>
<p className="text-sm italic">{errorState}</p>
</>
)
}
</div>
</a>
)
} else {
<>
<h1 className="font-bold text-2xl">No data :(</h1>
<p>Check out <a className="underline" href="https://last.fm/user/lulawex" target="_blank">last.fm/lulawex</a> if this isn't working.</p>
<p className="text-sm italic">{errorState}</p>
</>
}
}
@@ -19,10 +19,6 @@ export default function RecentPhoto() {
const [ loading, setLoading ] = useState<boolean>(true);
const [ errorState, setErrorState ] = useState<string | null>(null);
useEffect(() => {
console.log(data)
}, [data])
useEffect(() => {
fetch("https://photos-cors.alexav.gg", {
method: 'get',
@@ -33,7 +29,6 @@ export default function RecentPhoto() {
.then(async (res) => {
if (res.ok) {
console.log("ok!")
console.log(errorState)
const json = await res.json() as PhotoDataResponse[];
setData(json[0].result.data.json);
setLoading(false)