This commit is contained in:
Shisuys 2025-02-28 03:07:56 +00:00 committed by GitHub
commit 08a2e8caf0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 4 deletions

View file

@ -336,6 +336,8 @@
"quit": "Fechar" "quit": "Fechar"
}, },
"game_card": { "game_card": {
"available_one": "Disponível",
"available_other": "Disponíveis",
"no_downloads": "Sem downloads disponíveis" "no_downloads": "Sem downloads disponíveis"
}, },
"binary_not_found_modal": { "binary_not_found_modal": {

View file

@ -7,7 +7,7 @@ import "./game-card.scss";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { Badge } from "../badge/badge"; import { Badge } from "../badge/badge";
import { useCallback, useState } from "react"; import { useCallback, useState, useMemo } from "react";
import { useFormat, useRepacks } from "@renderer/hooks"; import { useFormat, useRepacks } from "@renderer/hooks";
import { steamUrlBuilder } from "@shared"; import { steamUrlBuilder } from "@shared";
@ -45,6 +45,15 @@ export function GameCard({ game, ...props }: GameCardProps) {
const { numberFormatter } = useFormat(); const { numberFormatter } = useFormat();
const firstThreeRepackers = useMemo(
() => uniqueRepackers.slice(0, 3),
[uniqueRepackers]
);
const remainingCount = useMemo(
() => uniqueRepackers.length - 3,
[uniqueRepackers]
);
return ( return (
<button <button
{...props} {...props}
@ -68,15 +77,24 @@ export function GameCard({ game, ...props }: GameCardProps) {
{uniqueRepackers.length > 0 ? ( {uniqueRepackers.length > 0 ? (
<ul className="game-card__download-options"> <ul className="game-card__download-options">
{uniqueRepackers.map((repacker) => ( {firstThreeRepackers.map((repacker) => (
<li key={repacker}> <li key={repacker}>
<Badge>{repacker}</Badge> <Badge>{repacker}</Badge>
</li> </li>
))} ))}
{remainingCount > 0 && (
<li>
<Badge>
+{remainingCount}{" "}
{t("game_card:available", { count: remainingCount })}
</Badge>
</li>
)}
</ul> </ul>
) : ( ) : (
<p className="game-card__no-download-label">{t("no_downloads")}</p> <p className="game-card__no-download-label">{t("no_downloads")}</p>
)} )}
<div className="game-card__specifics"> <div className="game-card__specifics">
<div className="game-card__specifics-item"> <div className="game-card__specifics-item">
<DownloadIcon /> <DownloadIcon />
@ -84,11 +102,10 @@ export function GameCard({ game, ...props }: GameCardProps) {
{stats ? numberFormatter.format(stats.downloadCount) : "…"} {stats ? numberFormatter.format(stats.downloadCount) : "…"}
</span> </span>
</div> </div>
<div className="game-card__specifics-item"> <div className="game-card__specifics-item">
<PeopleIcon /> <PeopleIcon />
<span> <span>
{stats ? numberFormatter.format(stats?.playerCount) : "…"} {stats ? numberFormatter.format(stats.playerCount) : "…"}
</span> </span>
</div> </div>
</div> </div>