From 15f12073cf94dd9111bd67742705f0a9721f9424 Mon Sep 17 00:00:00 2001 From: Nico Date: Thu, 10 Nov 2022 14:02:34 +0100 Subject: spotifyControls: make title/artists of local tracks unclickable (#201) Co-authored-by: Vendicated --- src/components/Link.tsx | 7 ++-- src/plugins/spotifyControls/PlayerComponent.tsx | 46 ++++++++++++++----------- src/plugins/spotifyControls/styles.css | 2 +- 3 files changed, 30 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/components/Link.tsx b/src/components/Link.tsx index 0965b64..2400ea6 100644 --- a/src/components/Link.tsx +++ b/src/components/Link.tsx @@ -18,19 +18,18 @@ import { React } from "../webpack/common"; -interface Props { - href: string; +interface Props extends React.DetailedHTMLProps, HTMLAnchorElement> { disabled?: boolean; - style?: React.CSSProperties; } export function Link(props: React.PropsWithChildren) { if (props.disabled) { props.style ??= {}; props.style.pointerEvents = "none"; + props["aria-disabled"] = true; } return ( - + {props.children} ); diff --git a/src/plugins/spotifyControls/PlayerComponent.tsx b/src/plugins/spotifyControls/PlayerComponent.tsx index b5cc26a..16fa250 100644 --- a/src/plugins/spotifyControls/PlayerComponent.tsx +++ b/src/plugins/spotifyControls/PlayerComponent.tsx @@ -18,6 +18,7 @@ import ErrorBoundary from "../../components/ErrorBoundary"; import { Flex } from "../../components/Flex"; +import { Link } from "../../components/Link"; import { debounce } from "../../utils/debounce"; import { classes, LazyComponent, lazyWebpack } from "../../utils/misc"; import { ContextMenu, FluxDispatcher, Forms, Menu, React } from "../../webpack/common"; @@ -262,31 +263,36 @@ 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={() => SpotifyStore.openExternal(`/track/${track.id}`)} + onClick={track.id ? () => { + SpotifyStore.openExternal(`/track/${track.id}`); + } : void 0} > {track.name} - - by  - {track.artists.map((a, i) => ( - - - {a.name} - - {i !== track.artists.length - 1 && {", "}} - - ))} - + {track.artists.some(a => a.name) && ( + + by  + {track.artists.map((a, i) => ( + + + {a.name} + + {i !== track.artists.length - 1 && {", "}} + + ))} + + )} {track.album.name && ( - on  + on  SpotifyStore.track, null, - (prev, next) => prev?.id === next?.id + (prev, next) => prev?.id ? (prev.id === next?.id) : prev?.name === next?.name ); const device = useStateFromStores( diff --git a/src/plugins/spotifyControls/styles.css b/src/plugins/spotifyControls/styles.css index a612219..9c7b1c0 100644 --- a/src/plugins/spotifyControls/styles.css +++ b/src/plugins/spotifyControls/styles.css @@ -121,7 +121,7 @@ .vc-spotify-artist:hover, #vc-spotify-album-title:hover, -#vc-spotify-song-title:hover { +#vc-spotify-song-title[role="link"]:hover { text-decoration: underline; cursor: pointer; } -- cgit