fix(a11y): kernel-level anti-cheat is shown by more than colour
Kernel-level anti-cheat differed from the rest only by its badge colour, red against amber, with the product name as the only text. That told a colour-blind reader and a screen reader nothing. games/AntiCheatBadge.svelte adds a shield icon and the words "Kernel-level". They are visible on a game's page, and read only by screen readers where a long product name already fills the badge (/random here; the table and the cards in the next commit). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a858c6ed20
commit
0f68351fb8
3 files changed
+41
-8
No files matched your search
@@ -0,0 +1,31 @@
|
||||
<script lang="ts">
|
||||
import ShieldAlert from "@lucide/svelte/icons/shield-alert";
|
||||
import Badge from "../ui/Badge.svelte";
|
||||
import { i18n } from "../i18n.svelte";
|
||||
|
||||
/**
|
||||
* An anti-cheat product, with kernel level shown by more than colour.
|
||||
*
|
||||
* Kernel-level anti-cheat used to differ from the rest only by the badge's
|
||||
* colour (red against amber), which says nothing to a colour-blind reader or
|
||||
* a screen reader. The shield icon is the visible cue, and the words are
|
||||
* always there: visible where there is room (`labelled`, the game page),
|
||||
* read by screen readers only in the table, the cards and /random, where a
|
||||
* long product name already fills the badge.
|
||||
*
|
||||
* `kernel` is `is_kernel_ac`, which is tri-state: null means nobody has
|
||||
* checked, and that is not shown as kernel-level.
|
||||
*/
|
||||
let {
|
||||
name,
|
||||
kernel = false,
|
||||
labelled = false,
|
||||
class: className,
|
||||
}: { name: string; kernel?: boolean | null; labelled?: boolean; class?: string } = $props();
|
||||
|
||||
const t = i18n.t;
|
||||
</script>
|
||||
|
||||
<Badge variant={kernel ? "destructive" : "warning"} class={className}>
|
||||
{#if kernel}<ShieldAlert class="mr-1 inline size-3 shrink-0 align-[-0.125em]" />{/if}{name}{#if kernel && labelled}<span> · {t("charts.acLevel.kernel")}</span>{:else if kernel}<span class="sr-only"> ({t("charts.acLevel.kernel")})</span>{/if}
|
||||
</Badge>
|
||||
@@ -23,6 +23,7 @@
|
||||
import { SITE_ORIGIN } from "#lib/site.js";
|
||||
import QueryState from "#lib/common/QueryState.svelte";
|
||||
import Badge from "#lib/ui/Badge.svelte";
|
||||
import AntiCheatBadge from "#lib/games/AntiCheatBadge.svelte";
|
||||
import Button from "#lib/ui/Button.svelte";
|
||||
import Seo from "#lib/common/Seo.svelte";
|
||||
import type { PageData } from "./$types";
|
||||
@@ -214,8 +215,8 @@
|
||||
|
||||
<div class="flex flex-wrap items-start gap-3">
|
||||
<h1 class="min-w-0 flex-1 text-2xl font-semibold tracking-tight wrap-break-word sm:text-3xl">
|
||||
{#if view.is_dead}<span title={t("games.deadTitle")}>💀</span>{/if}
|
||||
{view.name}
|
||||
{#if view.is_dead}<span aria-hidden="true" title={t("games.deadTitle")}>💀</span>{/if}
|
||||
{view.name}{#if view.is_dead}<span class="sr-only">, {t("games.deadTitle")}</span>{/if}
|
||||
</h1>
|
||||
{#if pct !== null}
|
||||
<!-- The score alone ("32%") said nothing about what it measures;
|
||||
@@ -237,7 +238,7 @@
|
||||
</Badge>
|
||||
{/if}
|
||||
{#if view.anti_cheat && view.anti_cheat !== "-"}
|
||||
<Badge variant={view.is_kernel_ac ? "destructive" : "warning"}>{view.anti_cheat}</Badge>
|
||||
<AntiCheatBadge name={view.anti_cheat} kernel={view.is_kernel_ac} labelled />
|
||||
{/if}
|
||||
{#if view.has_paid_dlc}<Badge variant="warning">{t("detail.labelHasPaidDlc")}</Badge>{/if}
|
||||
</div>
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
import PageHeader from "#lib/common/PageHeader.svelte";
|
||||
import Seo from "#lib/common/Seo.svelte";
|
||||
import Badge from "#lib/ui/Badge.svelte";
|
||||
import AntiCheatBadge from "#lib/games/AntiCheatBadge.svelte";
|
||||
import Button from "#lib/ui/Button.svelte";
|
||||
|
||||
const t = i18n.t;
|
||||
@@ -169,8 +170,10 @@
|
||||
<div class="aspect-[460/215] w-full bg-muted"></div>
|
||||
{/if}
|
||||
<h2 class="flex items-center gap-1.5 px-4 pt-3 text-base font-semibold group-hover:text-primary">
|
||||
{#if r.is_dead}<span title={t("games.deadTitle")}>💀</span>{/if}
|
||||
<span class="min-w-0 truncate">{r.name || "—"}</span>
|
||||
{#if r.is_dead}<span aria-hidden="true" title={t("games.deadTitle")}>💀</span>{/if}
|
||||
<span class="min-w-0 truncate">
|
||||
{r.name || "—"}{#if r.is_dead}<span class="sr-only">, {t("games.deadTitle")}</span>{/if}
|
||||
</span>
|
||||
</h2>
|
||||
</a>
|
||||
|
||||
@@ -182,9 +185,7 @@
|
||||
{/if}
|
||||
{#if r.genre}<Badge variant="outline">{r.genre}</Badge>{/if}
|
||||
{#if r.anti_cheat && r.anti_cheat !== "-"}
|
||||
<Badge variant={r.is_kernel_ac ? "destructive" : "warning"} class="block max-w-full truncate">
|
||||
{r.anti_cheat}
|
||||
</Badge>
|
||||
<AntiCheatBadge name={r.anti_cheat} kernel={r.is_kernel_ac} class="block max-w-full truncate" />
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
|
||||
Reference in new issue
Block a user