style: add button styling and refactor logo click handling in download group for improved accessibility and user experience

This commit is contained in:
Chubby Granny Chaser
2025-11-30 05:44:18 +00:00
parent 16e3d52508
commit 058a148c7f
2 changed files with 46 additions and 76 deletions

View File

@@ -101,6 +101,32 @@
display: flex; display: flex;
align-items: center; align-items: center;
&-button {
background: none;
border: none;
padding: 0;
cursor: pointer;
display: flex;
align-items: center;
transition: opacity 0.2s ease;
&:hover {
opacity: 0.8;
}
&:focus {
outline: 2px solid rgba(255, 255, 255, 0.5);
outline-offset: 4px;
border-radius: 4px;
}
&:focus-visible {
outline: 2px solid rgba(255, 255, 255, 0.5);
outline-offset: 4px;
border-radius: 4px;
}
}
img { img {
max-width: 180px; max-width: 180px;
max-height: 60px; max-height: 60px;

View File

@@ -210,7 +210,6 @@ interface HeroDownloadViewProps {
dominantColor: string; dominantColor: string;
lastPacket: ReturnType<typeof useDownload>["lastPacket"]; lastPacket: ReturnType<typeof useDownload>["lastPacket"];
speedHistory: number[]; speedHistory: number[];
getStatusText: (game: LibraryGame) => string;
formatSpeed: (speed: number) => string; formatSpeed: (speed: number) => string;
calculateETA: () => string; calculateETA: () => string;
pauseDownload: (shop: GameShop, objectId: string) => void; pauseDownload: (shop: GameShop, objectId: string) => void;
@@ -229,7 +228,6 @@ function HeroDownloadView({
dominantColor, dominantColor,
lastPacket, lastPacket,
speedHistory, speedHistory,
getStatusText,
formatSpeed, formatSpeed,
calculateETA, calculateETA,
pauseDownload, pauseDownload,
@@ -257,33 +255,21 @@ function HeroDownloadView({
<div className="download-group__hero-action-row"> <div className="download-group__hero-action-row">
<div className="download-group__hero-logo"> <div className="download-group__hero-logo">
{game.logoImageUrl ? ( {game.logoImageUrl ? (
<img <button
src={game.logoImageUrl} type="button"
alt={game.title}
onClick={handleLogoClick} onClick={handleLogoClick}
onKeyDown={(e) => { className="download-group__hero-logo-button"
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
handleLogoClick();
}
}}
role="button"
tabIndex={0}
/>
) : (
<h1
onClick={handleLogoClick}
onKeyDown={(e) => {
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
handleLogoClick();
}
}}
role="button"
tabIndex={0}
> >
{game.title} <img src={game.logoImageUrl} alt={game.title} />
</h1> </button>
) : (
<button
type="button"
onClick={handleLogoClick}
className="download-group__hero-logo-button"
>
<h1>{game.title}</h1>
</button>
)} )}
</div> </div>
</div> </div>
@@ -605,53 +591,6 @@ export function DownloadGroup({
); );
}; };
const getCompletedStatusText = (game: LibraryGame) => {
const isTorrent = game.download?.downloader === Downloader.Torrent;
if (isTorrent) {
return isGameSeeding(game)
? `${t("completed")} (${t("seeding")})`
: `${t("completed")} (${t("paused")})`;
}
return t("completed");
};
const getStatusText = (game: LibraryGame) => {
const isGameDownloading = isGameDownloadingMap[game.id];
const status = game.download?.status;
if (game.download?.extracting) {
return t("extracting");
}
if (isGameDeleting(game.id)) {
return t("deleting");
}
if (game.download?.progress === 1) {
return getCompletedStatusText(game);
}
if (isGameDownloading && lastPacket) {
if (lastPacket.isDownloadingMetadata) {
return t("downloading_metadata");
}
if (lastPacket.isCheckingFiles) {
return t("checking_files");
}
return t("download_in_progress");
}
switch (status) {
case "paused":
case "error":
return t("paused");
case "waiting":
return t("calculating_eta");
default:
return t("paused");
}
};
const extractGameDownload = useCallback( const extractGameDownload = useCallback(
async (shop: GameShop, objectId: string) => { async (shop: GameShop, objectId: string) => {
await window.electron.extractGameDownload(shop, objectId); await window.electron.extractGameDownload(shop, objectId);
@@ -770,7 +709,13 @@ export function DownloadGroup({
progress: game.download?.progress || 0, progress: game.download?.progress || 0,
isSeeding: isGameSeeding(game), isSeeding: isGameSeeding(game),
})), })),
[library, lastPacket?.gameId] [
library,
lastPacket?.gameId,
lastPacket?.download.fileSize,
isGameDownloadingMap,
seedingStatus,
]
); );
if (!library.length) return null; if (!library.length) return null;
@@ -805,7 +750,6 @@ export function DownloadGroup({
dominantColor={dominantColor} dominantColor={dominantColor}
lastPacket={lastPacket} lastPacket={lastPacket}
speedHistory={speedHistoryRef.current[game.id] || []} speedHistory={speedHistoryRef.current[game.id] || []}
getStatusText={getStatusText}
formatSpeed={formatSpeed} formatSpeed={formatSpeed}
calculateETA={calculateETA} calculateETA={calculateETA}
pauseDownload={pauseDownload} pauseDownload={pauseDownload}