mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-02-01 19:15:07 +01:00
style: add button styling and refactor logo click handling in download group for improved accessibility and user experience
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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}
|
||||||
|
|||||||
Reference in New Issue
Block a user