From 058a148c7f68be9d60e8762e951e6fa31a11900d Mon Sep 17 00:00:00 2001 From: Chubby Granny Chaser Date: Sun, 30 Nov 2025 05:44:18 +0000 Subject: [PATCH] style: add button styling and refactor logo click handling in download group for improved accessibility and user experience --- .../src/pages/downloads/download-group.scss | 26 +++++ .../src/pages/downloads/download-group.tsx | 96 ++++--------------- 2 files changed, 46 insertions(+), 76 deletions(-) diff --git a/src/renderer/src/pages/downloads/download-group.scss b/src/renderer/src/pages/downloads/download-group.scss index 0d513bae..4fd6ec02 100644 --- a/src/renderer/src/pages/downloads/download-group.scss +++ b/src/renderer/src/pages/downloads/download-group.scss @@ -101,6 +101,32 @@ display: flex; 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 { max-width: 180px; max-height: 60px; diff --git a/src/renderer/src/pages/downloads/download-group.tsx b/src/renderer/src/pages/downloads/download-group.tsx index 4b783517..a202af36 100644 --- a/src/renderer/src/pages/downloads/download-group.tsx +++ b/src/renderer/src/pages/downloads/download-group.tsx @@ -210,7 +210,6 @@ interface HeroDownloadViewProps { dominantColor: string; lastPacket: ReturnType["lastPacket"]; speedHistory: number[]; - getStatusText: (game: LibraryGame) => string; formatSpeed: (speed: number) => string; calculateETA: () => string; pauseDownload: (shop: GameShop, objectId: string) => void; @@ -229,7 +228,6 @@ function HeroDownloadView({ dominantColor, lastPacket, speedHistory, - getStatusText, formatSpeed, calculateETA, pauseDownload, @@ -257,33 +255,21 @@ function HeroDownloadView({
{game.logoImageUrl ? ( - {game.title} { - if (e.key === "Enter" || e.key === " ") { - e.preventDefault(); - handleLogoClick(); - } - }} - role="button" - tabIndex={0} - /> - ) : ( -

{ - if (e.key === "Enter" || e.key === " ") { - e.preventDefault(); - handleLogoClick(); - } - }} - role="button" - tabIndex={0} + className="download-group__hero-logo-button" > - {game.title} -

+ {game.title} + + ) : ( + )}
@@ -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( async (shop: GameShop, objectId: string) => { await window.electron.extractGameDownload(shop, objectId); @@ -770,7 +709,13 @@ export function DownloadGroup({ progress: game.download?.progress || 0, isSeeding: isGameSeeding(game), })), - [library, lastPacket?.gameId] + [ + library, + lastPacket?.gameId, + lastPacket?.download.fileSize, + isGameDownloadingMap, + seedingStatus, + ] ); if (!library.length) return null; @@ -805,7 +750,6 @@ export function DownloadGroup({ dominantColor={dominantColor} lastPacket={lastPacket} speedHistory={speedHistoryRef.current[game.id] || []} - getStatusText={getStatusText} formatSpeed={formatSpeed} calculateETA={calculateETA} pauseDownload={pauseDownload}