mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: add aria label to achievement summary
This commit is contained in:
parent
c5d4db0a1e
commit
e9f68977fe
2 changed files with 21 additions and 2 deletions
|
@ -375,4 +375,4 @@
|
||||||
"show_and_compare_achievements": "Show and compare your achievements to other users",
|
"show_and_compare_achievements": "Show and compare your achievements to other users",
|
||||||
"animated_profile_banner": "Animated profile banner"
|
"animated_profile_banner": "Animated profile banner"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import { average } from "color.js";
|
||||||
import Color from "color";
|
import Color from "color";
|
||||||
import { Link } from "@renderer/components";
|
import { Link } from "@renderer/components";
|
||||||
import { ComparedAchievementList } from "./compared-achievement-list";
|
import { ComparedAchievementList } from "./compared-achievement-list";
|
||||||
|
import { TFunction } from "i18next/typescript/t";
|
||||||
|
|
||||||
interface UserInfo {
|
interface UserInfo {
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -39,10 +40,26 @@ interface AchievementSummaryProps {
|
||||||
isComparison?: boolean;
|
isComparison?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ariaLabelSummary = (
|
||||||
|
t: TFunction,
|
||||||
|
gameTitle: string,
|
||||||
|
user: UserInfo
|
||||||
|
): string => {
|
||||||
|
return t("aria_achievement_summary", {
|
||||||
|
userDisplayName: user.displayName,
|
||||||
|
gameTitle: gameTitle,
|
||||||
|
userAchievementCount: user.unlockedAchievementCount,
|
||||||
|
userTotalAchievementCount: user.totalAchievementCount,
|
||||||
|
percentage: formatDownloadProgress(
|
||||||
|
user.unlockedAchievementCount / user.totalAchievementCount
|
||||||
|
),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
function AchievementSummary({ user, isComparison }: AchievementSummaryProps) {
|
function AchievementSummary({ user, isComparison }: AchievementSummaryProps) {
|
||||||
const { t } = useTranslation("achievement");
|
const { t } = useTranslation("achievement");
|
||||||
const { userDetails, hasActiveSubscription } = useUserDetails();
|
const { userDetails, hasActiveSubscription } = useUserDetails();
|
||||||
const { handleClickOpenCheckout } = useContext(gameDetailsContext);
|
const { handleClickOpenCheckout, gameTitle } = useContext(gameDetailsContext);
|
||||||
|
|
||||||
const getProfileImage = (
|
const getProfileImage = (
|
||||||
user: Pick<UserInfo, "profileImageUrl" | "displayName">
|
user: Pick<UserInfo, "profileImageUrl" | "displayName">
|
||||||
|
@ -124,6 +141,8 @@ function AchievementSummary({ user, isComparison }: AchievementSummaryProps) {
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
padding: `${SPACING_UNIT}px`,
|
padding: `${SPACING_UNIT}px`,
|
||||||
}}
|
}}
|
||||||
|
role="region"
|
||||||
|
aria-label={ariaLabelSummary(t, gameTitle, user)}
|
||||||
>
|
>
|
||||||
{getProfileImage(user)}
|
{getProfileImage(user)}
|
||||||
<div
|
<div
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue