aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/spotifyControls/PlayerComponent.tsx
diff options
context:
space:
mode:
authorV <vendicated@riseup.net>2023-07-04 17:53:17 +0200
committerV <vendicated@riseup.net>2023-07-04 17:53:17 +0200
commit93482ac2a5f7a073f505ba130a3074b97e6da6ca (patch)
tree8aa68085fc5e0d8dc44ae9ade8e9abe8491c0d6a /src/plugins/spotifyControls/PlayerComponent.tsx
parent994c3b3c92ccb510facd726a3ceecdb987263f79 (diff)
downloadVencord-93482ac2a5f7a073f505ba130a3074b97e6da6ca.tar.gz
Vencord-93482ac2a5f7a073f505ba130a3074b97e6da6ca.tar.bz2
Vencord-93482ac2a5f7a073f505ba130a3074b97e6da6ca.zip
SpotifyControls: improve open in app capabilities & styles
Diffstat (limited to 'src/plugins/spotifyControls/PlayerComponent.tsx')
-rw-r--r--src/plugins/spotifyControls/PlayerComponent.tsx35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/plugins/spotifyControls/PlayerComponent.tsx b/src/plugins/spotifyControls/PlayerComponent.tsx
index c0ba0fe..43c499a 100644
--- a/src/plugins/spotifyControls/PlayerComponent.tsx
+++ b/src/plugins/spotifyControls/PlayerComponent.tsx
@@ -21,7 +21,6 @@ import "./spotifyStyles.css";
import ErrorBoundary from "@components/ErrorBoundary";
import { Flex } from "@components/Flex";
import { ImageIcon, LinkIcon, OpenExternalIcon } from "@components/Icons";
-import { Link } from "@components/Link";
import { debounce } from "@utils/debounce";
import { openImageModal } from "@utils/discord";
import { classes, copyWithToast } from "@utils/misc";
@@ -254,6 +253,16 @@ function AlbumContextMenu({ track }: { track: Track; }) {
);
}
+function makeLinkProps(name: string, condition: unknown, path: string) {
+ if (!condition) return {};
+
+ return {
+ role: "link",
+ onClick: () => SpotifyStore.openExternal(path),
+ onContextMenu: makeContextMenu(name, path)
+ } satisfies React.HTMLAttributes<HTMLElement>;
+}
+
function Info({ track }: { track: Track; }) {
const img = track?.album?.image;
@@ -289,12 +298,8 @@ function Info({ track }: { track: Track; }) {
variant="text-sm/semibold"
id={cl("song-title")}
className={cl("ellipoverflow")}
- role={track.id ? "link" : undefined}
title={track.name}
- onClick={track.id ? () => {
- SpotifyStore.openExternal(`/track/${track.id}`);
- } : void 0}
- onContextMenu={track.id ? makeContextMenu("Song", `/track/${track.id}`) : void 0}
+ {...makeLinkProps("Song", track.id, `/track/${track.id}`)}
>
{track.name}
</Forms.FormText>
@@ -303,16 +308,14 @@ function Info({ track }: { track: Track; }) {
by&nbsp;
{track.artists.map((a, i) => (
<React.Fragment key={a.name}>
- <Link
+ <span
className={cl("artist")}
- disabled={!a.id}
- href={`https://open.spotify.com/artist/${a.id}`}
style={{ fontSize: "inherit" }}
title={a.name}
- onContextMenu={makeContextMenu("Artist", `/artist/${a.id}`)}
+ {...makeLinkProps("Artist", a.id, `/artist/${a.id}`)}
>
{a.name}
- </Link>
+ </span>
{i !== track.artists.length - 1 && <span className={cl("comma")}>{", "}</span>}
</React.Fragment>
))}
@@ -321,17 +324,15 @@ function Info({ track }: { track: Track; }) {
{track.album.name && (
<Forms.FormText variant="text-sm/normal" className={cl("ellipoverflow")}>
on&nbsp;
- <Link id={cl("album-title")}
- href={`https://open.spotify.com/album/${track.album.id}`}
- target="_blank"
+ <span
+ id={cl("album-title")}
className={cl("album")}
- disabled={!track.album.id}
style={{ fontSize: "inherit" }}
title={track.album.name}
- onContextMenu={makeContextMenu("Album", `/album/${track.album.id}`)}
+ {...makeLinkProps("Album", track.album.id, `/album/${track.album.id}`)}
>
{track.album.name}
- </Link>
+ </span>
</Forms.FormText>
)}
</div>