diff --git a/src/App.css b/src/App.css index c7a893b..938eb18 100644 --- a/src/App.css +++ b/src/App.css @@ -89,7 +89,6 @@ justify-content: space-around; font-size: larger; flex-wrap: wrap; - height: 80%; overflow-x: scroll; } @@ -269,8 +268,8 @@ .singlemusic { cursor: pointer; - min-width: 15em; - max-width: 15em; + width: 15em; + height: auto; word-wrap: anywhere; margin: 1em; padding: 1em; diff --git a/src/App.tsx b/src/App.tsx index 8c83584..7a17c9b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,7 +2,7 @@ import "./App.css"; import { AdvancedBr, Singular88, SingularOomfie } from "./components/comps.tsx"; import { createSignal, onMount } from "solid-js"; import Reviews from "./components/api.tsx"; -import Music, { MusicEntry } from "./components/music.tsx"; +import { Music, MusicEntry, Song } from "./components/music.tsx"; import { Bdpfp, Normalpfp } from "./components/pfp.tsx"; import { InfoCard } from "./components/middlecard.tsx"; @@ -61,16 +61,17 @@ function nyaboom() { } function App() { - const [musicList, setMusicList] = createSignal([]); + const [musicList, setMusicList] = createSignal([]); const [isLoading, setIsLoading] = createSignal(true); const [oomfies, setoomfies] = createSignal(<>oomfies); const [isAnimating, setIsAnimating] = createSignal(false); onMount(async () => { try { const response = await fetch( - "https://imtoolazytomakeaproperapi.amy.rip/", + "https://bopbot.amy.rip/", ); - const data = await response.json(); + const data = await response.json() as Song[]; + data.reverse(); setMusicList(data); } catch (error) { console.error("Error fetching music data:", error); @@ -271,7 +272,7 @@ function App() { {isLoading() ? (

Loading...

) : ( - musicList().map((link) => ) + musicList().map((link) => ) )} diff --git a/src/components/music.tsx b/src/components/music.tsx index 6a3d476..c423742 100644 --- a/src/components/music.tsx +++ b/src/components/music.tsx @@ -1,6 +1,18 @@ import { createSignal, onMount } from "solid-js"; -export default function Music(props: { shouldpopup: () => boolean, children: any }) { +export interface Song { + title: string; + artist: string; + apiProvider: string; + thumbnailUrl: string; + link: string; +} + +function shortenName(name: string, limit: number = 33): string { + return name.length > limit ? name.substring(0, limit - 3) + "..." : name +} + +export function Music(props: { shouldpopup: () => boolean, children: any }) { return
boolean, children: any
} -export function MusicEntry({ spotifylink }: { spotifylink: string }) { - const [musicInfo, setMusicInfo] = createSignal({}) as any; - const [isLoading, setIsLoading] = createSignal(true); - onMount(async () => { - try { - const apiresponse = await fetch(`https://corsisdum.exhq.dev/v1-alpha.1/links?url=spotify%253Atrack%253A${spotifylink}`) - const data = await apiresponse.json() - setMusicInfo(data) - } catch (error) { - console.error("Error fetching music data from song.link:", error); - } finally { - setIsLoading(false); - } - }) +export function MusicEntry(props: {musicInfo:Song}) { + return ( - <>{isLoading() ? ( -

Loading...

- ) : ( -
{ - document.location.href = musicInfo().pageUrl - }} class="singlemusic"> - {"album -
-
{ - musicInfo().entitiesByUniqueId[`SPOTIFY_SONG::${spotifylink}`]?.artistName?.length > 43 ? musicInfo().entitiesByUniqueId[`SPOTIFY_SONG::${spotifylink}`]?.artistName.substring(0, 30) + "..." : musicInfo().entitiesByUniqueId[`SPOTIFY_SONG::${spotifylink}`]?.artistName - }
-
{ - musicInfo().entitiesByUniqueId[`SPOTIFY_SONG::${spotifylink}`]?.title?.length > 43 ? musicInfo().entitiesByUniqueId[`SPOTIFY_SONG::${spotifylink}`]?.title.substring(0, 30) + "..." : musicInfo().entitiesByUniqueId[`SPOTIFY_SONG::${spotifylink}`]?.title - }
-
+
{ + document.location.href = props.musicInfo.link + }} class="singlemusic"> + {"album +
+
{ + shortenName(props.musicInfo.artist) + }
+
{ + shortenName(props.musicInfo.title) + }
- )} +
) } \ No newline at end of file