Merge pull request #244 from poli0981/fix/a11y-barriers

fix(a11y): games table semantics, first-run dialogs, kernel cue, contrast, zoom
This commit is contained in:
poli0981 authored and GitHub committed 2026-11-09 09:10:43 +07:00
commit 4926c7ea00
23 files changed
+729 -202

No files matched your search

+59 -51
View File
@@ -35,7 +35,10 @@ What matters most, in this order:
## What works today
Checked against the code on 2026-11-09 (website and apps 2.5.0).
Checked against the code on 2026-11-09. The website has everything below. The
desktop and Android apps 2.5.0 were built before the games table, first-run
screen, colour, zoom and focus fixes of that day, and get them with their next
release.
- **Language.** The page declares its language, and changes it when you
switch between English and Vietnamese.
@@ -43,15 +46,33 @@ Checked against the code on 2026-11-09 (website and apps 2.5.0).
The header and both navigation menus are labelled, and the menus mark the
page you are on. Each page has one main heading and its own title, and
moving to another page announces the new title.
- **Keyboard.** Links and controls show a focus ring (one exception, below).
- **Keyboard.** Links and controls show a focus ring.
<kbd>Ctrl</kbd>/<kbd>⌘</kbd>+<kbd>K</kbd> opens a command palette that
works like a search box with a list: arrow keys, <kbd>Enter</kbd>,
<kbd>Esc</kbd>. The menu drawer on small screens, the palette and the
desktop update dialog keep focus inside while they are open, close with
<kbd>Esc</kbd>, and put focus back where it was.
- **The games table.** A screen reader hears a table: column headers
(including names for the image, data-issue and Steam columns), the total
number of rows and columns, and the position of each row, even though only
the rows on screen exist. Each row is one stop for <kbd>Tab</kbd>, the
game's name, and the whole row lights up when it has focus. Clicking
anywhere on a row still opens the game. On a phone the cards are a list
that says how many games it holds and where you are in it.
- **The first-run screens.** The terms screen and the human check are
dialogs. Focus moves into them, and the page behind is out of reach for the
keyboard and for screen readers until you are through. The command palette
shortcut does nothing while they are open.
- **Names.** Buttons that only show an icon have a text name. Switches (the
language and theme buttons, the scrollbar options, the choices on *Random
games*, the anti-cheat families) say whether they are on.
- **Colour and contrast.** In both themes, text is at least 4.5:1 against its
background, badges and the current menu item included, and the edges of
text boxes and drop-downs are at least 3:1. Kernel-level anti-cheat carries
a shield icon as well as its red, and the words "Kernel-level". They are
spelled out on a game's page and read out by screen readers in the table,
the cards and *Random games*. A test computes these ratios from the theme's
colours, so a later colour change cannot quietly undo them.
- **Charts.** Each chart is announced as an image named by its title. Some
also give the numbers as text: *Top online* and *Top offline* list 100 games
under their charts, *Genres* lists the top 24, *Tags* writes out 40 of its
@@ -60,10 +81,12 @@ Checked against the code on 2026-11-09 (website and apps 2.5.0).
- **Images, sound and motion.** Game art is decorative (`alt=""`); the game's
name is always written next to it. Nothing plays sound or video. With your
system's *reduce motion* setting on, page animations and transitions are cut
short and scrolling jumps instead of gliding.
- **Zoom and small screens.** The website never blocks pinch-zoom. Below
tablet width the games table turns into cards, and a test checks that every
grid falls back to one column on a phone.
short, and scrolling jumps instead of gliding, "back to top" included.
- **Zoom and small screens.** The website never blocks pinch-zoom, and the
games list keeps a usable height at 400% zoom. The desktop app zooms with
<kbd>Ctrl</kbd>/<kbd>⌘</kbd> and <kbd>+</kbd> / <kbd>−</kbd> (from its next
release). Below tablet width the games table turns into cards, and a test
checks that every grid falls back to one column on a phone.
- **Settings.** Theme (dark by default, light, or follow the system), English
or Vietnamese, and hidden scrollbars. Hidden scrollbars still scroll from
the keyboard.
@@ -77,43 +100,25 @@ Checked against the code on 2026-11-09 (website and apps 2.5.0).
Known, and not fixed yet. Where there is another way to get the same thing, it
says so.
- **The games table is not a table to a screen reader.** Its rows are links
dressed up as table rows with no table around them, and three of its columns
have no header text. Each row takes two <kbd>Tab</kbd> presses, because the
Steam icon inside it is a second stop. Only the rows on screen exist in the
page, so a screen reader's browse mode and the browser's find-in-page see
only those.
*Instead:* narrow the list with search and the filters, open a game's own
page, or export to CSV/JSON. The [Markdown leaderboards](games/) are
ordinary tables.
- **The first-run screens.** Before the site opens you get the terms screen,
then (website only) a human check. Neither moves keyboard focus into itself
or keeps it there, so <kbd>Tab</kbd> walks through the hidden page behind
first. The terms screen is also not announced as a dialog, and each screen
adds a second main heading while it is open. The human check is Cloudflare
Turnstile, in a frame this project does not control. If it says your
browser is unsupported, there is no retry button.
*Instead:* the desktop and Android apps never show the human check, and
everything in the catalogue is readable on GitHub.
- **Charts.** Values, tooltips and legends are drawn on a canvas and need a
pointer. Several charts have no text version: DRM, languages, platforms,
players, reviews, release years, delisted games, most of *Stats*, and the
genre chart on the dashboard. Several tell categories apart by colour alone.
Chart animations ignore *reduce motion*.
*Instead:* the CSV/JSON export, or the raw data.
- **Colour.**
- Kernel-level anti-cheat is shown only by a red badge instead of an amber
one: in the games table, the cards, a game's page and *Random games*.
*Instead:* the [anti-cheat list](https://free-steam-games.win/charts/anti-cheat/list)
says it in words.
- In the light theme, links, primary buttons, warnings and some badges are
below the 4.5:1 contrast WCAG asks of text.
*Instead:* the dark theme, which is the default.
- The borders of text boxes and drop-downs are below 3:1 in both themes.
- Contrast themes (forced colours) get no special support.
- **Hover-only hints.** The 💀 on a dead game and the warning icon in a table
row explain themselves only in a mouse-hover tooltip. A screen reader just
reads "skull".
- **The games table is virtualised.** Only the rows on screen exist in the
page. A screen reader is told the full count, but the browser's
find-in-page only sees those rows.
*Instead:* narrow the list with search and the filters, or export to
CSV/JSON.
- **The human check is Cloudflare Turnstile,** in a frame this project does
not control. If it says your browser is unsupported, there is no retry
button.
*Instead:* the desktop and Android apps never show it, and everything in
the catalogue is readable on GitHub.
- **Hover-only hints.** To sighted readers, the 💀 on a dead game and the
warning icon in a table row explain themselves only in a mouse-hover
tooltip. Screen readers get the words.
*Instead:* **Hide dead** on the Games page takes dead games out of the
list.
- **Changes that are not announced:** the number of results after you filter,
@@ -124,18 +129,16 @@ says so.
exist only in English. Game names and descriptions are in whatever language
the developer wrote them. None of it is tagged, so a screen reader reads it
in the interface language's voice.
- **Zoom.**
- On the website, the games list and the cards sit in boxes sized to the
window, so at 300-400% zoom they shrink to almost nothing. Long values
are cut off with "…", and a few small labels have fixed pixel sizes.
- The desktop app has page zoom turned off: <kbd>Ctrl</kbd>+<kbd>+</kbd>
does nothing. As far as the code shows, the Android app does not
pinch-zoom either.
- *Instead:* game pages and the CSV/JSON export; the website in a browser;
or your system's magnifier or text size.
- **The command palette's search box** shows no focus ring.
- **No automated accessibility tests.** Svelte's accessibility warnings show
up in development but do not fail the build.
- **Contrast themes** (Windows' forced colours) get no special support.
- **Zoom.** Long values are cut off with "…", and a few small labels have
fixed pixel sizes. As far as the code shows, the Android app does not
pinch-zoom.
*Instead:* game pages and the CSV/JSON export, the website in a browser, or
your system's magnifier or text size.
- **Automated checks are static.** A test holds the fixes above in place and
computes the theme's contrast, but nothing runs a screen reader or an
accessibility scanner, and Svelte's accessibility warnings do not fail the
build.
## Supported environments
@@ -211,11 +214,15 @@ interface:
- Check it 360 px wide, at 200% zoom, in both themes, and with *reduce motion*
on.
- Build overlays and pop-ups on Bits UI's `Dialog` (focus trap,
<kbd>Esc</kbd>, focus returned), not a hand-made `div`.
<kbd>Esc</kbd>, focus returned), not a hand-made `div`. A screen that must
block the page reports itself in `web/src/lib/overlays.svelte.ts`, and the
layout makes everything behind it inert.
- Put new text in both `web/src/i18n/locales/en.json` and `vi.json`.
- Read the accessibility warnings `npm run check` prints. CI does not fail on
them, so nobody else will. Add no new `svelte-ignore a11y_*` without giving
a reason in the pull request.
- `web/src/lib/a11y.test.ts` holds the fixes listed above and the theme's
contrast. If it fails, fix the change, not the test.
The [pull request template](.github/pull_request_template.md) has the short
version as a checklist. Coding agents also follow [`CLAUDE.md`](CLAUDE.md),
@@ -232,4 +239,5 @@ which says to keep this file true.
[Discussions › Ideas](https://github.com/poli0981/free-steam-games-list/discussions/categories/ideas),
or an issue.
*Last reviewed: 2026-11-09 (website and apps 2.5.0).*
*Last reviewed: 2026-11-09, after that day's accessibility fixes (website).
Desktop and Android apps: 2.5.0.*
+40 -1
View File
@@ -26,6 +26,45 @@ All notable changes to this awesome noob repo will be documented here.
- Source archives (`git archive`, GitHub's "Source code" downloads) left out
three legal documents that the web build reads, so building from one
stopped. They are included now.
- **Accessibility.** These reach the website as soon as they are merged, and
the apps with their next release:
- **The games table** is now a table to a screen reader. It exposes its
roles, the row and column counts, and a position for every row, even
though only the rows on screen exist. The image, data-issue and Steam
columns have names.
- **Table rows** are no longer a link wrapped around another link, and each
row is one <kbd>Tab</kbd> stop instead of two. Clicking anywhere on a row
still opens the game.
- **The phone cards** are a list that tells a screen reader its length and
each card's position.
- **The terms screen and the human check** are dialogs that take focus, and
the page behind them is out of reach until you are through. Before, Tab
walked through the hidden page first, and Ctrl/⌘+K could open the
command palette underneath them, out of sight but holding focus.
- **Kernel-level anti-cheat** shows a shield icon and the words, not only a
red badge.
- **Contrast:**
- Light-theme links, primary buttons, warnings and badges reach 4.5:1.
The light theme's amber is a shade darker as a result.
- Red badges in the dark theme reach 4.5:1 too.
- Text boxes and drop-downs have a visible 3:1 edge in both themes.
- **Zoom:**
- The games list keeps a minimum height when zoomed in, instead of
shrinking to nothing at 300-400%.
- The desktop app zooms with Ctrl/⌘ and + / −, from its next release.
- **Smaller fixes:**
- "Back to top" is out of the Tab order while it is hidden, and jumps
instead of gliding when *reduce motion* is on.
- The command palette's search box shows a focus ring.
- Screen readers read out the 💀 and the table's warning icon as words.
- `ACCESSIBILITY.md` moves all of this from "Known limitations" to "What
works today".
### 🧰 Tooling & misc
- `web/src/lib/a11y.test.ts` holds those fixes in the code. It also computes
the theme's contrast with the WCAG formula, so a colour edit that drops
below 4.5:1 for text, or below 3:1 for a control's edge, fails the tests.
### 📚 Docs
@@ -43,7 +82,7 @@ All notable changes to this awesome noob repo will be documented here.
the contact page.** Neither of the last two is a document you accept, so
nobody is asked to accept the terms again.
- `CLAUDE.md`: `ACCESSIBILITY.md` is a claim about the code, kept true in the
same pull request.
same pull request, and the rules behind the accessibility fixes.
## [v4.7.0] – 2026-11-03 (The "Lucky Dip" Edition)
+30 -5
View File
@@ -1208,11 +1208,36 @@ scraping pipeline (`scripts/`) driven by GitHub Actions.
edits the list and its "Last reviewed" line in the same pull request.
Reports arrive through `.github/ISSUE_TEMPLATE/accessibility.yml` (label
`accessibility`), and the About page links both the form and the statement.
Two of its limitations look solved and are not:
- `GamesTable.svelte`'s comment says the grid "keeps the table SEMANTICS",
but its rows are `<a role="row">` with no `table`/`grid` parent.
- The desktop app cannot zoom: Tauri's `zoomHotkeysEnabled` defaults to
false and `tauri.conf.json` does not set it.
`src/lib/a11y.test.ts` holds the fixes it lists. Rules that are easy to
break:
- **The games table is an ARIA table only when it is complete.** That means
`role="table"` with `aria-rowcount`/`aria-colcount`, a `rowgroup`, and
`aria-rowindex` on every virtualised row. Every column needs a label or an
`srLabel` (`games/columns.ts`). It used to be `<a role="row">` with
nothing around it, which a screen reader read as neither a table nor a
link.
- **A row is not a link.** The name's `<a>` stretches over the row
(`after:absolute after:inset-0`). Anything that must stay hoverable or
clickable on its own sits above it with `relative z-[1]`: the tooltips,
and the Steam `<a>`, which is `tabindex="-1"` so a row is one Tab stop.
The row draws the focus ring (`has-[:focus-visible]`), because cells clip
overflow.
- **The first-run overlays report to `lib/overlays.svelte.ts`.** The layout
makes the page behind them `inert`: the bare pages' wrapper, the skip link
and the shell. Ctrl/Cmd+K stands down while they are open, because the
palette would open under the gate and trap focus there. They are
`role="dialog"`, focus themselves with `focusOnMount`, and title
themselves with an h2. `BackToTop` is inside the shell so that it goes
inert with the page.
- **Kernel-level anti-cheat goes through `games/AntiCheatBadge.svelte`.** It
adds a shield icon and the words, so the colour is not the only cue.
- **Theme colours are checked by the WCAG formula.** The test computes
4.5:1 for text (badges on their /15 tint included) and 3:1 for
`--input`/`--ring` in both themes. A token edit that drops below either
fails.
- **Desktop zoom needs both parts:** `zoomHotkeysEnabled` on the window,
and `capabilities/zoom.json`. The latter is desktop-only, and macOS/Linux
zoom through an injected script that calls `set_webview_zoom`.
Svelte's a11y warnings never fail CI (`svelte-check` runs without
`--fail-on-warnings`), so read them.
+16
View File
@@ -0,0 +1,16 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "desktop-zoom",
"description": "Page zoom with Ctrl/Cmd and +/-. tauri.conf.json turns on zoomHotkeysEnabled: on Windows that is WebView2's own zoom, while on macOS and Linux Tauri injects a script that calls set_webview_zoom, which needs this permission. Desktop-only, like updater.json: the setting does nothing on Android and iOS.",
"platforms": [
"windows",
"linux",
"macOS"
],
"windows": [
"main"
],
"permissions": [
"core:webview:allow-set-webview-zoom"
]
}
+1
View File
@@ -19,6 +19,7 @@
"minWidth": 880,
"minHeight": 600,
"resizable": true,
"zoomHotkeysEnabled": true,
"maximizable": true,
"fullscreen": false,
"center": true,
+4
View File
@@ -170,6 +170,10 @@
"filterAllStatus": "All status",
"hideDead": "Hide dead",
"colName": "Name",
"colImage": "Image",
"colIssues": "Data issues",
"colSteam": "Steam page",
"openOnSteamNamed": "Open {{name}} on Steam",
"noResults": "No game matches these filters.",
"clearFilters": "Clear filters",
"showing": "{{shown}} of {{total}}",
+4
View File
@@ -170,6 +170,10 @@
"filterAllStatus": "Mọi trạng thái",
"hideDead": "Ẩn dead",
"colName": "Tên",
"colImage": "Ảnh",
"colIssues": "Vấn đề dữ liệu",
"colSteam": "Trang Steam",
"openOnSteamNamed": "Mở {{name}} trên Steam",
"noResults": "Không có game nào khớp bộ lọc này.",
"clearFilters": "Xóa bộ lọc",
"showing": "{{shown}} trên {{total}}",
+192
View File
@@ -0,0 +1,192 @@
/**
* The accessibility fixes behind ACCESSIBILITY.md's "What works today", held
* in place by reading the source, like mobile-layout.test.ts. None of this
* replaces trying the app with a keyboard and a screen reader; it stops a
* refactor from quietly undoing what was checked by hand.
*/
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
import { withoutBlockComments } from "./testing/source";
import { COLS } from "./games/columns";
const raw = (...p: string[]) => readFileSync(join(process.cwd(), ...p), "utf-8");
const src = (...p: string[]) => withoutBlockComments(raw(...p));
const count = (text: string, needle: string) => text.split(needle).length - 1;
describe("the games table", () => {
const table = src("src", "lib", "games", "GamesTable.svelte");
it("is a complete ARIA table, so its rows mean something", () => {
// Rows used to be <a role="row"> with nothing around them: neither a
// table nor a link to a screen reader.
expect(table).toContain('role="table"');
expect(table).toContain("aria-rowcount=");
expect(table).toContain("aria-colcount=");
expect(table).toContain('role="rowgroup"');
expect(count(table, "aria-rowindex=")).toBe(2);
expect(table).not.toMatch(/<a\b[^>]*\brole="row"/);
});
it("has one link per row, and no fake link nested in it", () => {
expect(table).not.toContain('role="link"');
expect(table).toContain("after:absolute after:inset-0");
});
it("names every column, the icon-only ones for screen readers", () => {
for (const col of COLS) expect(col.label || col.srLabel, col.key).toBeTruthy();
});
});
describe("the phone cards", () => {
it("are a list that says how long it is and where each card sits", () => {
const cards = src("src", "lib", "games", "MobileGameCards.svelte");
for (const attr of ['role="list"', 'role="listitem"', "aria-setsize=", "aria-posinset="]) {
expect(cards).toContain(attr);
}
});
});
describe("list panes at high zoom", () => {
it.each([
["GamesTable.svelte", "h-[calc(100dvh-20rem)]"],
["MobileGameCards.svelte", "h-[calc(100dvh-18rem)]"],
])("%s keeps a minimum height", (file, height) => {
// Sized to the window alone, the pane reached zero at 300-400% zoom.
const text = src("src", "lib", "games", file);
const classes = text.slice(text.indexOf(height) - 40, text.indexOf(height) + 80);
expect(classes).toMatch(/\bmin-h-/);
});
});
describe("kernel-level anti-cheat", () => {
it("is never told apart by colour alone", () => {
const files = [
["src", "lib", "games", "GamesTable.svelte"],
["src", "lib", "games", "MobileGameCards.svelte"],
["src", "routes", "games", "[appid]", "+page.svelte"],
["src", "routes", "random", "+page.svelte"],
];
for (const f of files) {
const text = src(...f);
expect(text, f.join("/")).not.toMatch(/is_kernel_ac \? "destructive"/);
expect(text, f.join("/")).toContain("<AntiCheatBadge");
}
const badge = src("src", "lib", "games", "AntiCheatBadge.svelte");
expect(badge).toContain("ShieldAlert");
expect(badge).toContain('t("charts.acLevel.kernel")');
});
});
describe("the first-run overlays", () => {
// Raw text: "/legal/*" in a line comment of the gate reads as the start of
// a block comment to withoutBlockComments, which then swallows real code.
const gate = raw("src", "lib", "common", "ConsentGate.svelte");
const check = raw("src", "lib", "common", "HumanCheck.svelte");
const layout = raw("src", "routes", "+layout.svelte");
it("are modal dialogs that take focus, with one heading level below the page's", () => {
// Three cards in the gate: the terms, the declined notice, Leave site.
expect(count(gate, 'role="dialog"')).toBe(3);
expect(count(gate, 'aria-modal="true"')).toBe(3);
expect(count(gate, "{@attach focusOnMount}")).toBe(3);
expect(check).toContain('role="dialog"');
expect(check).toContain("{@attach focusOnMount}");
expect(gate).not.toContain("<h1");
expect(check).not.toContain("<h1");
});
it("make everything behind them inert", () => {
expect(gate).toContain("overlays.consent = open");
expect(check).toContain("overlays.humanCheck = open");
// The bare pages' wrapper, the skip link and the shell.
expect(count(layout, "inert={overlays.open || undefined}")).toBe(3);
});
it("are never covered by the command palette", () => {
const palette = src("src", "lib", "palette.svelte.ts");
expect(palette).toContain("if (overlays.open) return;");
});
});
describe("back to top", () => {
it("is out of reach while hidden, and honours reduced motion", () => {
const button = src("src", "lib", "common", "BackToTop.svelte");
expect(button).toContain("inert={!visible || undefined}");
expect(button).toContain("prefers-reduced-motion: reduce");
});
});
describe("the desktop app", () => {
it("lets the reader zoom", () => {
const conf = JSON.parse(readFileSync(join(process.cwd(), "src-tauri", "tauri.conf.json"), "utf-8")) as {
app: { windows: { label: string; zoomHotkeysEnabled?: boolean }[] };
};
expect(conf.app.windows.find((w) => w.label === "main")?.zoomHotkeysEnabled).toBe(true);
// macOS and Linux zoom through a script that needs this permission.
const zoom = JSON.parse(
readFileSync(join(process.cwd(), "src-tauri", "capabilities", "zoom.json"), "utf-8"),
) as { platforms: string[]; permissions: string[] };
expect(zoom.permissions).toContain("core:webview:allow-set-webview-zoom");
expect(zoom.platforms).not.toContain("android");
});
});
/* ───────────────────────────── contrast ───────────────────────────── */
type Rgb = [number, number, number];
function tokens(css: string, selector: string): Record<string, Rgb> {
const start = css.indexOf(`${selector} {`);
const body = css.slice(start, css.indexOf("}", start));
const out: Record<string, Rgb> = {};
for (const m of body.matchAll(/--([\w-]+):\s*([\d.]+)\s+([\d.]+)%\s+([\d.]+)%;/g)) {
out[m[1]] = hslToRgb(Number(m[2]), Number(m[3]) / 100, Number(m[4]) / 100);
}
return out;
}
function hslToRgb(h: number, s: number, l: number): Rgb {
const k = (n: number) => (n + h / 30) % 12;
const a = s * Math.min(l, 1 - l);
const f = (n: number) => l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
return [f(0), f(8), f(4)];
}
function luminance([r, g, b]: Rgb): number {
const ch = (v: number) => (v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4);
return 0.2126 * ch(r) + 0.7152 * ch(g) + 0.0722 * ch(b);
}
function ratio(a: Rgb, b: Rgb): number {
const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x);
return (hi + 0.05) / (lo + 0.05);
}
const tint = (fg: Rgb, bg: Rgb, alpha: number): Rgb =>
[0, 1, 2].map((i) => alpha * fg[i] + (1 - alpha) * bg[i]) as Rgb;
describe("theme contrast (WCAG 2.2 AA)", () => {
const css = readFileSync(join(process.cwd(), "src", "styles", "theme.css"), "utf-8");
const themes = { light: tokens(css, ":root"), dark: tokens(css, ".dark") };
it.each(Object.entries(themes))("%s: text is at least 4.5:1, control edges 3:1", (_, t) => {
const low: string[] = [];
const need = (label: string, value: number, min: number) => {
if (value < min) low.push(`${label}: ${value.toFixed(2)} < ${min}`);
};
for (const surface of ["background", "card"]) {
for (const text of ["foreground", "muted-foreground", "primary", "warning", "destructive", "success", "info"]) {
need(`${text} on ${surface}`, ratio(t[text], t[surface]), 4.5);
}
need(`input edge on ${surface}`, ratio(t.input, t[surface]), 3);
need(`focus ring on ${surface}`, ratio(t.ring, t[surface]), 3);
}
need("button label on primary", ratio(t["primary-foreground"], t.primary), 4.5);
// Badges and the active nav item: the colour as text on its own tint.
for (const tone of ["primary", "warning", "destructive", "success", "info"]) {
need(`${tone} on its /15 tint`, ratio(t[tone], tint(t[tone], t.card, 0.15)), 4.5);
}
expect(low).toEqual([]);
});
});
+9 -1
View File
@@ -23,10 +23,18 @@
<!-- bottom-4/right-4 plus the safe-area insets, so in the Android app the
button clears the navigation bar (see the utilities in styles/theme.css). -->
<!-- inert while hidden: it only fades out, so it stayed a Tab stop and a
button a screen reader read out. A JS smooth scroll is not covered by
the CSS reduced-motion rule, so it asks the system itself. -->
<button
type="button"
aria-label={i18n.t("common.backToTop")}
onclick={() => scroller?.scrollTo({ top: 0, behavior: "smooth" })}
inert={!visible || undefined}
onclick={() =>
scroller?.scrollTo({
top: 0,
behavior: matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth",
})}
class={cn(
"fixed z-20 grid size-10 place-items-center rounded-full border",
"bg-card text-muted-foreground shadow-lg transition-all hover:text-foreground",
+4 -2
View File
@@ -136,7 +136,9 @@
>
<Dialog.Title class="sr-only">{t("cmdk.title")}</Dialog.Title>
<div class="flex items-center gap-2 border-b px-3">
<!-- The focus ring is the row's, inset: an outline on the input itself would be
cut off by the dialog's edge, and the input used to have none at all. -->
<div class="flex items-center gap-2 border-b px-3 has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring has-[:focus-visible]:ring-inset">
<Search class="size-4 shrink-0 text-muted-foreground" />
<!-- svelte-ignore a11y_autofocus -->
<input
@@ -150,7 +152,7 @@
aria-controls="cmdk-list"
aria-activedescendant={activeId}
aria-autocomplete="list"
class="h-12 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"
class="h-12 w-full bg-transparent text-sm focus-visible:outline-none placeholder:text-muted-foreground"
/>
</div>
+36 -6
View File
@@ -13,6 +13,7 @@
import { isUngatedPath } from "../gates";
import { closeTab, leaveSite } from "../leave-site";
import { pwa } from "../pwa-state.svelte";
import { overlays, focusOnMount } from "../overlays.svelte";
import Button from "../ui/Button.svelte";
const t = i18n.t;
@@ -38,6 +39,14 @@
// dialog into every page's HTML.
const open = $derived(consent.hydrated && !consent.accepted && !exempt);
// The layout makes the page behind inert while this is open (overlays.svelte.ts).
$effect(() => {
overlays.consent = open;
return () => {
overlays.consent = false;
};
});
/**
* REVIEW mode: some documents changed since this reader accepted them, and
* only those are shown, as a diff. Before per-document hashing the only
@@ -142,9 +151,16 @@
<!-- nothing: the page underneath is already rendered -->
{:else if leaving !== "idle"}
<div class="fixed inset-0 z-[60] flex overflow-auto bg-background/95 p-safe-or-4 backdrop-blur-sm">
<div class="m-auto w-full max-w-md rounded-lg border bg-card p-8 text-center">
<div
role="dialog"
aria-modal="true"
aria-labelledby="consent-title"
tabindex="-1"
{@attach focusOnMount}
class="m-auto w-full max-w-md rounded-lg border bg-card p-8 text-center focus:outline-none"
>
<House class="mx-auto mb-4 size-10 text-muted-foreground" />
<h1 class="mb-2 text-xl font-semibold">{t("consent.leaveNowhereTitle")}</h1>
<h2 id="consent-title" class="mb-2 text-xl font-semibold">{t("consent.leaveNowhereTitle")}</h2>
<p role="status" class="text-sm text-muted-foreground">
{leaving === "refused" ? t("consent.leaveRefused") : t("consent.leaveNowhereBody")}
</p>
@@ -161,9 +177,16 @@
</div>
{:else if declined}
<div class="fixed inset-0 z-[60] flex overflow-auto bg-background/95 p-safe-or-4 backdrop-blur-sm">
<div class="m-auto w-full max-w-md rounded-lg border border-warning/40 bg-warning/5 p-8 text-center">
<div
role="dialog"
aria-modal="true"
aria-labelledby="consent-title"
tabindex="-1"
{@attach focusOnMount}
class="m-auto w-full max-w-md rounded-lg border border-warning/40 bg-warning/5 p-8 text-center focus:outline-none"
>
<ShieldCheck class="mx-auto mb-4 size-10 text-warning" />
<h1 class="mb-2 text-xl font-semibold">{t("consent.declinedTitle")}</h1>
<h2 id="consent-title" class="mb-2 text-xl font-semibold">{t("consent.declinedTitle")}</h2>
<p class="text-sm text-muted-foreground">{t("consent.declinedBody")}</p>
<div class="mt-6 flex flex-wrap justify-center gap-2">
<Button variant="outline" onclick={() => (declined = false)}>
@@ -180,7 +203,14 @@
</div>
{:else}
<div class="fixed inset-0 z-[60] flex overflow-auto bg-background/95 p-safe-or-4 backdrop-blur-sm">
<div class="m-auto w-full max-w-lg rounded-xl border bg-card p-6 shadow-xl sm:p-8">
<div
role="dialog"
aria-modal="true"
aria-labelledby="consent-title"
tabindex="-1"
{@attach focusOnMount}
class="m-auto w-full max-w-lg rounded-xl border bg-card p-6 shadow-xl focus:outline-none sm:p-8"
>
<div class="mb-5 flex items-start gap-3">
<span class="grid size-10 shrink-0 place-items-center rounded-lg bg-primary/15 text-primary">
{#if reviewing}
@@ -190,7 +220,7 @@
{/if}
</span>
<div>
<h1 class="text-xl font-semibold">{reviewing ? t("consent.changedTitle") : t("consent.title")}</h1>
<h2 id="consent-title" class="text-xl font-semibold">{reviewing ? t("consent.changedTitle") : t("consent.title")}</h2>
<p class="mt-1 text-sm text-muted-foreground">
{reviewing ? t("consent.changedIntro") : t("consent.intro")}
</p>
+13 -2
View File
@@ -11,6 +11,7 @@
import { legalDocSlug } from "../legal";
import { HUMAN_CHECK_ACTION, HUMAN_CHECK_PATH, type HumanCheckReply } from "../../../shared/human-check";
import Button from "../ui/Button.svelte";
import { overlays, focusOnMount } from "../overlays.svelte";
/**
* The Turnstile human check - WEB ONLY, after the consent gate.
@@ -31,6 +32,14 @@
consent.accepted && humanCheck.hydrated && !humanCheck.cleared && !isUngatedPath(page.url.pathname),
);
// The layout makes the page behind inert while this is open (overlays.svelte.ts).
$effect(() => {
overlays.humanCheck = open;
return () => {
overlays.humanCheck = false;
};
});
type Status = "loading" | "ready" | "confirming" | "failed" | "blocked" | "unsupported";
let status = $state<Status>("loading");
let code = $state<string | null>(null);
@@ -166,14 +175,16 @@
aria-modal="true"
aria-labelledby="human-check-title"
aria-describedby="human-check-intro"
class="m-auto w-full max-w-md rounded-xl border bg-card p-6 shadow-xl sm:p-8"
tabindex="-1"
{@attach focusOnMount}
class="m-auto w-full max-w-md rounded-xl border bg-card p-6 shadow-xl focus:outline-none sm:p-8"
>
<div class="mb-5 flex items-start gap-3">
<span class="grid size-10 shrink-0 place-items-center rounded-lg bg-primary/15 text-primary">
<ShieldCheck class="size-5" />
</span>
<div>
<h1 id="human-check-title" class="text-xl font-semibold">{t("humanCheck.title")}</h1>
<h2 id="human-check-title" class="text-xl font-semibold">{t("humanCheck.title")}</h2>
<p id="human-check-intro" class="mt-1 text-sm text-muted-foreground">{t("humanCheck.intro")}</p>
</div>
</div>
+31
View File
@@ -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>&nbsp;· {t("charts.acLevel.kernel")}</span>{:else if kernel}<span class="sr-only">&nbsp;({t("charts.acLevel.kernel")})</span>{/if}
</Badge>
+75 -57
View File
@@ -14,8 +14,8 @@
import { imgFallback } from "../img-fallback";
import { recordIssues } from "../validation";
import { formatNumber, parseReviewPercent, cn } from "../utils";
import { openExternal } from "../external-open";
import Badge from "../ui/Badge.svelte";
import AntiCheatBadge from "./AntiCheatBadge.svelte";
let { rows }: { rows: GameRecord[] } = $props();
@@ -63,62 +63,87 @@
</script>
<div class="overflow-hidden rounded-lg border bg-card">
<div bind:this={viewport} class="h-[calc(100dvh-20rem)] overflow-auto scrollbar-slim scrollbar-panel">
<div style:width="{TOTAL_WIDTH}px" style:min-width="100%">
<!-- Sticky header. A real <table> cannot be virtualised without either
losing sticky headers or fighting the row heights, so this is a grid
that keeps the table SEMANTICS through role attributes. -->
<!-- min-h: the height follows the window, so at 300-400% zoom it reached
zero and the list vanished. Taller than a tiny window, the page scrolls. -->
<div bind:this={viewport} class="h-[calc(100dvh-20rem)] min-h-64 overflow-auto scrollbar-slim scrollbar-panel">
<!-- A real <table> cannot be virtualised without either losing the sticky
header or fighting the row heights, so this is a grid of divs with the
ARIA table roles. They have to be complete to mean anything: the table
around the rows, the row and column counts (only the rows on screen
exist), and a row index on each. Rows used to be <a role="row"> with no
table around them, which a screen reader announced as neither a link
nor a table. -->
<div
role="table"
aria-label={t("games.title")}
aria-rowcount={rows.length + 1}
aria-colcount={COLS.length}
style:width="{TOTAL_WIDTH}px"
style:min-width="100%"
>
<div
role="row"
aria-rowindex={1}
class="sticky top-0 z-10 flex h-10 items-center border-b bg-card/95 backdrop-blur"
>
{#each COLS as col (col.key)}
{@const active = filters.sortKey === col.key}
<div
role="columnheader"
aria-sort={active ? (filters.sortDir === "asc" ? "ascending" : "descending") : "none"}
aria-sort={col.sortable ? (active ? (filters.sortDir === "asc" ? "ascending" : "descending") : "none") : undefined}
style:width="{col.width}px"
class="shrink-0 px-2"
>
{#if col.label}
{#if col.label && col.sortable}
<button
type="button"
disabled={!col.sortable}
onclick={() => toggleSort(col.key, col.sortable)}
title={col.sortable ? t("games.sortBy", { column: t(col.label) }) : undefined}
title={t("games.sortBy", { column: t(col.label) })}
class={cn(
"flex w-full items-center gap-1 text-xs font-semibold uppercase tracking-wide",
"flex w-full items-center gap-1 text-xs font-semibold uppercase tracking-wide hover:text-foreground",
col.align === "right" && "justify-end",
col.sortable ? "hover:text-foreground" : "cursor-default",
active ? "text-foreground" : "text-muted-foreground",
)}
>
<span class="truncate">{t(col.label)}</span>
{#if col.sortable}
{#if !active}
<ChevronsUpDown class="size-3 shrink-0 opacity-40" />
{:else if filters.sortDir === "asc"}
<ChevronUp class="size-3 shrink-0" />
{:else}
<ChevronDown class="size-3 shrink-0" />
{/if}
{#if !active}
<ChevronsUpDown class="size-3 shrink-0 opacity-40" />
{:else if filters.sortDir === "asc"}
<ChevronUp class="size-3 shrink-0" />
{:else}
<ChevronDown class="size-3 shrink-0" />
{/if}
</button>
{:else if col.label}
<!-- Not sortable: plain text, not a disabled button that a screen
reader announces as one. -->
<span class="block truncate text-xs font-semibold uppercase tracking-wide text-muted-foreground">
{t(col.label)}
</span>
{:else if col.srLabel}
<span class="sr-only">{t(col.srLabel)}</span>
{/if}
</div>
{/each}
</div>
<div style:height="{$virtualizer.getTotalSize()}px" class="relative">
<div role="rowgroup" style:height="{$virtualizer.getTotalSize()}px" class="relative">
{#each items as item (item.key)}
{@const g = rows[item.index]}
{@const appid = appidOf(g)}
{@const issues = recordIssues(g)}
{@const pct = parseReviewPercent(g.reviews)}
<a
href={appid ? `/games/${appid}` : g.link}
<!-- The whole row still opens the game: the name's link stretches
over it (after:absolute inset-0, against this positioned row), so
there is one link per row instead of a row that is a link.
Things that must stay hoverable or clickable on their own (the
warning and dead-game tooltips, the Steam link) sit above it
with relative z-[1]. Its focus ring is drawn by the row: the
cells clip overflow and would cut an outline off. -->
<div
role="row"
class="absolute left-0 flex items-center border-b text-sm transition-colors hover:bg-accent/60"
aria-rowindex={item.index + 2}
class="absolute left-0 flex items-center border-b text-sm transition-colors hover:bg-accent/60 has-[:focus-visible]:bg-accent/60 has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring has-[:focus-visible]:ring-inset"
style:height="{item.size}px"
style:width="{TOTAL_WIDTH}px"
style:transform="translateY({item.start}px)"
@@ -150,18 +175,20 @@
{/if}
{:else if col.key === "issues"}
{#if issues.length}
<span
class="grid size-5 place-items-center text-warning"
title={issues.map((i) => t(i.message, i.vars)).join(" · ")}
>
{@const issueText = issues.map((i) => t(i.message, i.vars)).join(" · ")}
<span class="relative z-[1] grid size-5 place-items-center text-warning" title={issueText}>
<TriangleAlert class="size-3.5" />
<span class="sr-only">{issueText}</span>
</span>
{/if}
{:else if col.key === "name"}
<span class="font-medium">
{#if g.is_dead}<span title={t("games.deadTitle")} class="mr-1">💀</span>{/if}
{g.name || "—"}
</span>
{#if g.is_dead}<span aria-hidden="true" title={t("games.deadTitle")} class="relative z-[1] mr-1">💀</span>{/if}
<a
href={appid ? `/games/${appid}` : g.link}
class="font-medium after:absolute after:inset-0 after:content-[''] focus-visible:outline-none"
>
{g.name || "—"}{#if g.is_dead}<span class="sr-only">, {t("games.deadTitle")}</span>{/if}
</a>
{:else if col.key === "genre"}
{#if g.genre}<Badge variant="outline">{g.genre}</Badge>{:else}<span class="text-muted-foreground">—</span>{/if}
{:else if col.key === "type_game"}
@@ -182,7 +209,7 @@
<span class="font-mono tnum">{formatNumber(g.all_time_peak)}</span>
{:else if col.key === "anti_cheat"}
{#if g.anti_cheat && g.anti_cheat !== "-"}
<Badge variant={g.is_kernel_ac ? "destructive" : "warning"}>{g.anti_cheat}</Badge>
<AntiCheatBadge name={g.anti_cheat} kernel={g.is_kernel_ac} />
{:else}<span class="text-muted-foreground">—</span>{/if}
{:else if col.key === "platforms"}
<span class="text-xs text-muted-foreground">
@@ -195,36 +222,27 @@
{t(g.status === "active" ? "common.active" : "common.delisted")}
</Badge>
{:else if col.key === "link"}
<!-- stopPropagation so the Steam link does not also trigger
the row navigation wrapping it. -->
<span
role="link"
tabindex="0"
<!-- A real link now that it is not nested inside the row's
own link, so the apps' external-link interceptor opens it
in the system browser like any other. Out of the Tab
order: one stop per row, not two, and a game's own page
has the same Steam links for the keyboard. Screen readers
still find it. -->
<a
href={g.link}
target="_blank"
rel="noreferrer"
tabindex="-1"
aria-label={t("games.openOnSteamNamed", { name: g.name || appid || "" })}
title={t("detail.openOnSteam", { appid: appidOf(g) })}
onclick={(e) => {
e.preventDefault();
e.stopPropagation();
// openExternal, not window.open: the Tauri webview blocks
// window.open to external URLs, and the global link
// interceptor only sees <a> elements - this is a span
// inside the row's own internal link.
void openExternal(g.link);
}}
onkeydown={(e) => {
if (e.key === "Enter") {
e.preventDefault();
e.stopPropagation();
void openExternal(g.link);
}
}}
class="inline-grid size-6 place-items-center text-muted-foreground hover:text-primary"
class="relative z-[1] inline-grid size-6 place-items-center text-muted-foreground hover:text-primary"
>
<ExternalLink class="size-3.5" />
</span>
</a>
{/if}
</div>
{/each}
</a>
</div>
{/each}
</div>
</div>
+64 -53
View File
@@ -10,6 +10,7 @@
import { formatNumber, parseReviewPercent, cn } from "../utils";
import { reviewTone } from "./columns";
import Badge from "../ui/Badge.svelte";
import AntiCheatBadge from "./AntiCheatBadge.svelte";
// Below md the 1,282px-wide table is unusable, so the same rows render as
// cards. Still virtualised: 3,700 cards is as many DOM nodes as 3,700 rows.
@@ -39,8 +40,11 @@
const items = $derived($virtualizer.getVirtualItems());
</script>
<div bind:this={viewport} class="h-[calc(100dvh-18rem)] overflow-auto scrollbar-slim scrollbar-panel">
<div style:height="{$virtualizer.getTotalSize()}px" class="relative">
<!-- min-h, as in GamesTable: at 300-400% zoom the window-sized height reached
zero. A list with its size and each card's position, since only the cards
on screen exist. -->
<div bind:this={viewport} class="h-[calc(100dvh-18rem)] min-h-64 overflow-auto scrollbar-slim scrollbar-panel">
<div role="list" aria-label={t("games.title")} style:height="{$virtualizer.getTotalSize()}px" class="relative">
{#each items as item (item.key)}
{@const g = rows[item.index]}
{@const appid = appidOf(g)}
@@ -50,62 +54,69 @@
measuring), so a badge row that wrapped to a third line used to paint
over the next card. The anti-cheat badge truncates instead of wrapping:
some values run to 72 characters. -->
<a
href={appid ? `/games/${appid}` : g.link}
class="absolute left-0 right-0 flex gap-3 overflow-hidden border-b px-1 py-3"
<div
role="listitem"
aria-setsize={rows.length}
aria-posinset={item.index + 1}
class="absolute left-0 right-0"
style:height="{item.size}px"
style:transform="translateY({item.start}px)"
>
{#if g.header_image}
<img
src={headerToCapsule(g.header_image)}
{@attach imgFallback(thumbFallback(g.header_image))}
alt=""
loading="lazy"
decoding="async"
referrerpolicy="no-referrer"
class="h-[42px] w-[90px] shrink-0 rounded object-cover"
/>
{:else}
<div class="h-[42px] w-[90px] shrink-0 rounded bg-muted"></div>
{/if}
<div class="min-w-0 flex-1">
<div class="flex items-center gap-1.5">
{#if g.is_dead}<span title={t("games.deadTitle")}>💀</span>{/if}
<span class="truncate text-sm font-medium">{g.name || "—"}</span>
{#if issues.length}
<TriangleAlert
class="size-3.5 shrink-0 text-warning"
aria-label={issues.map((i) => t(i.message, i.vars)).join(" · ")}
/>
{/if}
</div>
<div class="mt-1 flex flex-wrap items-center gap-1">
{#if g.genre}<Badge variant="outline">{g.genre}</Badge>{/if}
{#if g.type_game}
<Badge variant={g.type_game === "online" ? "success" : "secondary"}>
{t(g.type_game === "online" ? "common.online" : "common.offline")}
</Badge>
{/if}
{#if g.anti_cheat && g.anti_cheat !== "-"}
<Badge variant={g.is_kernel_ac ? "destructive" : "warning"} class="block max-w-full truncate">
{g.anti_cheat}
</Badge>
{/if}
</div>
</div>
<div class="shrink-0 text-right">
{#if pct !== null}
<div class={cn("font-mono text-sm tnum", reviewTone(pct))}>{pct}%</div>
<a
href={appid ? `/games/${appid}` : g.link}
class="flex h-full gap-3 overflow-hidden border-b px-1 py-3"
>
{#if g.header_image}
<img
src={headerToCapsule(g.header_image)}
{@attach imgFallback(thumbFallback(g.header_image))}
alt=""
loading="lazy"
decoding="async"
referrerpolicy="no-referrer"
class="h-[42px] w-[90px] shrink-0 rounded object-cover"
/>
{:else}
<div class="h-[42px] w-[90px] shrink-0 rounded bg-muted"></div>
{/if}
<div class="font-mono text-xs text-muted-foreground tnum">
{formatNumber(g.current_players)}
<div class="min-w-0 flex-1">
<div class="flex items-center gap-1.5">
{#if g.is_dead}<span aria-hidden="true" title={t("games.deadTitle")}>💀</span>{/if}
<span class="truncate text-sm font-medium">
{g.name || "—"}{#if g.is_dead}<span class="sr-only">, {t("games.deadTitle")}</span>{/if}
</span>
{#if issues.length}
<TriangleAlert
class="size-3.5 shrink-0 text-warning"
aria-label={issues.map((i) => t(i.message, i.vars)).join(" · ")}
/>
{/if}
</div>
<div class="mt-1 flex flex-wrap items-center gap-1">
{#if g.genre}<Badge variant="outline">{g.genre}</Badge>{/if}
{#if g.type_game}
<Badge variant={g.type_game === "online" ? "success" : "secondary"}>
{t(g.type_game === "online" ? "common.online" : "common.offline")}
</Badge>
{/if}
{#if g.anti_cheat && g.anti_cheat !== "-"}
<AntiCheatBadge name={g.anti_cheat} kernel={g.is_kernel_ac} class="block max-w-full truncate" />
{/if}
</div>
</div>
</div>
</a>
<div class="shrink-0 text-right">
{#if pct !== null}
<div class={cn("font-mono text-sm tnum", reviewTone(pct))}>{pct}%</div>
{/if}
<div class="font-mono text-xs text-muted-foreground tnum">
{formatNumber(g.current_players)}
</div>
</div>
</a>
</div>
{/each}
</div>
</div>
+6 -3
View File
@@ -33,6 +33,9 @@ export interface ColDef {
key: ColumnKey;
/** i18n key, or "" for the icon-only columns. */
label: string;
/** i18n key read only by screen readers, for the icon-only columns: an
* empty column header leaves every cell under it unnamed. */
srLabel?: string;
width: number;
sortable?: boolean;
align?: "left" | "right" | "center";
@@ -40,8 +43,8 @@ export interface ColDef {
}
export const COLS: ColDef[] = [
{ key: "thumb", label: "", width: 64 },
{ key: "issues", label: "", width: 30 },
{ key: "thumb", label: "", srLabel: "games.colImage", width: 64 },
{ key: "issues", label: "", srLabel: "games.colIssues", width: 30 },
{
key: "name",
label: "games.colName",
@@ -113,7 +116,7 @@ export const COLS: ColDef[] = [
sortable: true,
sortValue: (g) => g.status ?? "",
},
{ key: "link", label: "", width: 48 },
{ key: "link", label: "", srLabel: "games.colSteam", width: 48 },
];
export const TOTAL_WIDTH = COLS.reduce((sum, c) => sum + c.width, 0);
+33
View File
@@ -0,0 +1,33 @@
/**
* Whether a first-run overlay (the consent gate, the human check) is on screen.
*
* Each overlay reports itself from an $effect, so the condition stays in the
* component that decides to show itself. The root layout makes the page
* underneath `inert` while one is open: out of the Tab order and out of the
* accessibility tree, so keyboard focus and a screen reader stay in the
* overlay. Before this, Tab walked through the whole hidden page before it
* reached the gate's buttons. The Ctrl/Cmd+K shortcut stands down too: the
* palette would open UNDER the gate (z-50 against z-[60]) and trap focus where
* nobody can see it.
*
* Never true during prerender: both overlays wait until storage has been read.
*/
class Overlays {
consent = $state(false);
humanCheck = $state(false);
get open(): boolean {
return this.consent || this.humanCheck;
}
}
export const overlays = new Overlays();
/**
* Attachment for an overlay's dialog element: focus it as it mounts, so the
* keyboard and a screen reader start inside it, on its label. The element
* carries tabindex="-1" (focusable from script, not a Tab stop of its own).
*/
export function focusOnMount(node: HTMLElement): void {
node.focus({ preventScroll: true });
}
+68
View File
@@ -0,0 +1,68 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { focusOnMount, overlays } from "./overlays.svelte";
import { installPaletteShortcut, palette } from "./palette.svelte";
afterEach(() => {
overlays.consent = false;
overlays.humanCheck = false;
palette.hide();
vi.unstubAllGlobals();
});
describe("first-run overlays", () => {
it("count as open while either the consent gate or the human check is", () => {
expect(overlays.open).toBe(false);
overlays.consent = true;
expect(overlays.open).toBe(true);
overlays.consent = false;
overlays.humanCheck = true;
expect(overlays.open).toBe(true);
overlays.humanCheck = false;
expect(overlays.open).toBe(false);
});
it("take focus as they mount, without scrolling to it", () => {
const focus = vi.fn();
focusOnMount({ focus } as unknown as HTMLElement);
expect(focus).toHaveBeenCalledWith({ preventScroll: true });
});
});
describe("the Ctrl/Cmd+K shortcut", () => {
/** A keydown with only what the handler reads; this suite runs in Node. */
function press(target: EventTarget, init: { key: string; ctrlKey?: boolean }): Event {
const event = Object.assign(new Event("keydown", { cancelable: true }), {
isComposing: false,
keyCode: 0,
metaKey: false,
ctrlKey: false,
...init,
});
target.dispatchEvent(event);
return event;
}
it("stands down under a first-run overlay, and toggles the palette otherwise", () => {
const win = new EventTarget();
vi.stubGlobal("window", win);
const teardown = installPaletteShortcut();
try {
// Under the gate the palette would open beneath it and hold focus out
// of sight, so the key is left alone entirely.
overlays.consent = true;
const ignored = press(win, { key: "k", ctrlKey: true });
expect(palette.open).toBe(false);
expect(ignored.defaultPrevented).toBe(false);
overlays.consent = false;
const handled = press(win, { key: "k", ctrlKey: true });
expect(palette.open).toBe(true);
expect(handled.defaultPrevented).toBe(true);
press(win, { key: "Escape" });
expect(palette.open).toBe(false);
} finally {
teardown();
}
});
});
+5
View File
@@ -1,3 +1,5 @@
import { overlays } from "./overlays.svelte";
/**
* Command-palette open state, kept out of the component so anything can open
* it — the topbar button, the keyboard shortcut, an empty-state prompt — without
@@ -40,6 +42,9 @@ export function installPaletteShortcut(): () => void {
function onKeydown(e: KeyboardEvent) {
if (e.isComposing || e.keyCode === 229) return;
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k") {
// Not under a first-run overlay: the palette would open beneath it and
// trap focus out of sight (overlays.svelte.ts).
if (overlays.open) return;
e.preventDefault();
palette.toggle();
return;
+13 -4
View File
@@ -11,6 +11,7 @@
import { humanCheck } from "#lib/human-check-state.svelte.js";
import { appReady } from "#lib/app-ready.js";
import { installPaletteShortcut } from "#lib/palette.svelte.js";
import { overlays } from "#lib/overlays.svelte.js";
import { games, installGamesRevalidation } from "#lib/games.svelte.js";
import { upgradeLegacyHashUrl } from "#lib/legacy-url.js";
import { recoverFallbackRoute } from "#lib/fallback-route.js";
@@ -208,16 +209,21 @@
{#if pwaInfo}{@html pwaInfo.webManifest.linkTag}{/if}
</svelte:head>
<!-- inert while the consent gate or the human check is open: the page
behind leaves the Tab order and the accessibility tree, so keyboard
focus and screen readers stay in the overlay (lib/overlays.svelte.ts).
Never set during prerender. -->
{#if bare}
{@render children()}
<!-- display:contents: a wrapper for `inert` that takes no part in the layout. -->
<div class="contents" inert={overlays.open || undefined}>{@render children()}</div>
{:else}
<a href="#main" class="skip-link">{i18n.t("common.skipToContent")}</a>
<a href="#main" class="skip-link" inert={overlays.open || undefined}>{i18n.t("common.skipToContent")}</a>
<!-- The safe-area padding keeps the shell out from under the Android status
bar (and a landscape cutout); <main> takes the bottom inset itself, so
the page scrolls behind the navigation bar but its last line clears it.
See the safe-area utilities in styles/theme.css. -->
<div class="flex h-dvh overflow-hidden pt-safe pl-safe pr-safe">
<div class="flex h-dvh overflow-hidden pt-safe pl-safe pr-safe" inert={overlays.open || undefined}>
<aside class="hidden w-60 shrink-0 border-r bg-card/40 lg:block">
<Sidebar />
</aside>
@@ -253,10 +259,13 @@
</div>
</main>
</div>
<!-- Fixed-position, so where it sits in the DOM only decides what is
inert with it: inside the shell, it goes inert with the page. -->
<BackToTop scroller={main} />
</div>
<CommandPalette />
<BackToTop scroller={main} />
{/if}
<!-- An OVERLAY, not a replacement for the page.
+4 -3
View File
@@ -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>
+6 -5
View File
@@ -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>
+16 -9
View File
@@ -32,7 +32,11 @@
--card-foreground: 30 12% 12%;
--surface-2: 40 22% 95%;
--primary: 28 88% 42%;
/* Light-theme text tokens are dark enough for 4.5:1 as small text: on the
page, on cards, and on their own /12-/15 tints (badges, the active nav
item). At 42% the amber links and button labels measured 3.8-3.9:1.
Computed with the WCAG formula, not judged by eye. */
--primary: 28 88% 34%;
--primary-foreground: 40 60% 99%;
--secondary: 40 20% 94%;
--secondary-foreground: 30 14% 18%;
@@ -44,16 +48,19 @@
/* Meaning-bearing. These are NOT decoration and do not follow the accent:
review scores, safety flags and anti-cheat tiers all read through them,
and a reader has to be able to tell them apart at a glance. */
--destructive: 358 68% 47%;
--destructive: 358 68% 42%;
--destructive-foreground: 0 0% 100%;
--success: 152 58% 32%;
--warning: 36 92% 38%;
--info: 205 80% 40%;
--success: 152 58% 27%;
--warning: 36 92% 29%;
--info: 205 80% 35%;
--border: 38 18% 87%;
--border-strong: 36 16% 76%;
--input: 38 18% 87%;
--ring: 28 88% 42%;
/* The edge of a text box or a drop-down is what tells you it is one, so
it needs 3:1 against the page (it was 1.3:1, the same as --border).
--border stays light: card edges carry no meaning. */
--input: 36 12% 54%;
--ring: 28 88% 34%;
--radius: 0.5rem;
/* Scrollbars: a warm neutral thumb that warms towards the brand amber on
@@ -80,7 +87,7 @@
--accent: 30 10% 19%;
--accent-foreground: 40 20% 95%;
--destructive: 358 72% 62%;
--destructive: 358 72% 67%;
--destructive-foreground: 40 20% 96%;
--success: 152 56% 50%;
--warning: 38 94% 60%;
@@ -88,7 +95,7 @@
--border: 30 10% 19%;
--border-strong: 30 9% 29%;
--input: 30 10% 19%;
--input: 30 9% 40%;
--ring: 34 96% 58%;
--scrollbar-thumb: 30 9% 28%;