Skip to content

[UI] Use cover art for the most recently played game #2750

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
Show file tree
Hide file tree
Changes from all commits
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
29 changes: 29 additions & 0 deletions src/frontend/screens/Library/components/GameCard/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
aspect-ratio: 173/275;
}

.gameCard.justPlayed {
aspect-ratio: 275/205;
}

.gameCard.gamepad {
aspect-ratio: 3/4;
}
Expand Down Expand Up @@ -62,6 +66,12 @@
display: block;
}

.gameCard.justPlayed .justPlayedImg {
aspect-ratio: 16 / 10;
object-fit: cover;
width: 100%;
}

.gameCard .gameLogo {
position: absolute;
top: 50%;
Expand Down Expand Up @@ -106,6 +116,12 @@
padding: var(--space-xs-fixed);
}

.gameCard.justPlayed > .icons {
justify-content: right;
grid-template-columns: 0.3fr 1fr 0.4fr 0.5fr;
grid-template-areas: 'update gap settings play';
}

.gameCard.gamepad > .icons {
display: none;
}
Expand Down Expand Up @@ -308,6 +324,19 @@
transition: all 300ms;
}

.playIcon > span {
font-family: var(--secondary-font-family);
border-radius: 5px;
color: #161616;
cursor: pointer;
padding: var(--space-xs-fixed);
background: var(--success);
color: var(--text-tertiary);
font-weight: 500;
font-size: 15px;
text-align: center;
}

.icons path,
.icons circle {
transition: 300ms;
Expand Down
26 changes: 19 additions & 7 deletions src/frontend/screens/Library/components/GameCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ interface Card {
buttonClick: () => void
hasUpdate: boolean
isRecent: boolean
justPlayed: boolean
gameInfo: GameInfo
forceCard?: boolean
}
Expand All @@ -55,6 +56,7 @@ const GameCard = ({
buttonClick,
forceCard,
isRecent = false,
justPlayed = false,
gameInfo: gameInfoFromProps
}: Card) => {
const [visible, setVisible] = useState(false)
Expand Down Expand Up @@ -96,6 +98,7 @@ const GameCard = ({

const {
title,
art_cover,
art_square: cover,
art_logo: logo = undefined,
app_name: appName,
Expand Down Expand Up @@ -212,7 +215,7 @@ const GameCard = ({
title={`${t('label.playing.start')} (${title})`}
disabled={disabled}
>
<PlayIcon />
{justPlayed ? <span>PLAY</span> : <PlayIcon />}
</SvgButton>
)
} else {
Expand Down Expand Up @@ -338,6 +341,7 @@ const GameCard = ({
const hiddenClass = isHiddenGame ? 'hidden' : ''
const notAvailableClass = notAvailable ? 'notAvailable' : ''
const gamepadClass = activeController ? 'gamepad' : ''
const justPlayedClass = justPlayed ? 'justPlayed' : ''
const imgClasses = `gameImg ${isInstalled ? 'installed' : ''} ${
allTilesInColor ? 'allTilesInColor' : ''
}`
Expand All @@ -347,7 +351,7 @@ const GameCard = ({

const wrapperClasses = `${
grid ? 'gameCard' : 'gameListItem'
} ${instClass} ${hiddenClass} ${notAvailableClass} ${gamepadClass}`
} ${instClass} ${hiddenClass} ${notAvailableClass} ${gamepadClass} ${justPlayedClass}`

const showUpdateButton =
hasUpdate && !isUpdating && !isQueued && !notAvailable
Expand Down Expand Up @@ -382,11 +386,19 @@ const GameCard = ({
}
>
<StoreLogos runner={runner} />
<CachedImage
src={getImageFormatting(cover, runner)}
className={imgClasses}
alt="cover"
/>
{justPlayed ? (
<CachedImage
src={art_cover}
className="justPlayedImg"
alt={title}
/>
) : (
<CachedImage
src={getImageFormatting(cover, runner)}
className={imgClasses}
alt="cover"
/>
)}
{logo && (
<CachedImage
alt="logo"
Expand Down
5 changes: 3 additions & 2 deletions src/frontend/screens/Library/components/GamesList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ const GamesList = ({
</div>
)}
{!!library.length &&
library.map((gameInfo) => {
library.map((gameInfo, index) => {
const { app_name, is_installed, runner } = gameInfo

const isJustPlayed = isRecent && index === 0
let is_dlc = false
if (gameInfo.runner !== 'sideload') {
is_dlc = gameInfo.install.is_dlc ?? false
Expand All @@ -117,6 +117,7 @@ const GamesList = ({
forceCard={layout === 'grid'}
isRecent={isRecent}
gameInfo={gameInfo}
justPlayed={isJustPlayed}
/>
)
})}
Expand Down
4 changes: 4 additions & 0 deletions src/frontend/screens/Library/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
padding: 0 var(--space-md-fixed) var(--space-md-fixed);
}

.gameList.firstLane > :first-child {
grid-column: span 2;
}

.gameListLayout {
display: flex;
flex-direction: column;
Expand Down