Merge pull request #1909 from hydralauncher/fix/library-game-covers

fix: library cards not using placeholder and icon as a game cover
This commit is contained in:
Chubby Granny Chaser
2026-01-03 16:19:33 +00:00
committed by GitHub
2 changed files with 43 additions and 16 deletions

View File

@@ -221,6 +221,26 @@
left: 0; left: 0;
z-index: 0; z-index: 0;
} }
&__cover-placeholder {
position: relative;
width: 100%;
height: 100%;
min-width: 100%;
min-height: 100%;
background: linear-gradient(
90deg,
rgba(255, 255, 255, 0.08) 0%,
rgba(255, 255, 255, 0.04) 50%,
rgba(255, 255, 255, 0.08) 100%
);
border-radius: 4px;
color: rgba(255, 255, 255, 0.3);
display: flex;
align-items: center;
justify-content: center;
z-index: 0;
}
} }
@keyframes pulse { @keyframes pulse {

View File

@@ -1,7 +1,12 @@
import { LibraryGame } from "@types"; import { LibraryGame } from "@types";
import { useGameCard } from "@renderer/hooks"; import { useGameCard } from "@renderer/hooks";
import { memo } from "react"; import { memo, useState } from "react";
import { ClockIcon, AlertFillIcon, TrophyIcon } from "@primer/octicons-react"; import {
ClockIcon,
AlertFillIcon,
TrophyIcon,
ImageIcon,
} from "@primer/octicons-react";
import "./library-game-card.scss"; import "./library-game-card.scss";
interface LibraryGameCardProps { interface LibraryGameCardProps {
@@ -25,14 +30,9 @@ export const LibraryGameCard = memo(function LibraryGameCard({
const { formatPlayTime, handleCardClick, handleContextMenuClick } = const { formatPlayTime, handleCardClick, handleContextMenuClick } =
useGameCard(game, onContextMenu); useGameCard(game, onContextMenu);
const coverImage = ( const coverImage = game.coverImageUrl?.replaceAll("\\", "/") ?? "";
game.customIconUrl ??
game.coverImageUrl ?? const [imageError, setImageError] = useState(false);
game.libraryImageUrl ??
game.libraryHeroImageUrl ??
game.iconUrl ??
""
).replaceAll("\\", "/");
return ( return (
<button <button
@@ -98,12 +98,19 @@ export const LibraryGameCard = memo(function LibraryGameCard({
)} )}
</div> </div>
<img {imageError || !coverImage ? (
src={coverImage ?? undefined} <div className="library-game-card__cover-placeholder">
alt={game.title} <ImageIcon size={48} />
className="library-game-card__game-image" </div>
loading="lazy" ) : (
/> <img
src={coverImage}
alt={game.title}
className="library-game-card__game-image"
loading="lazy"
onError={() => setImageError(true)}
/>
)}
</button> </button>
); );
}); });