a bit less horrible
This commit is contained in:
parent
85ae72ffb6
commit
8ac5d4219c
3 changed files with 39 additions and 41 deletions
|
|
@ -89,7 +89,6 @@
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
font-size: larger;
|
font-size: larger;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
height: 80%;
|
|
||||||
overflow-x: scroll;
|
overflow-x: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -269,8 +268,8 @@
|
||||||
|
|
||||||
.singlemusic {
|
.singlemusic {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
min-width: 15em;
|
width: 15em;
|
||||||
max-width: 15em;
|
height: auto;
|
||||||
word-wrap: anywhere;
|
word-wrap: anywhere;
|
||||||
margin: 1em;
|
margin: 1em;
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
|
|
|
||||||
11
src/App.tsx
11
src/App.tsx
|
|
@ -2,7 +2,7 @@ import "./App.css";
|
||||||
import { AdvancedBr, Singular88, SingularOomfie } from "./components/comps.tsx";
|
import { AdvancedBr, Singular88, SingularOomfie } from "./components/comps.tsx";
|
||||||
import { createSignal, onMount } from "solid-js";
|
import { createSignal, onMount } from "solid-js";
|
||||||
import Reviews from "./components/api.tsx";
|
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 { Bdpfp, Normalpfp } from "./components/pfp.tsx";
|
||||||
import { InfoCard } from "./components/middlecard.tsx";
|
import { InfoCard } from "./components/middlecard.tsx";
|
||||||
|
|
||||||
|
|
@ -61,16 +61,17 @@ function nyaboom() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [musicList, setMusicList] = createSignal<string[]>([]);
|
const [musicList, setMusicList] = createSignal<Song[]>([]);
|
||||||
const [isLoading, setIsLoading] = createSignal(true);
|
const [isLoading, setIsLoading] = createSignal(true);
|
||||||
const [oomfies, setoomfies] = createSignal(<>oomfies</>);
|
const [oomfies, setoomfies] = createSignal(<>oomfies</>);
|
||||||
const [isAnimating, setIsAnimating] = createSignal(false);
|
const [isAnimating, setIsAnimating] = createSignal(false);
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
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);
|
setMusicList(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching music data:", error);
|
console.error("Error fetching music data:", error);
|
||||||
|
|
@ -271,7 +272,7 @@ function App() {
|
||||||
{isLoading() ? (
|
{isLoading() ? (
|
||||||
<p>Loading...</p>
|
<p>Loading...</p>
|
||||||
) : (
|
) : (
|
||||||
musicList().map((link) => <MusicEntry spotifylink={link} />)
|
musicList().map((link) => <MusicEntry musicInfo={link} />)
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,18 @@
|
||||||
import { createSignal, onMount } from "solid-js";
|
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 <div style={{
|
return <div style={{
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
display: props.shouldpopup() ? "block" : "none"
|
display: props.shouldpopup() ? "block" : "none"
|
||||||
|
|
@ -9,39 +21,25 @@ export default function Music(props: { shouldpopup: () => boolean, children: any
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
export function MusicEntry({ spotifylink }: { spotifylink: string }) {
|
export function MusicEntry(props: {musicInfo:Song}) {
|
||||||
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);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return (
|
return (
|
||||||
<>{isLoading() ? (
|
<div onClick={() => {
|
||||||
<p>Loading...</p>
|
document.location.href = props.musicInfo.link
|
||||||
) : (
|
}} class="singlemusic">
|
||||||
<div onClick={() => {
|
<img style={{
|
||||||
document.location.href = musicInfo().pageUrl
|
"margin-right": "0.5em"
|
||||||
}} class="singlemusic">
|
}}
|
||||||
<img style={{
|
src={"https://proxy.spiro.exhq.dev/_/plain/" + props.musicInfo.thumbnailUrl}
|
||||||
"margin-right": "0.5em"
|
alt={"album cover of" + props.musicInfo.title}/>
|
||||||
}} src={"https://proxy.spiro.exhq.dev/_/plain/" + musicInfo().entitiesByUniqueId[`SPOTIFY_SONG::${spotifylink}`]?.thumbnailUrl} alt={"album cover of" + musicInfo().entitiesByUniqueId[`SPOTIFY_SONG::${spotifylink}`]?.title} />
|
<div class="innersinglemusic">
|
||||||
<div class="innersinglemusic">
|
<div class="musicartist"> {
|
||||||
<div class="musicartist" > {
|
shortenName(props.musicInfo.artist)
|
||||||
musicInfo().entitiesByUniqueId[`SPOTIFY_SONG::${spotifylink}`]?.artistName?.length > 43 ? musicInfo().entitiesByUniqueId[`SPOTIFY_SONG::${spotifylink}`]?.artistName.substring(0, 30) + "..." : musicInfo().entitiesByUniqueId[`SPOTIFY_SONG::${spotifylink}`]?.artistName
|
}</div>
|
||||||
}</div>
|
<div class="musictitle"> {
|
||||||
<div class="musictitle"> {
|
shortenName(props.musicInfo.title)
|
||||||
musicInfo().entitiesByUniqueId[`SPOTIFY_SONG::${spotifylink}`]?.title?.length > 43 ? musicInfo().entitiesByUniqueId[`SPOTIFY_SONG::${spotifylink}`]?.title.substring(0, 30) + "..." : musicInfo().entitiesByUniqueId[`SPOTIFY_SONG::${spotifylink}`]?.title
|
} </div>
|
||||||
} </div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)}</>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue