Skip to content

Fix Issue #2466 GamePage image is missing logo when available #3245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/frontend/screens/Game/GamePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export default React.memo(function GamePage(): JSX.Element | null {
art_square,
art_cover,
art_background,
art_logo: logo = undefined,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can just use art_logo everywhere? it makes it easier to understand that it's the same thing that comes from the gameInfo and we already use art_... for the other images, makes it more consistent

Copy link
Collaborator

@arielj arielj Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, I think there's no need to do the = undefined since it will be undefined if it is undefined anyway

I see we have this in GameCard, but in that component we do rename other properties like cover or appName and I think we can ignore the = undefined there too (not something to change in this PR though)

install: { platform: installPlatform },
is_installed
} = gameInfo
Expand Down Expand Up @@ -325,7 +326,11 @@ export default React.memo(function GamePage(): JSX.Element | null {
{/* OLD DESIGN */}
{!experimentalFeatures.enableNewDesign && (
<>
<GamePicture art_square={art_square} store={runner} />
<GamePicture
art_square={art_square}
logo={logo}
store={runner}
/>
<NavLink
className="backButton"
to={backRoute}
Expand Down Expand Up @@ -394,7 +399,11 @@ export default React.memo(function GamePage(): JSX.Element | null {
<DotsMenu gameInfo={gameInfo} handleUpdate={handleUpdate} />
{!isBrowserGame && <SettingsButton gameInfo={gameInfo} />}
<div className="mainInfo">
<GamePicture art_square={art_cover} store={runner} />
<GamePicture
art_square={art_cover}
logo={logo}
store={runner}
/>
<div className="store-icon">
<StoreLogos runner={runner} />
</div>
Expand Down
32 changes: 24 additions & 8 deletions src/frontend/screens/Game/GamePicture/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ import fallbackImage from 'frontend/assets/heroic_card.jpg'

interface Props extends React.ImgHTMLAttributes<HTMLImageElement> {
art_square: string
logo?: string | undefined
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need the | undefined? I think because it's optional with the ? it already includes undefined as a possibility

store: string
}

function GamePicture({ art_square, store, className, ...props }: Props) {
function GamePicture({
art_square,
logo = undefined,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here as the other places, I'd just call this art_logo and without the default undefined, makes naming more consistent with the other places and it's undefined if not defined already

store,
className,
...props
}: Props) {
function getImageFormatting() {
if (art_square === 'fallback' || !art_square)
return { src: fallbackImage, fallback: fallbackImage }
Expand All @@ -27,13 +34,22 @@ function GamePicture({ art_square, store, className, ...props }: Props) {

return (
<div className="gamePicture">
<CachedImage
alt="cover-art"
className={`gameImg ${className}`}
src={src}
fallback={fallback}
{...props}
/>
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these { ... } needed?

<CachedImage
alt="cover-art"
className={`gameImg ${className}`}
src={src}
fallback={fallback}
{...props}
/>
}
{logo && (
<CachedImage
alt="logo"
src={`${logo}?h=400&resize=1&w=300`}
className={`gameLogo`}
/>
)}
</div>
)
}
Expand Down