feat: accessibility statement, keyboard/screen-reader/chart/contrast fixes; 4.6.0 (#183) [skip-discuss]
Accessibility pass for the website and the apps (WCAG 2.2 AA target) and the accessibility statement: root ACCESSIBILITY.md + docs/i18n/vi/ACCESSIBILITY.md, the accessibility issue form, a default PR template; focus management, the '/' shortcut switch, chart names and data tables, contrast tokens with a CI check, Windows contrast themes; a docs sync of verified mismatches; version 4.6.0 with the two deps sweeps since 4.5.0 (#176, #182). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4046408157
commit
047d918d43
104 files changed
+2329
-348
No files matched your search
@@ -0,0 +1,103 @@
|
|||||||
|
name: ♿ Accessibility barrier
|
||||||
|
description: Something on the website or in the apps doesn't work with your keyboard, screen reader, zoom, contrast settings or other assistive technology
|
||||||
|
title: "[Accessibility] "
|
||||||
|
labels: ["accessibility"]
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
Thank you for taking the time to report this. Every report helps, even a partial one — describe what happened in your own words, and skip whatever you'd rather not share. Please don't include health information.
|
||||||
|
|
||||||
|
Prefer email, or don't have a GitHub account? Write to **contact@poli0981.dev** (English or Vietnamese). What happens next, and the response targets, are in [ACCESSIBILITY.md](https://github.com/poli0981/free-games-itchio-list/blob/main/ACCESSIBILITY.md#7-reporting-an-accessibility-barrier).
|
||||||
|
|
||||||
|
**Found a security vulnerability?** Please don't file it here: report it privately (see SECURITY.md).
|
||||||
|
|
||||||
|
- type: dropdown
|
||||||
|
id: where
|
||||||
|
attributes:
|
||||||
|
label: Where did it happen?
|
||||||
|
description: Pick all that apply.
|
||||||
|
multiple: true
|
||||||
|
options:
|
||||||
|
- Website (freeitchgames.win)
|
||||||
|
- Desktop app — Windows
|
||||||
|
- Desktop app — macOS
|
||||||
|
- Desktop app — Linux
|
||||||
|
- Android app
|
||||||
|
- Not sure
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: page
|
||||||
|
attributes:
|
||||||
|
label: Page or screen
|
||||||
|
description: The address of the page, or the screen in the app.
|
||||||
|
placeholder: e.g. https://freeitchgames.win/charts, or "the Games list in the Android app"
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: details
|
||||||
|
attributes:
|
||||||
|
label: What were you trying to do, and what happened?
|
||||||
|
description: What you expected, what happened instead, and the steps to get there if you can.
|
||||||
|
placeholder: |
|
||||||
|
e.g. I pressed Tab to reach the "Platform" filter, but focus jumped back to the top of the page.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: dropdown
|
||||||
|
id: kind
|
||||||
|
attributes:
|
||||||
|
label: What kind of barrier? (optional)
|
||||||
|
multiple: true
|
||||||
|
options:
|
||||||
|
- Keyboard (can't reach or use something, focus lost or hidden)
|
||||||
|
- Screen reader (missing or wrong name, nothing announced, wrong reading order)
|
||||||
|
- Zoom, text size or layout at large sizes
|
||||||
|
- Colour or contrast (including Windows contrast themes)
|
||||||
|
- Motion or animation
|
||||||
|
- Charts
|
||||||
|
- Language (read in the wrong language or voice)
|
||||||
|
- Speech input or switch access
|
||||||
|
- Something else
|
||||||
|
|
||||||
|
- type: dropdown
|
||||||
|
id: severity
|
||||||
|
attributes:
|
||||||
|
label: How much does it get in your way?
|
||||||
|
description: Just your best guess; it may change during triage.
|
||||||
|
options:
|
||||||
|
- Critical — I can't do a main task at all (find, open or read a game, change settings)
|
||||||
|
- Serious — I can, but only with great effort or a workaround
|
||||||
|
- Moderate — annoying or inconsistent, but I get there
|
||||||
|
- Minor — a small polish issue
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: assistive-tech
|
||||||
|
attributes:
|
||||||
|
label: Assistive technology and version (if any)
|
||||||
|
placeholder: e.g. Windows Narrator, NVDA 2026.1, VoiceOver on iOS 26, TalkBack, keyboard only, Windows contrast theme
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: environment
|
||||||
|
attributes:
|
||||||
|
label: Device, operating system, browser or app version
|
||||||
|
description: The app version is shown on the About page.
|
||||||
|
placeholder: e.g. Windows 11 + Edge 142; Android 15 + app 4.6.0
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: media
|
||||||
|
attributes:
|
||||||
|
label: Screenshot or recording (optional)
|
||||||
|
description: Paste or drag files here. Please hide any personal information.
|
||||||
|
|
||||||
|
- type: checkboxes
|
||||||
|
id: conduct
|
||||||
|
attributes:
|
||||||
|
label: Code of Conduct
|
||||||
|
description: By submitting this issue you agree to follow the project's [Code of Conduct](https://github.com/poli0981/free-games-itchio-list/blob/main/CODE_OF_CONDUCT.md).
|
||||||
|
options:
|
||||||
|
- label: I agree to follow the Code of Conduct.
|
||||||
|
required: true
|
||||||
@@ -10,6 +10,7 @@ body:
|
|||||||
|
|
||||||
**Found a security vulnerability?** Please don't file it here — report it privately via https://github.com/poli0981/free-games-itchio-list/security/advisories/new or security@poli0981.dev.
|
**Found a security vulnerability?** Please don't file it here — report it privately via https://github.com/poli0981/free-games-itchio-list/security/advisories/new or security@poli0981.dev.
|
||||||
Want a game removed (or you're its creator)? Use the "Remove a Game" template instead.
|
Want a game removed (or you're its creator)? Use the "Remove a Game" template instead.
|
||||||
|
Something doesn't work with your keyboard, screen reader, zoom or contrast settings? The "Accessibility barrier" template asks the right questions.
|
||||||
|
|
||||||
- type: dropdown
|
- type: dropdown
|
||||||
id: where
|
id: where
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
name: 🚫 Remove a Game (or copyright request)
|
name: 🚫 Remove a Game (or copyright request)
|
||||||
description: Ask to remove games from the catalog or correct their data, including requests from creators and rights holders (max 10 per issue)
|
description: Ask to remove games from the catalog or correct their data, including requests from creators and rights holders (max 10 per issue)
|
||||||
title: "[Remove Games] "
|
title: "[Remove Games] "
|
||||||
labels: ["removal"]
|
labels: ["delete-game"]
|
||||||
body:
|
body:
|
||||||
- type: markdown
|
- type: markdown
|
||||||
attributes:
|
attributes:
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ Closes # (link issue number if any)
|
|||||||
- [ ] Tested locally — Python: `pytest`, `ruff check scripts tests webapp/scripts`, `python scripts/validate.py`; webapp: `npm test`, `npm run lint`, `npx tsc -b`
|
- [ ] Tested locally — Python: `pytest`, `ruff check scripts tests webapp/scripts`, `python scripts/validate.py`; webapp: `npm test`, `npm run lint`, `npx tsc -b`
|
||||||
- [ ] No new bugs introduced (hopefully)
|
- [ ] No new bugs introduced (hopefully)
|
||||||
- [ ] No secrets, tokens or personal data in the diff
|
- [ ] No secrets, tokens or personal data in the diff
|
||||||
|
- [ ] Touched the UI? It still works with the keyboard alone and a screen reader ([checklist](https://github.com/poli0981/free-games-itchio-list/blob/main/ACCESSIBILITY.md#8-for-contributors))
|
||||||
- [ ] I agree my contribution is licensed under the MIT License (see `LICENSE`)
|
- [ ] I agree my contribution is licensed under the MIT License (see `LICENSE`)
|
||||||
- [ ] Followed the vibe (chill, no drama)
|
- [ ] Followed the vibe (chill, no drama)
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Not code or games? Fix my bad English, typos, or update legal docs — still sup
|
|||||||
|
|
||||||
### What did you update?
|
### What did you update?
|
||||||
- [ ] Fix typo/grammar in README/docs
|
- [ ] Fix typo/grammar in README/docs
|
||||||
- [ ] Update DISCLAIMER/PRIVACY/TERMS/EULA/SECURITY/etc.
|
- [ ] Update DISCLAIMER/PRIVACY/TERMS/EULA/SECURITY/ACCESSIBILITY/etc.
|
||||||
- [ ] Update the Vietnamese mirror (`README.vi.md`, `docs/i18n/vi/`)
|
- [ ] Update the Vietnamese mirror (`README.vi.md`, `docs/i18n/vi/`)
|
||||||
- [ ] Improve MY_STUFF or ACKNOWLEDGEMENTS
|
- [ ] Improve MY_STUFF or ACKNOWLEDGEMENTS
|
||||||
- [ ] Add badges/screenshots
|
- [ ] Add badges/screenshots
|
||||||
@@ -19,6 +19,7 @@ References # (if any)
|
|||||||
### Checklist
|
### Checklist
|
||||||
- [ ] No breaking changes
|
- [ ] No breaking changes
|
||||||
- [ ] Relative links still resolve; website links use `https://freeitchgames.win/<path>`
|
- [ ] Relative links still resolve; website links use `https://freeitchgames.win/<path>`
|
||||||
|
- [ ] Headings in order, link text that says where it goes, alt text for images, header cells in tables
|
||||||
- [ ] If I changed an English doc that has a Vietnamese mirror, I updated the mirror too (or said so above so someone else can)
|
- [ ] If I changed an English doc that has a Vietnamese mirror, I updated the mirror too (or said so above so someone else can)
|
||||||
- [ ] I agree my contribution is licensed under CC BY 4.0, like the rest of the documentation
|
- [ ] I agree my contribution is licensed under CC BY 4.0, like the rest of the documentation
|
||||||
- [ ] Keeps the self-deprecating vibe :D
|
- [ ] Keeps the self-deprecating vibe :D
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ References # (link if any)
|
|||||||
### Checklist
|
### Checklist
|
||||||
- [ ] Tested locally (Python: `pytest`, `ruff check scripts tests webapp/scripts`; webapp: `npm test`, `npm run lint`, `npm run knip`, `npx tsc -b`)
|
- [ ] Tested locally (Python: `pytest`, `ruff check scripts tests webapp/scripts`; webapp: `npm test`, `npm run lint`, `npm run knip`, `npx tsc -b`)
|
||||||
- [ ] Doesn't break the daily refresh or the ingest workflow
|
- [ ] Doesn't break the daily refresh or the ingest workflow
|
||||||
|
- [ ] UI changes pass the [accessibility checklist](https://github.com/poli0981/free-games-itchio-list/blob/main/ACCESSIBILITY.md#8-for-contributors): keyboard, focus, labels in `en.ts` + `vi.ts`, contrast (`npm test`), reduced motion, one screen-reader check
|
||||||
- [ ] New npm dependency? Added it to `webapp/src/lib/about.ts` so the About page lists it
|
- [ ] New npm dependency? Added it to `webapp/src/lib/about.ts` so the About page lists it
|
||||||
- [ ] Edited `webapp/wrangler.jsonc`? Ran `npm run cf:types`
|
- [ ] Edited `webapp/wrangler.jsonc`? Ran `npm run cf:types`
|
||||||
- [ ] I agree my contribution is licensed under the MIT License (see `LICENSE`)
|
- [ ] I agree my contribution is licensed under the MIT License (see `LICENSE`)
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<!--
|
||||||
|
Thanks for the PR! For a more specific checklist, add ?template=bug_fix.md (or new_features.md,
|
||||||
|
documentation.md, add_games.md) to this page's address — they live in .github/PULL_REQUEST_TEMPLATE/.
|
||||||
|
-->
|
||||||
|
|
||||||
|
### What and why
|
||||||
|
|
||||||
|
What does this change, and why?
|
||||||
|
|
||||||
|
### Related issues
|
||||||
|
|
||||||
|
Closes # (if any)
|
||||||
|
|
||||||
|
### Checklist
|
||||||
|
|
||||||
|
- [ ] Tested locally — Python: `pytest`, `ruff check scripts tests webapp/scripts`; webapp: `npm test`, `npm run lint`, `npm run knip`, `npx tsc -b`
|
||||||
|
- [ ] No secrets, tokens or personal data in the diff
|
||||||
|
- [ ] New UI text is in both `webapp/src/lib/i18n/en.ts` and `vi.ts`; a changed English doc has its Vietnamese mirror updated (or I said so above)
|
||||||
|
- [ ] I agree my contribution is licensed like the part it changes: MIT for code, CC BY 4.0 for data and docs
|
||||||
|
|
||||||
|
### Accessibility (UI or docs changes — see [ACCESSIBILITY.md](https://github.com/poli0981/free-games-itchio-list/blob/main/ACCESSIBILITY.md#8-for-contributors))
|
||||||
|
|
||||||
|
- [ ] N/A — no UI or docs change
|
||||||
|
- [ ] Works with the keyboard alone: everything reachable, focus visible and never lost
|
||||||
|
- [ ] Every control has a name; nothing relies on colour alone; `npm test` (contrast check) passes
|
||||||
|
- [ ] Respects reduced motion; no new auto-playing motion
|
||||||
|
- [ ] Checked once with a screen reader (Narrator, NVDA, VoiceOver or TalkBack)
|
||||||
|
- [ ] Docs: headings in order, descriptive link text, alt text for images
|
||||||
@@ -0,0 +1,195 @@
|
|||||||
|
# Accessibility
|
||||||
|
|
||||||
|
Last updated: 2026-11-09
|
||||||
|
|
||||||
|
Applies from: the release of version 4.6.0 (the website and the desktop and Android apps).
|
||||||
|
|
||||||
|
This is a hobby project run by one person, poli0981 (SkullMute), called "the Maintainer" below: a catalog of free itch.io games, on the website https://freeitchgames.win and in desktop and Android apps that show the same pages. Everyone should be able to use it, whether with a keyboard alone, a screen reader, zoom, a high-contrast theme, speech input or anything else. This statement says what works, how it is checked, what doesn't work yet, and how to tell the Maintainer when something gets in your way.
|
||||||
|
|
||||||
|
A Vietnamese translation is available at [`docs/i18n/vi/ACCESSIBILITY.md`](docs/i18n/vi/ACCESSIBILITY.md). If the two differ, this English version prevails.
|
||||||
|
|
||||||
|
> **TL;DR**
|
||||||
|
>
|
||||||
|
> - The goal is [WCAG 2.2](https://www.w3.org/TR/WCAG22/) Level AA for the website and the apps. That is a target, not a certificate: nobody outside the project has audited it.
|
||||||
|
> - Every page works with the keyboard alone and with a screen reader. The Maintainer tests with the keyboard only and Windows Narrator.
|
||||||
|
> - Colours meet the WCAG contrast ratios in the light and dark themes, and a test checks them on every change. Windows contrast themes are supported, and the site follows your system's "reduce motion" setting.
|
||||||
|
> - Every chart comes with a data table.
|
||||||
|
> - Known gaps are listed in [§6](#6-known-limitations).
|
||||||
|
> - Something in your way? Open an [accessibility issue](https://github.com/poli0981/free-games-itchio-list/issues/new?template=accessibility.yml) or email **contact@poli0981.dev**.
|
||||||
|
|
||||||
|
## 1. Scope
|
||||||
|
|
||||||
|
This statement covers:
|
||||||
|
|
||||||
|
- **the website** https://freeitchgames.win: every public page (Home, Games, the game pages, Charts, Removed, Suggest, Settings, About, the error pages) and the verification page shown before them;
|
||||||
|
- **the desktop apps** (Windows, macOS, Linux) **and the Android app**, which show the same pages in the system's web view.
|
||||||
|
|
||||||
|
It doesn't cover:
|
||||||
|
|
||||||
|
- the games themselves, their itch.io pages, and what their creators wrote or made (titles, descriptions, tags, cover images);
|
||||||
|
- Cloudflare Turnstile, the third-party check on the verification page and on the Suggest form (Cloudflare is responsible for its accessibility);
|
||||||
|
- the Maintainer's admin page, which has one user;
|
||||||
|
- other sites the pages link to, GitHub included.
|
||||||
|
|
||||||
|
## 2. Goals and priorities
|
||||||
|
|
||||||
|
- **Target**: [WCAG 2.2](https://www.w3.org/TR/WCAG22/) Level AA, as far as a one-person hobby project can get.
|
||||||
|
- **First**: the main tasks with a keyboard and a screen reader: find a game, read its details, open it on itch.io, change your settings, suggest a game.
|
||||||
|
- **Then**: readable text and controls (contrast, zoom, reflow), no motion you didn't ask for, and the right language for screen readers (English or Vietnamese).
|
||||||
|
- **Always**: new features keep all of this working (see [§8](#8-for-contributors)).
|
||||||
|
|
||||||
|
## 3. What works today
|
||||||
|
|
||||||
|
### Moving around
|
||||||
|
|
||||||
|
- "Skip to content" is the first thing the Tab key reaches.
|
||||||
|
- Each page has named landmarks (header, main navigation, search, main content, pager, footer), one level-1 heading, and its own title.
|
||||||
|
- After you follow a link inside the site, focus moves to the new page's heading, so a screen reader announces the page and Tab continues from there. Going back returns focus to the link you used, for example the game you opened from the list.
|
||||||
|
- The sticky header never covers what has keyboard focus.
|
||||||
|
|
||||||
|
### Keyboard
|
||||||
|
|
||||||
|
- Everything works with the keyboard alone: menus, filters, dialogs and charts.
|
||||||
|
- Focus is always visible: a purple outline, or the system highlight in a contrast theme.
|
||||||
|
- Dialogs keep focus inside while they are open and return it to where you were when they close.
|
||||||
|
- "/" jumps to the search box. You can switch this shortcut off in **Settings → Accessibility**, which helps with speech input or if the key clashes with your screen reader or your browser's quick find.
|
||||||
|
- When a control disappears after you use it (clearing a search, removing a filter), focus moves to the next sensible place instead of getting lost.
|
||||||
|
|
||||||
|
### Screen readers
|
||||||
|
|
||||||
|
- Every control has a name, in English or Vietnamese. Icons are hidden from screen readers.
|
||||||
|
- The number of results, search suggestions, loading states and form messages are announced.
|
||||||
|
- On wide screens the game list is a table with column headers; on phones it is a simple list.
|
||||||
|
- Links that open a new tab (in the apps: your browser) say so.
|
||||||
|
- Text in the other language, such as the language names and the English-only names of the legal documents, is marked with its language.
|
||||||
|
|
||||||
|
### Seeing the content
|
||||||
|
|
||||||
|
- Text and controls meet the WCAG 2.2 AA contrast ratios in both themes: 4.5:1 for text, 3:1 for field borders, the focus outline and chart colours. The test [`webapp/scripts/check-contrast.test.mjs`](webapp/scripts/check-contrast.test.mjs) checks the colours on every change.
|
||||||
|
- Light, dark or system theme, compact or normal rows, and hidden scrollbars: all in Settings.
|
||||||
|
- Windows contrast themes (forced colours): the selected tab, pressed toggles, the current page and switches use the system's highlight colours.
|
||||||
|
- Zoom is never blocked. At 400 % zoom or in a 320-pixel-wide window the phone layout takes over, and the page doesn't scroll sideways.
|
||||||
|
- Links inside sentences are underlined. Nothing is shown by colour alone: states also change the text, an outline or an underline.
|
||||||
|
|
||||||
|
### Motion
|
||||||
|
|
||||||
|
- With "reduce motion" switched on in your system, animations, chart entrances and smooth scrolling are off.
|
||||||
|
- On the website, covers are normally shown as still images (animated covers are turned into stills).
|
||||||
|
- Apart from loading placeholders, nothing moves on its own.
|
||||||
|
|
||||||
|
### Charts
|
||||||
|
|
||||||
|
- Each chart is named after its heading. Focus it and use the left and right arrow keys: the value you move to is read out.
|
||||||
|
- Under every chart, **Data table** opens the same numbers as a table, with each part's share for the pie charts.
|
||||||
|
|
||||||
|
### Language
|
||||||
|
|
||||||
|
- The pages are in English or Vietnamese (Settings), and the page language follows your choice, so screen readers pick the right voice. Numbers and dates follow it too.
|
||||||
|
|
||||||
|
## 4. How it is tested
|
||||||
|
|
||||||
|
- **By the Maintainer, by hand** (November 2026): the website on Windows 11 and the Windows desktop app, with the keyboard only (mouse switched off) and Windows Narrator. No blocking problems were found.
|
||||||
|
- **For 4.6.0**: the main pages and dialogs were walked through with the keyboard, and their accessibility tree was checked (names, roles, headings, landmarks, announcements) in English and Vietnamese, on a desktop and a phone-sized screen.
|
||||||
|
- **Automatically, on every change**: the contrast test above and the app's unit tests (where focus goes after a page change, the chart tables).
|
||||||
|
- **Before each release**: a short smoke test. That means a keyboard pass through the main tasks, a screen reader spot check, 200 % zoom and a narrow window, reduced motion, and a Windows contrast theme.
|
||||||
|
- **Not yet**: automated browser scans (such as axe or Lighthouse) in CI, and testing by people who use a wide range of assistive technology every day. Help is welcome.
|
||||||
|
|
||||||
|
## 5. Supported environments
|
||||||
|
|
||||||
|
| | Versions |
|
||||||
|
|---|---|
|
||||||
|
| Website | Current Chrome, Edge, Firefox and Safari on computers and phones. The oldest versions the site is built for are Chrome and Edge 111, Firefox 114, and Safari and iOS 15.4. |
|
||||||
|
| Desktop apps | Windows 10 and 11 (Microsoft Edge WebView2), macOS (WebKit 16.4 or newer), Linux (WebKitGTK 4.1) |
|
||||||
|
| Android app | Android 11 or newer |
|
||||||
|
|
||||||
|
Assistive technology:
|
||||||
|
|
||||||
|
- **Tested**: Windows Narrator on Windows 11, and keyboard-only use.
|
||||||
|
- **Expected to work, not regularly tested**: NVDA and JAWS on Windows, VoiceOver on macOS and iOS, TalkBack on Android, browser zoom, Windows contrast themes, speech input. They rely on the same standard markup.
|
||||||
|
- **Limited**: Orca in the Linux desktop app, because WebKitGTK supports screen readers less well than the browsers do.
|
||||||
|
|
||||||
|
## 6. Known limitations
|
||||||
|
|
||||||
|
- **Creators' text isn't marked with its language.** Game titles, descriptions and tags come from itch.io in many languages, and a screen reader reads them in the page's language.
|
||||||
|
- **Cover images have a generic description** ("Game name cover"). What the image shows isn't described.
|
||||||
|
- **Charts**: the arrow keys only move left and right. The genre treemap can't be stepped through, but its numbers are in its data table and in the Genres chart. Chart text has a fixed pixel size, so a larger default font size in your browser doesn't change it (page zoom does).
|
||||||
|
- **Desktop apps**: there are no zoom keys inside the app, the window can't be maximized, and it can't be made smaller than 900 × 600. If you need larger text, use your system's display scaling or the website in a browser.
|
||||||
|
- **Android app**: pinch-to-zoom is off. The website can be zoomed in your phone's browser.
|
||||||
|
- **Animated covers in the apps**: the apps load covers straight from itch.io, so an animated cover keeps playing there.
|
||||||
|
- **Cloudflare's checks**: the verification check (website only) and the anti-spam check on the Suggest form are Cloudflare Turnstile widgets. They usually pass without anything to do. If one ever asks for something you can't do, email the Maintainer.
|
||||||
|
- **GitHub pages**: the policies, this statement and the issue forms live on GitHub, so GitHub's own accessibility applies there.
|
||||||
|
- **No external audit**, and one maintainer.
|
||||||
|
|
||||||
|
## 7. Reporting an accessibility barrier
|
||||||
|
|
||||||
|
If something stops you or slows you down, please say so. Partial reports help too.
|
||||||
|
|
||||||
|
- **GitHub**: open an [Accessibility barrier issue](https://github.com/poli0981/free-games-itchio-list/issues/new?template=accessibility.yml).
|
||||||
|
- **Email**: **contact@poli0981.dev**. No GitHub account needed; English or Vietnamese both work.
|
||||||
|
|
||||||
|
Details that help, as far as you're comfortable sharing them (never send health information):
|
||||||
|
|
||||||
|
- what you were trying to do, and what happened instead;
|
||||||
|
- the page (its address) or the app and its version, shown on the About page;
|
||||||
|
- your device, operating system and browser;
|
||||||
|
- the assistive technology you use and its version, if any;
|
||||||
|
- a screenshot or a recording, if you can.
|
||||||
|
|
||||||
|
How much it gets in your way:
|
||||||
|
|
||||||
|
| Severity | Meaning |
|
||||||
|
|---|---|
|
||||||
|
| Critical | You can't do a main task at all, for example open a game or read its details. |
|
||||||
|
| Serious | You can, but only with great effort or a workaround. |
|
||||||
|
| Moderate | It's annoying or inconsistent, but you get there. |
|
||||||
|
| Minor | A small polish issue. |
|
||||||
|
|
||||||
|
What happens next. These are targets, not guarantees, since this is a solo hobby project:
|
||||||
|
|
||||||
|
- **Acknowledgement** within 7 days, often sooner.
|
||||||
|
- **A fix or a workaround**: Critical within 30 days, Serious within 60 days, Moderate and Minor in a later release.
|
||||||
|
- **Website fixes** go live when they are deployed; **app fixes** come with the next release.
|
||||||
|
- You'll be asked whether the fix works for you, and credited in the release notes if you want.
|
||||||
|
|
||||||
|
Security vulnerabilities don't belong in a public issue: see [SECURITY.md](SECURITY.md).
|
||||||
|
|
||||||
|
## 8. For contributors
|
||||||
|
|
||||||
|
Changes to the interface must keep [§3](#3-what-works-today) true:
|
||||||
|
|
||||||
|
- **Keyboard**: every control can be reached and used, focus stays visible and never gets lost.
|
||||||
|
- **Names**: every control has a label, with its text in both `webapp/src/lib/i18n/en.ts` and `vi.ts`.
|
||||||
|
- **Colour**: use the theme tokens. `npm test` checks contrast (4.5:1 for text, 3:1 for borders, focus and chart colours), and colour is never the only signal.
|
||||||
|
- **Motion**: respect `prefers-reduced-motion`; the shared CSS rule and `SERIES_ANIMATION` already do.
|
||||||
|
- **Screen reader**: check the change once with one (Narrator, NVDA, VoiceOver or TalkBack).
|
||||||
|
- **Markup**: prefer native elements and the Radix / shadcn components already in use, and add ARIA only when it's needed.
|
||||||
|
|
||||||
|
Documentation: headings in order, link text that says where it goes, alt text for images, header cells in tables, and the Vietnamese translation updated (or say in the pull request that it isn't).
|
||||||
|
|
||||||
|
The [pull request template](.github/pull_request_template.md) has the checklist.
|
||||||
|
|
||||||
|
## 9. Finding accessible games
|
||||||
|
|
||||||
|
The catalog shows the accessibility features that creators list on their itch.io pages, such as subtitles, configurable controls or colour-blind modes:
|
||||||
|
|
||||||
|
- on each game's page, under "Accessibility";
|
||||||
|
- as the Accessibility filter on the Games page, for example https://freeitchgames.win/games?access=Subtitles;
|
||||||
|
- in the "Accessibility Features" chart (Charts → Discovery).
|
||||||
|
|
||||||
|
Creators declare these features themselves, and the project doesn't verify them. If a game's information is wrong, report it with the "Bug Report" issue template.
|
||||||
|
|
||||||
|
## 10. References
|
||||||
|
|
||||||
|
- [Open Source Guides: Accessibility best practices for your project](https://opensource.guide/accessibility-best-practices-for-your-project/)
|
||||||
|
- [Open Source Accessibility toolkit](https://github.com/open-source-accessibility/accessibility-toolkit): this statement follows the outline of its ACCESSIBILITY.md example, in its own words.
|
||||||
|
- [Web Content Accessibility Guidelines (WCAG) 2.2](https://www.w3.org/TR/WCAG22/)
|
||||||
|
- [W3C: Developing an accessibility statement](https://www.w3.org/WAI/planning/statements/)
|
||||||
|
|
||||||
|
## 11. Contact
|
||||||
|
|
||||||
|
- **Accessibility barriers**: the [issue form](https://github.com/poli0981/free-games-itchio-list/issues/new?template=accessibility.yml) or **contact@poli0981.dev**.
|
||||||
|
- **Everything else**: see the addresses in [README → Legal](README.md#legal).
|
||||||
|
|
||||||
|
## 12. Final vibes
|
||||||
|
|
||||||
|
One person, one catalog, every way of browsing it. If something here doesn't work the way you use the web, the Maintainer would really like to hear it — that's how this list gets better. 🚀
|
||||||
+2
-1
@@ -3,12 +3,13 @@
|
|||||||
All notable changes to this project, newest first. The notes of each release live in
|
All notable changes to this project, newest first. The notes of each release live in
|
||||||
[`changelog/`](changelog/), one file per minor version: `changelog/<major>.x/ver<major>.<minor>.x.md`.
|
[`changelog/`](changelog/), one file per minor version: `changelog/<major>.x/ver<major>.<minor>.x.md`.
|
||||||
|
|
||||||
**Latest release: [4.5.0](changelog/4.x/ver4.5.x.md#450---2026-10-27-rate-limits-for-the-whole-site) (2026-10-27) — Rate limits for the whole site.**
|
**Latest release: [4.6.0](changelog/4.x/ver4.6.x.md#460---2026-11-09-accessibility) (2026-11-09) — Accessibility.**
|
||||||
|
|
||||||
## 4.x
|
## 4.x
|
||||||
|
|
||||||
| Version | Date | Highlights |
|
| Version | Date | Highlights |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
|
| [4.6.0](changelog/4.x/ver4.6.x.md#460---2026-11-09-accessibility) | 2026-11-09 | Accessibility: statement, keyboard and screen-reader fixes, chart data tables, WCAG contrast |
|
||||||
| [4.5.0](changelog/4.x/ver4.5.x.md#450---2026-10-27-rate-limits-for-the-whole-site) | 2026-10-27 | Rate limits for the whole site (HTTP 429), WAF guide |
|
| [4.5.0](changelog/4.x/ver4.5.x.md#450---2026-10-27-rate-limits-for-the-whole-site) | 2026-10-27 | Rate limits for the whole site (HTTP 429), WAF guide |
|
||||||
| [4.4.3](changelog/4.x/ver4.4.x.md#443---2026-10-26-dependency-and-security-updates) | 2026-10-26 | Dependency and security updates (build-tool advisories closed) |
|
| [4.4.3](changelog/4.x/ver4.4.x.md#443---2026-10-26-dependency-and-security-updates) | 2026-10-26 | Dependency and security updates (build-tool advisories closed) |
|
||||||
| [4.4.2](changelog/4.x/ver4.4.x.md#442---2026-10-22-toolchain-upgrade-code-scan-fixes) | 2026-10-22 | Toolchain upgrade (TypeScript 7, Node 26, Python 3.15), code-scan fixes |
|
| [4.4.2](changelog/4.x/ver4.4.x.md#442---2026-10-22-toolchain-upgrade-code-scan-fixes) | 2026-10-22 | Toolchain upgrade (TypeScript 7, Node 26, Python 3.15), code-scan fixes |
|
||||||
|
|||||||
@@ -60,14 +60,15 @@ Local admin without Access: put `DEV_ADMIN_EMAIL=you@example.com` in `webapp/.de
|
|||||||
- Cache: react-query persisted to IndexedDB (`webapp.query-cache`, 7 days) by `lib/data/persister.ts` — byte 0 = format (1 deflate-raw, 0 plain), then the JSON; a legacy string is dropped; writes throttled 1 s and skipped when no data object changed. Persisted: `db`, `deleted`, `count-history` and only the `desc` files the current catalog names (`shouldPersistQuery`); stale `desc` queries are removed after a `db` success. `CACHE_BUSTER = ${APP.version}:data-v2`. **`gcTime` must stay >= persist `maxAge`.**
|
- Cache: react-query persisted to IndexedDB (`webapp.query-cache`, 7 days) by `lib/data/persister.ts` — byte 0 = format (1 deflate-raw, 0 plain), then the JSON; a legacy string is dropped; writes throttled 1 s and skipped when no data object changed. Persisted: `db`, `deleted`, `count-history` and only the `desc` files the current catalog names (`shouldPersistQuery`); stale `desc` queries are removed after a `db` success. `CACHE_BUSTER = ${APP.version}:data-v2`. **`gcTime` must stay >= persist `maxAge`.**
|
||||||
- Layout: `components/site/*` (sticky top nav + global search with the `/` shortcut + display menu + phone sheet menu; footer) — the window scrolls, not `<main>`. `/` is the Welcome page (`routes/welcome.tsx`).
|
- Layout: `components/site/*` (sticky top nav + global search with the `/` shortcut + display menu + phone sheet menu; footer) — the window scrolls, not `<main>`. `/` is the Welcome page (`routes/welcome.tsx`).
|
||||||
- `/games`: search, filters, sort and page live in the URL — `lib/game-filters.ts` (`parseQuery` / `toParams` drop defaults; params `q genre platform status tag lang input engine ai access rating browser sort page`; `ai` treats "N/A" / a missing field as its own "Not disclosed" value and lists its options in a fixed order (`aiRank`); unit-tested) — rendered by `components/games/*` (filter chips with facet counts that ignore their own filter, a desktop ARIA table / phone list chosen by `useIsMobile`, 100 per page; the detail page's breadcrumb links back to the same list via router state). Counts show the whole catalog ("2,729 of 2,811") because 18+ games are hidden by default.
|
- `/games`: search, filters, sort and page live in the URL — `lib/game-filters.ts` (`parseQuery` / `toParams` drop defaults; params `q genre platform status tag lang input engine ai access rating browser sort page`; `ai` treats "N/A" / a missing field as its own "Not disclosed" value and lists its options in a fixed order (`aiRank`); unit-tested) — rendered by `components/games/*` (filter chips with facet counts that ignore their own filter, a desktop ARIA table / phone list chosen by `useIsMobile`, 100 per page; the detail page's breadcrumb links back to the same list via router state). Counts show the whole catalog ("2,729 of 2,811") because 18+ games are hidden by default.
|
||||||
- `components/charts/` (19 charts, 4 lazy tabs loaded with `lib/lazy-preload.ts` — preloaded when idle or on hover/focus, rendered without a Suspense fallback once loaded — and kept mounted once shown (gotcha 33; skeletons in `chart-skeletons.tsx` match the cards), every series spreading `SERIES_ANIMATION` (300 ms, no delay; a test checks), **no barrel `index.ts`**; every Recharts tooltip/cursor comes from `chart-theme.ts` + `chart-tooltip.tsx`, every pie legend from `LEGEND_BASE` there; below `md` the charts get 12 px legends / 11 px ticks from a media block in `index.css`, the tab bar is one row of equal tabs, and Languages / Avg session switch to horizontal bars via `useIsMobile`), `components/game-thumb.tsx` (`lib/thumbnail.ts` → `/img/160|640/...` on the web, the original URL in Tauri), `components/legal-gate.tsx` (a non-dismissable Radix dialog **over** the page, so deep links land where they pointed; links flagged `inGate` in `lib/about.ts`; re-prompts when `LEGAL_VERSION` in `stores/prefs.ts` changes; no "Leave" button in Tauri).
|
- `components/charts/` (19 charts, 4 lazy tabs loaded with `lib/lazy-preload.ts` — preloaded when idle or on hover/focus, rendered without a Suspense fallback once loaded — and kept mounted once shown (gotcha 33; skeletons in `chart-skeletons.tsx` match the cards), every series spreading `SERIES_ANIMATION` (300 ms, no delay; a test checks), **no barrel `index.ts`**; every Recharts tooltip/cursor comes from `chart-theme.ts` + `chart-tooltip.tsx`, every pie legend from `LEGEND_BASE` there; every chart container spreads `chartAria(id)` (named by its card's h2 + description + arrow-key hint), every `<Pie>` has `rootTabIndex={-1}`, every `ChartCard` gets an `id` and a `table` (a lazy `<details>` "Data table" built with `lib/chart-table.ts`), and the tooltip reads its text into the card's polite live region through `ChartAnnounce` (a ref, no re-render — gotcha 33); `chart-theme.test.ts` checks all four; below `md` the charts get 12 px legends / 11 px ticks from a media block in `index.css`, the tab bar is one row of equal tabs, and Languages / Avg session switch to horizontal bars via `useIsMobile`), `components/game-thumb.tsx` (`lib/thumbnail.ts` → `/img/160|640/...` on the web, the original URL in Tauri), `components/legal-gate.tsx` (a non-dismissable Radix dialog **over** the page, so deep links land where they pointed; links flagged `inGate` in `lib/about.ts`; re-prompts when `LEGAL_VERSION` in `stores/prefs.ts` changes; no "Leave" button in Tauri).
|
||||||
- Styling: **Tailwind v4** via `@tailwindcss/vite` (no PostCSS, no `tailwind.config`); tokens are hex CSS variables in `src/index.css` (`:root` / `.dark`, `@theme inline`; `--brand-soft`, `--thumb`, `--success`, `--scrollbar-thumb(-hover/-active)` besides the shadcn set) and must match the approved mockup. Themed scrollbars (`@layer base`, only under `(hover: hover) and (pointer: fine)`): `::-webkit-scrollbar*` for Chromium/Safari, `scrollbar-color` / `scrollbar-width: thin` for Firefox only (gotcha 28); "Hide scrollbars" = unlayered `html[data-scrollbars='hidden']` rules (`hooks/useScrollbarsEffect.ts`). On mouse devices `<html>` reserves the scrollbar gutter, released while a dialog locks scrolling (gotcha 35). The theme: `stores/theme.ts` (synced across tabs, site ↔ admin), `hooks/useThemeEffect.ts` (`.dark` + the `theme-color` metas), an inline pre-paint script in both HTML entries (gotcha 34), and the display menu's button shows `components/theme-icon.ts`'s icon for the theme in use. Self-hosted Geist / Geist Mono (`@fontsource-variable/*`, CSP `font-src 'self'`). Numbers and dates go through `lib/format.ts` (`useFormat`: en-GB / vi-VN). `webapp/scripts/gen_assets.py` redraws favicon, PWA icons and `og.png` from the same tokens and the Geist fonts in `node_modules`.
|
- Styling: **Tailwind v4** via `@tailwindcss/vite` (no PostCSS, no `tailwind.config`); tokens are hex CSS variables in `src/index.css` (`:root` / `.dark`, `@theme inline`; `--brand-soft`, `--thumb`, `--success`, `--scrollbar-thumb(-hover/-active)` besides the shadcn set) and must match the approved mockup — except where WCAG 2.2 AA needed more (4.6.0): `--primary` #6a48f5 (white text 5.44:1), `--primary-text` for purple text (#9a83ff in dark), `--input` #8a8a93 / #6b6b75 for field borders and the off switch (3:1), `--destructive-solid` for filled destructive buttons; `--brand` keeps the mockup's #7c5cff for the logo (as do the favicon, `og.png`, the app icons and the gate page's logo). `webapp/scripts/check-contrast.test.mjs` fails CI when a token pair or a chart colour (`components/charts/palette.ts`) drops below 4.5:1 (text) / 3:1 (borders, ring, chart marks); `lib/color.ts` does the maths. A `@media (forced-colors: active)` block gives selected tabs / pressed toggles / the current page / the active option and switches the system highlight (Windows contrast themes). Themed scrollbars (`@layer base`, only under `(hover: hover) and (pointer: fine) and (forced-colors: none)`): `::-webkit-scrollbar*` for Chromium/Safari, `scrollbar-color` / `scrollbar-width: thin` for Firefox only (gotcha 28); "Hide scrollbars" = unlayered `html[data-scrollbars='hidden']` rules (`hooks/useScrollbarsEffect.ts`). On mouse devices `<html>` reserves the scrollbar gutter, released while a dialog locks scrolling (gotcha 35). The theme: `stores/theme.ts` (synced across tabs, site ↔ admin), `hooks/useThemeEffect.ts` (`.dark` + the `theme-color` metas), an inline pre-paint script in both HTML entries (gotcha 34), and the display menu's button shows `components/theme-icon.ts`'s icon for the theme in use. Self-hosted Geist / Geist Mono (`@fontsource-variable/*`, CSP `font-src 'self'`). Numbers and dates go through `lib/format.ts` (`useFormat`: en-GB / vi-VN). `webapp/scripts/gen_assets.py` redraws favicon, PWA icons and `og.png` from the same tokens and the Geist fonts in `node_modules`.
|
||||||
- `lib/gate.ts` (web only): when a tab comes back into view or a cover fails and the verification pass may have run out (`webapp.gate` hint), it asks `GET /api/verify` and reloads into the verification page; `lib/reload.ts` is the shared at-most-every-30-s reload guard.
|
- `lib/gate.ts` (web only): when a tab comes back into view or a cover fails and the verification pass may have run out (`webapp.gate` hint), it asks `GET /api/verify` and reloads into the verification page; `lib/reload.ts` is the shared at-most-every-30-s reload guard.
|
||||||
- `hooks/useSeoHead.ts` sets canonical + robots per route (index.html has no static canonical/og:url on purpose).
|
- `hooks/useSeoHead.ts` sets canonical + robots per route (index.html has no static canonical/og:url on purpose).
|
||||||
|
- Accessibility (statement: root `ACCESSIBILITY.md`; target WCAG 2.2 AA): after an in-app navigation `App.tsx`'s ScrollManager moves focus to the new page's h1 (`lib/route-focus.ts` decides: not on first load or query-only changes; a #hash focuses its section; Back focuses the link last used on that entry), waiting for lazy routes with `components/focus-target.ts` (`whenPresent`, 10 s; `focusElement` adds `tabindex=-1` + `data-focus-target`, which hides the ring). Dialogs without a trigger return focus themselves (18+: the opener, `requestNsfw(returnFocus)`; legal gate: the page h1); menus that navigate `preventDefault` their `onCloseAutoFocus` (gotcha 46). The "/" shortcut is a pref (`slashShortcut`, Settings → Accessibility; WCAG 2.1.4). `CardTitle` renders an h2. `ExtLink` appends "(opens in a new tab)" / "(opens in your browser)" for screen readers. English-only strings shown on a Vietnamese page carry `lang="en"`; `<html lang>` turns `vi` only once the VI dictionary is in. `html { scroll-padding-top }` keeps focus clear of the sticky header. No a11y linter: `eslint-plugin-jsx-a11y` peers ESLint ≤ 9.
|
||||||
- `lib/i18n/` — `en.ts` is the source of truth; `vi.ts` is `Record<MessageKey, string>` and must never be static-imported (lazy chunk).
|
- `lib/i18n/` — `en.ts` is the source of truth; `vi.ts` is `Record<MessageKey, string>` and must never be static-imported (lazy chunk).
|
||||||
- `stores/` — Zustand: `prefs` (`webapp.prefs`: language, density, `hideScrollbars`, legal acceptance…), `theme` (`webapp.theme`).
|
- `stores/` — Zustand: `prefs` (`webapp.prefs`: language, density, `hideScrollbars`, legal acceptance…), `theme` (`webapp.theme`).
|
||||||
- `lib/about.ts` — keep `THIRD_PARTY` up to date when adding npm deps; `LEGAL_LINKS`; `APP.version`.
|
- `lib/about.ts` — keep `THIRD_PARTY` up to date when adding npm deps; `LEGAL_LINKS`; `APP.version`.
|
||||||
- Code split (`vite.config.ts` rolldown `codeSplitting.groups`): `vendor-react` (priority 100 — must claim React first), `vendor-query`, `vendor-ui`. There is deliberately **no vendor-charts group** (it pulled React/clsx in and put Recharts on the first load); Recharts stays in the lazy chart chunks. Initial load ≈ 179 KB gzip (JS + CSS, gzip -9; 4.2 added ~4.6 KB for the pack loader, persister and `useQueries`) plus ~51 KB of Geist woff2; catalog data on a first visit ≈ 264 KB (main packs + log + history), descriptions ≈ 170 KB on demand. `fflate` is a lazy chunk, never preloaded. Web build `target` is Safari/iOS 15.4 (Radix class static blocks otherwise break iOS 15); Tauri uses the default.
|
- Code split (`vite.config.ts` rolldown `codeSplitting.groups`): `vendor-react` (priority 100 — must claim React first), `vendor-query`, `vendor-ui`. There is deliberately **no vendor-charts group** (it pulled React/clsx in and put Recharts on the first load); Recharts stays in the lazy chart chunks. Initial load ≈ 189 KB gzip (JS + CSS, gzip -9, measured for 4.6.0; 4.2 added ~4.6 KB for the pack loader, persister and `useQueries`, 4.6 ~3 KB for focus management and the accessibility strings) plus ~51 KB of Geist woff2; catalog data on a first visit ≈ 264 KB (main packs + log + history), descriptions ≈ 170 KB on demand. `fflate` is a lazy chunk, never preloaded. Web build `target` is Safari/iOS 15.4 (Radix class static blocks otherwise break iOS 15); Tauri uses the default.
|
||||||
|
|
||||||
## Editable vs read-only fields
|
## Editable vs read-only fields
|
||||||
|
|
||||||
@@ -106,7 +107,7 @@ Draft-first: **never** `gh release create` by hand before CI — tauri-action v1
|
|||||||
|
|
||||||
## Licenses & policies
|
## Licenses & policies
|
||||||
|
|
||||||
Code **MIT** (`LICENSE`); catalog data **CC BY 4.0** for the maintainer's contribution — excluding creators' descriptions, cover images, names/trademarks (`data_game/LICENSE.md`, `LICENSES/CC-BY-4.0.txt`); docs **CC BY 4.0**; map + non-affiliation in `NOTICE.md`. Policies (EN in `docs/`, VI mirrors in `docs/i18n/vi/`, English controls): ToS (website + data + content removal), EULA (desktop/Android binaries only; also `webapp/src-tauri/installer/EULA.rtf`), Privacy Policy, Disclaimer, `SECURITY.md`, `CODE_OF_CONDUCT.md`. When a policy changes, bump `LEGAL_VERSION` (`webapp/src/stores/prefs.ts`) and the dates in `about.legal.desc` (EN/VI) so the legal gate asks again. Contact addresses `contact@ / legal@ / privacy@ / security@ / takedown@poli0981.dev` are aliases of the maintainer's Google Workspace mailbox (not Cloudflare Email Routing; the Privacy Policy lists Google as the email processor). The maintainer's site https://poli0981.dev/ and channel hub https://poli0981.dev/links/ are linked from the About page (`DEV` in `lib/about.ts`).
|
Code **MIT** (`LICENSE`); catalog data **CC BY 4.0** for the maintainer's contribution — excluding creators' descriptions, cover images, names/trademarks (`data_game/LICENSE.md`, `LICENSES/CC-BY-4.0.txt`); docs **CC BY 4.0**; map + non-affiliation in `NOTICE.md`. Policies (EN in `docs/`, VI mirrors in `docs/i18n/vi/`, English controls): ToS (website + data + content removal), EULA (desktop/Android binaries only; also `webapp/src-tauri/installer/EULA.rtf`), Privacy Policy, Disclaimer, `SECURITY.md`, `CODE_OF_CONDUCT.md`. `ACCESSIBILITY.md` (root: GitHub's accessibility community health file; VI mirror `docs/i18n/vi/ACCESSIBILITY.md`) is a statement, not a policy to accept — no `LEGAL_VERSION` bump when it changes, but keep its §3 (what works) and §6 (known limitations) in step with the code; barriers come in through `.github/ISSUE_TEMPLATE/accessibility.yml` (label `accessibility`) or contact@. When a policy changes, bump `LEGAL_VERSION` (`webapp/src/stores/prefs.ts`) and the dates in `about.legal.desc` (EN/VI) so the legal gate asks again. Contact addresses `contact@ / legal@ / privacy@ / security@ / takedown@poli0981.dev` are aliases of the maintainer's Google Workspace mailbox (not Cloudflare Email Routing; the Privacy Policy lists Google as the email processor). The maintainer's site https://poli0981.dev/ and channel hub https://poli0981.dev/links/ are linked from the About page (`DEV` in `lib/about.ts`).
|
||||||
|
|
||||||
## Known gotchas (cost a release each — don't relearn)
|
## Known gotchas (cost a release each — don't relearn)
|
||||||
|
|
||||||
@@ -154,6 +155,12 @@ Code **MIT** (`LICENSE`); catalog data **CC BY 4.0** for the maintainer's contri
|
|||||||
42. **miniflare (wrangler's local runtime) pins `undici` exactly, so Dependabot can't fix an undici alert** until a wrangler release moves the pin. The stopgap is `overrides.undici` in `webapp/package.json` (4.4.3–4.5.0 carried `^7.30.1` over wrangler 4.152's 7.29.1; dropped with wrangler 4.156, whose miniflare pins 7.30.1). Only miniflare uses undici; nothing of it reaches the site, the Worker or the apps. Remove such an override once `npm ls undici` without it shows the fixed version, and before miniflare moves to a new undici major (the override would hold it back).
|
42. **miniflare (wrangler's local runtime) pins `undici` exactly, so Dependabot can't fix an undici alert** until a wrangler release moves the pin. The stopgap is `overrides.undici` in `webapp/package.json` (4.4.3–4.5.0 carried `^7.30.1` over wrangler 4.152's 7.29.1; dropped with wrangler 4.156, whose miniflare pins 7.30.1). Only miniflare uses undici; nothing of it reaches the site, the Worker or the apps. Remove such an override once `npm ls undici` without it shows the fixed version, and before miniflare moves to a new undici major (the override would hold it back).
|
||||||
43. **The Workers rate-limit binding counts per machine, not per data centre.** Measured on production right after the 4.5.0 deploy (CDG): 1,000 requests in 53 s, each `curl` on a new connection, against `RL_SITE` 120/60 s → **no 429 at all**; 200 requests on **one** keep-alive connection → 93 × 200, then 429s. A data centre has many machines, each counts locally and syncs late, so a client that keeps one connection (browsers over HTTP/2, scripts with keep-alive) is held to the limit, while one that opens a new connection per request is spread across machines and barely counted. The zone's WAF rule counts across the data centre: it is the limit that holds against floods. Test the Worker limits over one connection (`curl URL URL …` in one invocation, or `--next`), never with `xargs curl`; under `wrangler dev` (miniflare: one process) every request counts. The WAF rule (300 / 10 s, set 2026-10-27) needs > 30 requests a second, which `xargs curl` doesn't reach from a home line: use the runbook's Node `fetch` one-liner (800 requests in 4.9 s → 111 × 200, 201 × Worker 429, 488 × WAF 1015).
|
43. **The Workers rate-limit binding counts per machine, not per data centre.** Measured on production right after the 4.5.0 deploy (CDG): 1,000 requests in 53 s, each `curl` on a new connection, against `RL_SITE` 120/60 s → **no 429 at all**; 200 requests on **one** keep-alive connection → 93 × 200, then 429s. A data centre has many machines, each counts locally and syncs late, so a client that keeps one connection (browsers over HTTP/2, scripts with keep-alive) is held to the limit, while one that opens a new connection per request is spread across machines and barely counted. The zone's WAF rule counts across the data centre: it is the limit that holds against floods. Test the Worker limits over one connection (`curl URL URL …` in one invocation, or `--next`), never with `xargs curl`; under `wrangler dev` (miniflare: one process) every request counts. The WAF rule (300 / 10 s, set 2026-10-27) needs > 30 requests a second, which `xargs curl` doesn't reach from a home line: use the runbook's Node `fetch` one-liner (800 requests in 4.9 s → 111 × 200, 201 × Worker 429, 488 × WAF 1015).
|
||||||
|
|
||||||
|
44. **Tailwind v4's `outline-hidden` adds a visible 2 px outline in forced-colours mode.** On a focus variant that is the point (inputs keep a system-coloured focus ring in Windows contrast themes); used unconditionally on a container (`<main tabIndex={-1}>`, the games list, popovers) it drew a permanent frame there. Containers use `outline-none`, fields `focus-visible:outline-hidden`.
|
||||||
|
45. **Vitest stubs CSS imports — `./index.css?raw` is an empty string in tests.** A test that reads a stylesheet lives in `webapp/scripts/*.test.mjs` and uses `node:fs` (`check-contrast.test.mjs`; `src/` has no Node types).
|
||||||
|
46. **Radix FocusScope gives focus back to the trigger in a `setTimeout` after unmount.** A link inside a menu or sheet that navigates would have focus pulled back to the menu button, away from the new page's h1: `SheetContent` / `PopoverContent` call `e.preventDefault()` in `onCloseAutoFocus` when the path changed. A modal opened without a Radix trigger (the 18+ dialog) drops focus to `<body>` unless `onCloseAutoFocus` focuses something. Radix 1.3.1 sets no `aria-modal` (it hides the rest with `aria-hidden`).
|
||||||
|
47. **Name Recharts charts with `aria-labelledby`, not their `title` prop** (`title` also shows a native browser tooltip over the whole chart); `Treemap`'s props type has no `role`. A custom tooltip loses Recharts' live region, and the tooltip box is `visibility: hidden` while inactive, so announcements go through the card (`ChartAnnounce`).
|
||||||
|
48. **The tool permissions refuse loading third-party code into the preview page** (an axe-core `<script>` from a CDN). Check pages with the browser's accessibility tree and DOM queries instead; Lighthouse / axe DevTools are for the owner's own browser.
|
||||||
|
|
||||||
## Safe-edit rules
|
## Safe-edit rules
|
||||||
|
|
||||||
- Don't write `data_game/` from new code paths directly — go through a patch + `apply_patch.py` (or the Worker's `repo.ts`), so concurrent writers never clobber each other and `validate.py` gates every commit.
|
- Don't write `data_game/` from new code paths directly — go through a patch + `apply_patch.py` (or the Worker's `repo.ts`), so concurrent writers never clobber each other and `validate.py` gates every commit.
|
||||||
@@ -163,7 +170,9 @@ Code **MIT** (`LICENSE`); catalog data **CC BY 4.0** for the maintainer's contri
|
|||||||
|
|
||||||
## Current state (Nov 2026)
|
## Current state (Nov 2026)
|
||||||
|
|
||||||
**Deps sweeps since v4.5.0** (not released — both go into the next release's notes; the catalog had 5,818 games on 2026-11-09). Each combines the week's Dependabot PRs plus what Dependabot didn't open (its 5-PR limit, pip / actions / cargo), with the 3-day cooldown applied by hand to every ecosystem (cargo and actions have none in `dependabot.yml`):
|
**v4.6.0** (2026-11-09): accessibility. Root `ACCESSIBILITY.md` + VI mirror (the owner had tested the website and the Windows app with the keyboard only and Windows Narrator; this release fixed what a WCAG 2.2 AA review found), the `accessibility.yml` issue form and labels `accessibility` / `feedback`, a default `.github/pull_request_template.md` (GitHub's community profile ignores `PULL_REQUEST_TEMPLATE/`). Code: focus management (route h1, Back to the used link, dialogs), the "/" shortcut switch, header search options / count, h2 card titles, `lang` marking, screen-reader text for counts / loading / new tabs, contrast tokens + `check-contrast.test.mjs`, forced-colours CSS, chart names / arrow-key announcements / data tables. Docs sync: dead `@freeitchgames.win` addresses in `data_game/LICENSE.md`, stale dates / VI revision notes / library versions, `check:tauri` in the check lists, the About page's removal link, `remove_game.yml` → label `delete-game`. Not done by choice: desktop zoom (`zoomHotkeysEnabled` off, `maximizable: false`, min 900×600 — a known limitation in the statement). No policy change (`LEGAL_VERSION` unchanged). Ships the two deps sweeps below.
|
||||||
|
|
||||||
|
**Deps sweeps since v4.5.0** (shipped in 4.6.0; the catalog had 5,818 games on 2026-11-09). Each combines the week's Dependabot PRs plus what Dependabot didn't open (its 5-PR limit, pip / actions / cargo), with the 3-day cooldown applied by hand to every ecosystem (cargo and actions have none in `dependabot.yml`):
|
||||||
- 2026-11-02, PR #176: Dependabot #171–#175 (react-router 8.5.1, TanStack Query 5.105.0, lucide-react 1.64.0, knip 6.44.0, typescript-eslint 8.72.1, wrangler 4.156.0 + regenerated types), jose 6.2.14, `overrides.undici` dropped (gotcha 42), pytest 9.2.0 / Ruff 0.17.3, sonarqube-scan-action 8.4.0, `cargo update`.
|
- 2026-11-02, PR #176: Dependabot #171–#175 (react-router 8.5.1, TanStack Query 5.105.0, lucide-react 1.64.0, knip 6.44.0, typescript-eslint 8.72.1, wrangler 4.156.0 + regenerated types), jose 6.2.14, `overrides.undici` dropped (gotcha 42), pytest 9.2.0 / Ruff 0.17.3, sonarqube-scan-action 8.4.0, `cargo update`.
|
||||||
- 2026-11-09, PR #182: Dependabot #177–#181 (TanStack Query 5.106.1, vitest 5.1.0, vite 8.3.6, @vitejs/plugin-react 6.2.1, Tailwind 4.3.4, eslint 10.14.0, knip 6.44.1, wrangler 4.158.0 + regenerated types, jose 6.2.15, globals 17.14.0), lucide-react 1.69.0, soupsieve 4.0.1 (a major whose breaking changes only touch `<template>` / `<iframe>` contents), coverage 7.17.2 / Ruff 0.17.4, setup-java 6.2.0, sonarqube-scan-action 8.4.1, `cargo update` (wasm-bindgen 0.2.130 family …). Node 26.13.0 (LTS) with its npm 11.20.0 is current.
|
- 2026-11-09, PR #182: Dependabot #177–#181 (TanStack Query 5.106.1, vitest 5.1.0, vite 8.3.6, @vitejs/plugin-react 6.2.1, Tailwind 4.3.4, eslint 10.14.0, knip 6.44.1, wrangler 4.158.0 + regenerated types, jose 6.2.15, globals 17.14.0), lucide-react 1.69.0, soupsieve 4.0.1 (a major whose breaking changes only touch `<template>` / `<iframe>` contents), coverage 7.17.2 / Ruff 0.17.4, setup-java 6.2.0, sonarqube-scan-action 8.4.1, `cargo update` (wasm-bindgen 0.2.130 family …). Node 26.13.0 (LTS) with its npm 11.20.0 is current.
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -41,6 +41,7 @@ Details live in the [Terms of Use](docs/ToS.md) and the [Disclaimer](docs/DISCLA
|
|||||||
- Checkboxes for common bugs (dead links, wrong flags, broken page, etc.).
|
- Checkboxes for common bugs (dead links, wrong flags, broken page, etc.).
|
||||||
- Details + screenshots + urgency level.
|
- Details + screenshots + urgency level.
|
||||||
- **Security problems are not bugs for the public tracker.** Report them privately: see [SECURITY.md](SECURITY.md).
|
- **Security problems are not bugs for the public tracker.** Report them privately: see [SECURITY.md](SECURITY.md).
|
||||||
|
- **Accessibility barriers** (keyboard, screen reader, zoom, contrast, motion…): use the **[Accessibility barrier]** template ([direct link](https://github.com/poli0981/free-games-itchio-list/issues/new?template=accessibility.yml)), or email contact@poli0981.dev if you'd rather not use GitHub. What happens next is in [ACCESSIBILITY.md](ACCESSIBILITY.md#7-reporting-an-accessibility-barrier).
|
||||||
- If it's complex, see "Discuss More" below.
|
- If it's complex, see "Discuss More" below.
|
||||||
|
|
||||||
### 4. Suggest Features or Improvements
|
### 4. Suggest Features or Improvements
|
||||||
@@ -67,14 +68,15 @@ Details live in the [Terms of Use](docs/ToS.md) and the [Disclaimer](docs/DISCLA
|
|||||||
|
|
||||||
**PR rules** (the non-negotiable part):
|
**PR rules** (the non-negotiable part):
|
||||||
|
|
||||||
- **CI must pass.** Python CI (ruff check + format, vulture, pytest, `validate.py`) and Webapp CI (type generation check, lint, knip, tests, build, `wrangler deploy --dry-run`) both run on PRs. Red CI = no merge. SonarQube Cloud also analyses each PR (with test coverage) and reports its quality gate as the "SonarCloud Code Analysis" check.
|
- **CI must pass.** Python CI (ruff check + format, vulture, pytest, `validate.py`) and Webapp CI (Tauri crate/npm version check, type generation check, lint, knip, tests, build, `wrangler deploy --dry-run`) both run on PRs. Red CI = no merge. SonarQube Cloud also analyses each PR (with test coverage) and reports its quality gate as the "SonarCloud Code Analysis" check.
|
||||||
- **PRs are merged with squash** (one PR becomes one commit on `main`) **or a merge commit, never by fast-forward**, so make the PR title a good commit message (the repo uses the `type(scope): summary` style, e.g. `fix(web): …`).
|
- **PRs are merged with squash** (one PR becomes one commit on `main`) **or a merge commit, never by fast-forward**, so make the PR title a good commit message (the repo uses the `type(scope): summary` style, e.g. `fix(web): …`).
|
||||||
- **Licensing is inbound = outbound.** By opening a PR you agree that your contribution is licensed under the same license as the part it changes: **MIT** for code, **CC BY 4.0** for catalog data and documentation (see [README → License](README.md#license)). Only submit work you have the right to submit.
|
- **Licensing is inbound = outbound.** By opening a PR you agree that your contribution is licensed under the same license as the part it changes: **MIT** for code, **CC BY 4.0** for catalog data and documentation (see [README → License](README.md#license)). Only submit work you have the right to submit.
|
||||||
- **Never commit secrets**: no tokens, API keys, `.dev.vars` / `.env` files, private keys (such as the GitHub App key) or signing keystores. If you pushed one by accident, report it privately (security@poli0981.dev) and rotate it; deleting the commit is not enough.
|
- **Never commit secrets**: no tokens, API keys, `.dev.vars` / `.env` files, private keys (such as the GitHub App key) or signing keystores. If you pushed one by accident, report it privately (security@poli0981.dev) and rotate it; deleting the commit is not enough.
|
||||||
- **Don't edit `data_game/` by hand.** Data changes go through the pipeline (a patch + `apply_patch.py`, which runs `validate.py`), so concurrent writers never clobber each other.
|
- **Don't edit `data_game/` by hand.** Data changes go through the pipeline (a patch + `apply_patch.py`, which runs `validate.py`), so concurrent writers never clobber each other.
|
||||||
- Don't commit build output or generated files: `webapp/dist/`, `webapp/.wrangler/`, `webapp/src-tauri/target/`, `webapp/src-tauri/gen/`. (`webapp/src-tauri/Cargo.lock` **is** committed; keep it in sync when you change `Cargo.toml`.)
|
- Don't commit build output or generated files: `webapp/dist/`, `webapp/.wrangler/`, `webapp/src-tauri/target/`, `webapp/src-tauri/gen/`. (`webapp/src-tauri/Cargo.lock` **is** committed; keep it in sync when you change `Cargo.toml`.)
|
||||||
- Adding an npm dependency? Also add it to the `THIRD_PARTY` list in `webapp/src/lib/about.ts` so the About page credits it.
|
- Adding an npm dependency? Also add it to the `THIRD_PARTY` list in `webapp/src/lib/about.ts` so the About page credits it.
|
||||||
- New external link in the app? Use `<ExtLink href="…">` from `webapp/src/components/ext-link.tsx`, not a plain `<a href="…" target="_blank">`: plain anchors work on the web but silently break in the Tauri apps.
|
- New external link in the app? Use `<ExtLink href="…">` from `webapp/src/components/ext-link.tsx`, not a plain `<a href="…" target="_blank">`: plain anchors work on the web but silently break in the Tauri apps (and ExtLink tells screen readers the link opens a new tab).
|
||||||
|
- **Accessibility**: UI changes keep working with the keyboard alone and with screen readers, and keep the contrast ratios (`npm test` checks the colours). The checklist is in [ACCESSIBILITY.md → For contributors](ACCESSIBILITY.md#8-for-contributors) and in the pull request template.
|
||||||
|
|
||||||
### 8. Dev Setup (Summary)
|
### 8. Dev Setup (Summary)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Notice
|
# Notice
|
||||||
|
|
||||||
Last updated: 2026-09-29
|
Last updated: 2026-10-16
|
||||||
|
|
||||||
Applies from: the release of version 4.0.0.
|
Applies from: the release of version 4.0.0.
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Free Itch.io Games List
|
# Free Itch.io Games List
|
||||||
|
|
||||||
[](https://github.com/poli0981/free-games-itchio-list/releases/latest)
|
[](https://github.com/poli0981/free-games-itchio-list/releases/latest)
|
||||||
[](https://freeitchgames.win)
|
[](https://freeitchgames.win)
|
||||||
[](https://github.com/poli0981/free-games-itchio-list/stargazers)
|
[](https://github.com/poli0981/free-games-itchio-list/stargazers)
|
||||||
[](https://github.com/poli0981/free-games-itchio-list/network/members)
|
[](https://github.com/poli0981/free-games-itchio-list/network/members)
|
||||||
@@ -45,6 +45,10 @@ Everything lives on the website, **<https://freeitchgames.win>**:
|
|||||||
- **18+ content is hidden by default.** Games flagged `nsfw: Yes` stay hidden (covers included) unless
|
- **18+ content is hidden by default.** Games flagged `nsfw: Yes` stay hidden (covers included) unless
|
||||||
you opt in under Settings after confirming you are 18 or older. That choice is stored only in your
|
you opt in under Settings after confirming you are 18 or older. That choice is stored only in your
|
||||||
browser.
|
browser.
|
||||||
|
- **Made for every way of browsing.** Everything works with the keyboard alone and with screen readers,
|
||||||
|
colours meet the WCAG contrast ratios in both themes, every chart has a data table, and the site
|
||||||
|
follows your system's reduced-motion and contrast settings. What works, the known gaps and how to
|
||||||
|
report a barrier: [ACCESSIBILITY.md](ACCESSIBILITY.md).
|
||||||
|
|
||||||
Every link goes to the game's own page on itch.io. Cover images on the website are resized copies served
|
Every link goes to the game's own page on itch.io. Cover images on the website are resized copies served
|
||||||
by freeitchgames.win, so your browser does not contact itch.io until you click a link.
|
by freeitchgames.win, so your browser does not contact itch.io until you click a link.
|
||||||
@@ -286,6 +290,8 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for the full guide.
|
|||||||
- **Remove a game / fix its data**: email takedown@poli0981.dev or open a
|
- **Remove a game / fix its data**: email takedown@poli0981.dev or open a
|
||||||
["Remove a game" issue](https://github.com/poli0981/free-games-itchio-list/issues/new?template=remove_game.yml).
|
["Remove a game" issue](https://github.com/poli0981/free-games-itchio-list/issues/new?template=remove_game.yml).
|
||||||
- **Report bugs**: use the "Bug Report" issue template.
|
- **Report bugs**: use the "Bug Report" issue template.
|
||||||
|
- **Accessibility barriers**: use the ["Accessibility barrier" issue template](https://github.com/poli0981/free-games-itchio-list/issues/new?template=accessibility.yml) or email
|
||||||
|
contact@poli0981.dev. See [ACCESSIBILITY.md](ACCESSIBILITY.md).
|
||||||
- **Request features**: use the "Feature Request / Improvement" template, or send a PR.
|
- **Request features**: use the "Feature Request / Improvement" template, or send a PR.
|
||||||
- **Security issues**: report them privately, never in a public issue. See [SECURITY.md](SECURITY.md).
|
- **Security issues**: report them privately, never in a public issue. See [SECURITY.md](SECURITY.md).
|
||||||
- **Privacy questions**: see the [Privacy Policy](docs/PrivacyPolicy.md) or email privacy@poli0981.dev.
|
- **Privacy questions**: see the [Privacy Policy](docs/PrivacyPolicy.md) or email privacy@poli0981.dev.
|
||||||
@@ -350,6 +356,7 @@ belong to their respective owners.
|
|||||||
- [EULA](docs/EULA.md): covers the desktop and Android apps only
|
- [EULA](docs/EULA.md): covers the desktop and Android apps only
|
||||||
- [Code of Conduct](CODE_OF_CONDUCT.md)
|
- [Code of Conduct](CODE_OF_CONDUCT.md)
|
||||||
- [Security Policy](SECURITY.md)
|
- [Security Policy](SECURITY.md)
|
||||||
|
- [Accessibility statement](ACCESSIBILITY.md): what works with assistive technology, known gaps, how to report a barrier
|
||||||
- [NOTICE](NOTICE.md)
|
- [NOTICE](NOTICE.md)
|
||||||
|
|
||||||
Contact (the Maintainer's own mailbox on poli0981.dev):
|
Contact (the Maintainer's own mailbox on poli0981.dev):
|
||||||
|
|||||||
+5
-2
@@ -1,6 +1,6 @@
|
|||||||
# Danh sách Game Itch.io Miễn Phí
|
# Danh sách Game Itch.io Miễn Phí
|
||||||
|
|
||||||
[](https://github.com/poli0981/free-games-itchio-list/releases/latest)
|
[](https://github.com/poli0981/free-games-itchio-list/releases/latest)
|
||||||
[](https://freeitchgames.win)
|
[](https://freeitchgames.win)
|
||||||
[](https://github.com/poli0981/free-games-itchio-list/stargazers)
|
[](https://github.com/poli0981/free-games-itchio-list/stargazers)
|
||||||
[](https://github.com/poli0981/free-games-itchio-list/network/members)
|
[](https://github.com/poli0981/free-games-itchio-list/network/members)
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
[](data_game/LICENSE.md)
|
[](data_game/LICENSE.md)
|
||||||
[](README.md)
|
[](README.md)
|
||||||
|
|
||||||
> Bản dịch từ bản tiếng Anh cập nhật ngày 2026-09-24 (English source revision 2026-09-24). Nếu có khác biệt, bản tiếng Anh được ưu tiên.
|
> Bản dịch từ bản tiếng Anh cập nhật ngày 2026-11-09 (English source revision 2026-11-09). Nếu có khác biệt, bản tiếng Anh được ưu tiên.
|
||||||
>
|
>
|
||||||
> Bản tiếng Anh tại [`README.md`](README.md) là bản chính thức. Bản dịch tiếng Việt của các tài liệu chính sách nằm trong [`docs/i18n/vi/`](docs/i18n/vi/).
|
> Bản tiếng Anh tại [`README.md`](README.md) là bản chính thức. Bản dịch tiếng Việt của các tài liệu chính sách nằm trong [`docs/i18n/vi/`](docs/i18n/vi/).
|
||||||
|
|
||||||
@@ -39,6 +39,7 @@ Mọi thứ nằm trên website **<https://freeitchgames.win>**:
|
|||||||
- **Đã gỡ** (Removed): mọi game bị loại khỏi danh mục, kèm lý do (<https://freeitchgames.win/removed>).
|
- **Đã gỡ** (Removed): mọi game bị loại khỏi danh mục, kèm lý do (<https://freeitchgames.win/removed>).
|
||||||
- **Kiểm tra nhanh trước.** Lần đầu vào, rồi khoảng mỗi 48 giờ, trang sẽ chạy một bước kiểm tra Cloudflare Turnstile ngắn để chặn bot. Thường nó tự qua rồi mở đúng trang bạn cần. Dữ liệu trong `/data` và các ứng dụng không cần bước này.
|
- **Kiểm tra nhanh trước.** Lần đầu vào, rồi khoảng mỗi 48 giờ, trang sẽ chạy một bước kiểm tra Cloudflare Turnstile ngắn để chặn bot. Thường nó tự qua rồi mở đúng trang bạn cần. Dữ liệu trong `/data` và các ứng dụng không cần bước này.
|
||||||
- **Nội dung 18+ bị ẩn theo mặc định.** Game được đánh dấu `nsfw: Yes` sẽ bị ẩn (kể cả ảnh bìa) trừ khi bạn tự bật trong Settings sau khi xác nhận mình đủ 18 tuổi. Lựa chọn đó chỉ được lưu trong trình duyệt của bạn.
|
- **Nội dung 18+ bị ẩn theo mặc định.** Game được đánh dấu `nsfw: Yes` sẽ bị ẩn (kể cả ảnh bìa) trừ khi bạn tự bật trong Settings sau khi xác nhận mình đủ 18 tuổi. Lựa chọn đó chỉ được lưu trong trình duyệt của bạn.
|
||||||
|
- **Dành cho mọi cách duyệt web.** Mọi thứ dùng được chỉ với bàn phím và với trình đọc màn hình, màu sắc đạt tỉ lệ tương phản WCAG ở cả hai giao diện, mỗi biểu đồ có bảng dữ liệu, và site làm theo thiết lập giảm chuyển động và tương phản của hệ thống. Những gì đã hỗ trợ, các hạn chế đã biết và cách báo rào cản: [Trợ năng](docs/i18n/vi/ACCESSIBILITY.md) ([EN](ACCESSIBILITY.md)).
|
||||||
|
|
||||||
Mọi link đều dẫn tới trang riêng của game trên itch.io. Ảnh bìa trên website là bản thu nhỏ do freeitchgames.win phục vụ, nên trình duyệt của bạn không kết nối tới itch.io cho tới khi bạn bấm vào một link.
|
Mọi link đều dẫn tới trang riêng của game trên itch.io. Ảnh bìa trên website là bản thu nhỏ do freeitchgames.win phục vụ, nên trình duyệt của bạn không kết nối tới itch.io cho tới khi bạn bấm vào một link.
|
||||||
|
|
||||||
@@ -221,6 +222,7 @@ Xem [CONTRIBUTING (tiếng Việt)](docs/i18n/vi/CONTRIBUTING.md) để có hư
|
|||||||
- **Thêm game**: dùng [trang Suggest](https://freeitchgames.win/suggest).
|
- **Thêm game**: dùng [trang Suggest](https://freeitchgames.win/suggest).
|
||||||
- **Gỡ game / sửa dữ liệu**: gửi email tới takedown@poli0981.dev hoặc mở issue ["Remove a game"](https://github.com/poli0981/free-games-itchio-list/issues/new?template=remove_game.yml).
|
- **Gỡ game / sửa dữ liệu**: gửi email tới takedown@poli0981.dev hoặc mở issue ["Remove a game"](https://github.com/poli0981/free-games-itchio-list/issues/new?template=remove_game.yml).
|
||||||
- **Báo lỗi**: dùng issue template "Bug Report".
|
- **Báo lỗi**: dùng issue template "Bug Report".
|
||||||
|
- **Rào cản trợ năng**: dùng [issue template "Accessibility barrier"](https://github.com/poli0981/free-games-itchio-list/issues/new?template=accessibility.yml) hoặc gửi email tới contact@poli0981.dev. Xem [Trợ năng](docs/i18n/vi/ACCESSIBILITY.md) ([EN](ACCESSIBILITY.md)).
|
||||||
- **Đề xuất tính năng**: dùng template "Feature Request / Improvement", hoặc gửi PR.
|
- **Đề xuất tính năng**: dùng template "Feature Request / Improvement", hoặc gửi PR.
|
||||||
- **Vấn đề bảo mật**: báo cáo riêng tư, đừng bao giờ mở issue công khai. Xem [SECURITY](docs/i18n/vi/SECURITY.md) ([EN](SECURITY.md)).
|
- **Vấn đề bảo mật**: báo cáo riêng tư, đừng bao giờ mở issue công khai. Xem [SECURITY](docs/i18n/vi/SECURITY.md) ([EN](SECURITY.md)).
|
||||||
- **Câu hỏi về quyền riêng tư**: xem [Chính sách quyền riêng tư](docs/i18n/vi/PrivacyPolicy.md) ([EN](docs/PrivacyPolicy.md)) hoặc gửi email tới privacy@poli0981.dev.
|
- **Câu hỏi về quyền riêng tư**: xem [Chính sách quyền riêng tư](docs/i18n/vi/PrivacyPolicy.md) ([EN](docs/PrivacyPolicy.md)) hoặc gửi email tới privacy@poli0981.dev.
|
||||||
@@ -277,6 +279,7 @@ Bản tiếng Việt nằm trong [`docs/i18n/vi/`](docs/i18n/vi/); bản tiếng
|
|||||||
- [EULA](docs/i18n/vi/EULA.md) ([EN](docs/EULA.md)): chỉ áp dụng cho app desktop và Android
|
- [EULA](docs/i18n/vi/EULA.md) ([EN](docs/EULA.md)): chỉ áp dụng cho app desktop và Android
|
||||||
- [Quy tắc ứng xử](docs/i18n/vi/CODE_OF_CONDUCT.md) ([EN](CODE_OF_CONDUCT.md))
|
- [Quy tắc ứng xử](docs/i18n/vi/CODE_OF_CONDUCT.md) ([EN](CODE_OF_CONDUCT.md))
|
||||||
- [Chính sách bảo mật (Security Policy)](docs/i18n/vi/SECURITY.md) ([EN](SECURITY.md))
|
- [Chính sách bảo mật (Security Policy)](docs/i18n/vi/SECURITY.md) ([EN](SECURITY.md))
|
||||||
|
- [Tuyên bố trợ năng (Accessibility)](docs/i18n/vi/ACCESSIBILITY.md) ([EN](ACCESSIBILITY.md)): những gì đã hỗ trợ cho công cụ trợ năng, các hạn chế đã biết, cách báo rào cản
|
||||||
- [NOTICE](NOTICE.md)
|
- [NOTICE](NOTICE.md)
|
||||||
|
|
||||||
Liên hệ (hộp thư riêng của Maintainer trên poli0981.dev):
|
Liên hệ (hộp thư riêng của Maintainer trên poli0981.dev):
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
# Security Policy
|
# Security Policy
|
||||||
|
|
||||||
Last updated: 2026-10-16
|
Last updated: 2026-10-27
|
||||||
|
|
||||||
Applies from: the release of version 4.0.0.
|
Applies from: the release of version 4.0.0.
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
# Changelog — 4.6.x
|
||||||
|
|
||||||
|
Release notes for 4.6.0, newest first. Every version: [CHANGELOG.md](../../CHANGELOG.md).
|
||||||
|
|
||||||
|
## [4.6.0] - 2026-11-09 (Accessibility)
|
||||||
|
|
||||||
|
The website and the apps work better with a keyboard, a screen reader, Windows contrast themes and
|
||||||
|
reduced motion, and the project now has an accessibility statement,
|
||||||
|
[ACCESSIBILITY.md](../../ACCESSIBILITY.md) (in Vietnamese:
|
||||||
|
[docs/i18n/vi/ACCESSIBILITY.md](../../docs/i18n/vi/ACCESSIBILITY.md)). It says what works, what
|
||||||
|
doesn't yet, and how to report a barrier. The Maintainer had already tested the website and the
|
||||||
|
Windows app with the keyboard only and Windows Narrator; this release fixes the gaps a review against
|
||||||
|
WCAG 2.2 AA found.
|
||||||
|
|
||||||
|
### Upgrade notes
|
||||||
|
|
||||||
|
- **Nothing to accept again**: no policy changed. The accessibility statement isn't a policy you
|
||||||
|
accept, so the first-visit notice doesn't come back.
|
||||||
|
- **A new setting**: **Settings → Accessibility** turns off the "/" shortcut that jumps to the search
|
||||||
|
box (useful with speech input, or when the key clashes with a screen reader or your browser's quick
|
||||||
|
find).
|
||||||
|
- **Colours**: buttons and purple text are a shade darker, form fields have darker borders, and the
|
||||||
|
selected tab, the current page and the highlighted search suggestion are marked with an outline, an
|
||||||
|
underline or a bar. This brings the contrast up to WCAG 2.2 AA. The logo and the app icons are
|
||||||
|
unchanged.
|
||||||
|
- **Desktop and Android apps**: install 4.6.0 over 4.5.0 as usual.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **Accessibility statement** ([ACCESSIBILITY.md](../../ACCESSIBILITY.md), EN + VI): the WCAG 2.2
|
||||||
|
AA target, what works, how it is tested, supported browsers and assistive technology, known
|
||||||
|
limitations, and how to report a barrier, with severity levels and response targets. It is
|
||||||
|
linked from the About page, the footer, Settings and the README.
|
||||||
|
- **Reporting a barrier**: an "Accessibility barrier" issue form (label `accessibility`), or email
|
||||||
|
contact@poli0981.dev, no GitHub account needed.
|
||||||
|
- **Charts you can read**: every chart is named after its heading, reads each value aloud as you
|
||||||
|
step through it with the left and right arrow keys, and has a **Data table** under it with the
|
||||||
|
same numbers (plus each part's share for pie charts).
|
||||||
|
- **Settings → Accessibility**: the "/" shortcut switch and a link to the statement.
|
||||||
|
- **A contrast check in CI**: a test fails if a colour token or a chart colour drops below the
|
||||||
|
WCAG 2.2 AA ratios.
|
||||||
|
- **A default pull request template** with an accessibility checklist.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- **Focus follows the page**: after you follow a link inside the site, focus moves to the new page's
|
||||||
|
heading, so a screen reader announces it and Tab continues from there. Back returns focus to the
|
||||||
|
link you used, for example the game you opened from the list. Links to a section (About →
|
||||||
|
Support) move focus there too.
|
||||||
|
- **Contrast**: white text on buttons goes from 4.35 to 5.44:1, purple text from 4.2 to 5.2:1 (6.6:1
|
||||||
|
in dark mode), field borders and the off position of switches reach 3:1. Chart colours reach 3:1 on
|
||||||
|
the light theme too, treemap labels pick a readable colour per cell, and axis labels are readable
|
||||||
|
in dark mode. The Online/Offline chart is blue and orange, which colour-blind readers can tell
|
||||||
|
apart.
|
||||||
|
- **Windows contrast themes**: the selected tab, pressed toggles, the current page, the active
|
||||||
|
search suggestion and switches use the system's highlight colours, and chart text follows the
|
||||||
|
system text colour.
|
||||||
|
- **Screen readers hear more**: the number of search suggestions, loading states, rating counts,
|
||||||
|
filter counts ("Genre, 2 selected"), the reason and date of each removed game, and that a link
|
||||||
|
opens a new tab (in the apps: your browser). Card titles on the About and Charts pages are real
|
||||||
|
headings, and the game-not-found page and the 18+ notice have their own page titles.
|
||||||
|
- **Language**: text in the other language (the language names, the English-only names of the legal
|
||||||
|
documents) is marked as such, the page's language switches to Vietnamese only once the Vietnamese
|
||||||
|
text has loaded, and the Suggest page's anti-spam check uses the site's language.
|
||||||
|
- **Search box**: "See all results" can be reached with the arrow keys.
|
||||||
|
- **Suggest form**: the game link is checked when you leave the field or send the form, not at the
|
||||||
|
first keystroke, and the Send button stays reachable and says what is missing.
|
||||||
|
- **First-visit notice**: "Accept & continue" can be reached with Tab before the box is ticked
|
||||||
|
(pressing it moves you to the box), and focus moves to the page once you accept.
|
||||||
|
- **Links inside sentences are underlined.**
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **The 18+ dialog lost keyboard focus when it closed**; focus now returns to the button or switch
|
||||||
|
that opened it.
|
||||||
|
- **The sticky header could cover the element that had keyboard focus.**
|
||||||
|
- **Focus was lost** when the control you used disappeared: clearing the search, removing a filter,
|
||||||
|
"Clear" in a filter menu, "back to top".
|
||||||
|
- **Reduced motion**: looping loading animations now stop and "back to top" no longer scrolls
|
||||||
|
smoothly when your system asks for less motion.
|
||||||
|
- **Short screens**: the 18+ dialog, the phone menu and the display menu scroll instead of being cut
|
||||||
|
off.
|
||||||
|
- **Docs**: the catalog data license still listed the @freeitchgames.win addresses retired in 4.1.1;
|
||||||
|
the About page's "Content removal" link opened the YAML source of the issue form; some "Last
|
||||||
|
updated" dates, translation notes and library versions were behind.
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
The two weekly updates since 4.5.0, which have been on the website since they were merged:
|
||||||
|
|
||||||
|
- **2026-11-02** (#176, Dependabot #171–#175 and a few more): React Router 8.5.1, TanStack Query
|
||||||
|
5.105.0, lucide-react 1.64.0, knip 6.44.0, typescript-eslint 8.72.1, wrangler 4.156.0 (its
|
||||||
|
generated Worker types refreshed), jose 6.2.14; the `undici` override dropped (wrangler's own
|
||||||
|
version now has the fix); pytest 9.2.0 and Ruff 0.17.3 for the pipeline;
|
||||||
|
`sonarqube-scan-action` 8.4.0; the Rust dependencies refreshed.
|
||||||
|
- **2026-11-09** (#182, Dependabot #177–#181 and a few more): TanStack Query 5.106.1, Vitest 5.1.0,
|
||||||
|
Vite 8.3.6, @vitejs/plugin-react 6.2.1, Tailwind CSS 4.3.4, ESLint 10.14.0, knip 6.44.1,
|
||||||
|
wrangler 4.158.0 (types refreshed), jose 6.2.15, globals 17.14.0, lucide-react 1.69.0;
|
||||||
|
soupsieve 4.0.1, coverage 7.17.2 and Ruff 0.17.4 for the pipeline; `actions/setup-java` 6.2.0 and
|
||||||
|
`sonarqube-scan-action` 8.4.1; the Rust dependencies refreshed (wasm-bindgen 0.2.130 and others).
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Catalog data license
|
# Catalog data license
|
||||||
|
|
||||||
Last updated: 2026-10-03
|
Last updated: 2026-11-09
|
||||||
|
|
||||||
Applies from: the release of version 4.0.0.
|
Applies from: the release of version 4.0.0.
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ a guarantee. The project does not scan downloads. See the [Disclaimer](../docs/D
|
|||||||
## 7. Corrections and removals
|
## 7. Corrections and removals
|
||||||
|
|
||||||
Game creators and rights holders can ask for a game to be removed or its data corrected. Email
|
Game creators and rights holders can ask for a game to be removed or its data corrected. Email
|
||||||
**takedown@freeitchgames.win** or open the
|
**takedown@poli0981.dev** or open the
|
||||||
["Remove a game" issue](https://github.com/poli0981/free-games-itchio-list/issues/new?template=remove_game.yml).
|
["Remove a game" issue](https://github.com/poli0981/free-games-itchio-list/issues/new?template=remove_game.yml).
|
||||||
Include the game URL, who you are (creator, rights holder, or someone acting for them) and the reason. The
|
Include the game URL, who you are (creator, rights holder, or someone acting for them) and the reason. The
|
||||||
full process is in the [Terms of Use](../docs/ToS.md).
|
full process is in the [Terms of Use](../docs/ToS.md).
|
||||||
@@ -134,4 +134,4 @@ to the Data from version 4.0.0 on.
|
|||||||
|
|
||||||
*This is a plain-language summary written by a hobby maintainer, not a lawyer, and it is not legal advice.
|
*This is a plain-language summary written by a hobby maintainer, not a lawyer, and it is not legal advice.
|
||||||
If this file and the CC BY 4.0 legal code disagree, the legal code wins. Questions:
|
If this file and the CC BY 4.0 legal code disagree, the legal code wins. Questions:
|
||||||
**legal@freeitchgames.win**.*
|
**legal@poli0981.dev**.*
|
||||||
+6
-6
@@ -1,6 +1,6 @@
|
|||||||
# Third-party components
|
# Third-party components
|
||||||
|
|
||||||
Last updated: 2026-10-03
|
Last updated: 2026-11-09
|
||||||
|
|
||||||
Applies from: the release of version 4.0.0.
|
Applies from: the release of version 4.0.0.
|
||||||
|
|
||||||
@@ -28,22 +28,22 @@ shared UI components).
|
|||||||
| Component | Version | Used for | License |
|
| Component | Version | Used for | License |
|
||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| [React](https://react.dev) (`react`, `react-dom`) | 19.3 | UI framework | MIT |
|
| [React](https://react.dev) (`react`, `react-dom`) | 19.3 | UI framework | MIT |
|
||||||
| [React Router](https://reactrouter.com) (`react-router`) | 8.4 | Routing | MIT |
|
| [React Router](https://reactrouter.com) (`react-router`) | 8.5 | Routing | MIT |
|
||||||
| [Zustand](https://github.com/pmndrs/zustand) | 5.0 | Preference and theme stores | MIT |
|
| [Zustand](https://github.com/pmndrs/zustand) | 5.0 | Preference and theme stores | MIT |
|
||||||
| [TanStack Query](https://tanstack.com/query) (`@tanstack/react-query`, `react-query-persist-client`) | 5.103 | Data fetching and the local catalog cache | MIT |
|
| [TanStack Query](https://tanstack.com/query) (`@tanstack/react-query`, `react-query-persist-client`) | 5.106 | Data fetching and the local catalog cache | MIT |
|
||||||
| [idb-keyval](https://github.com/jakearchibald/idb-keyval) | 6.3 | IndexedDB storage for the compressed catalog cache | Apache-2.0 |
|
| [idb-keyval](https://github.com/jakearchibald/idb-keyval) | 6.3 | IndexedDB storage for the compressed catalog cache | Apache-2.0 |
|
||||||
| [fflate](https://github.com/101arrowz/fflate) | 0.8 | Decompressing the catalog where the browser has no Compression Streams (older Safari / iOS) | MIT |
|
| [fflate](https://github.com/101arrowz/fflate) | 0.8 | Decompressing the catalog where the browser has no Compression Streams (older Safari / iOS) | MIT |
|
||||||
| [Recharts](https://recharts.org) | 3.10 | Charts | MIT |
|
| [Recharts](https://recharts.org) | 3.10 | Charts | MIT |
|
||||||
| [Radix UI](https://www.radix-ui.com) primitives (`@radix-ui/react-checkbox`, `-dialog`, `-label`, `-popover`, `-separator`, `-slot`, `-switch`, `-tabs`) | 1.x / 2.x | Accessible UI building blocks | MIT |
|
| [Radix UI](https://www.radix-ui.com) primitives (`@radix-ui/react-checkbox`, `-dialog`, `-label`, `-popover`, `-separator`, `-slot`, `-switch`, `-tabs`) | 1.x / 2.x | Accessible UI building blocks | MIT |
|
||||||
| [shadcn/ui](https://ui.shadcn.com) | pattern | Component patterns copied into `webapp/src/components/ui/` | MIT |
|
| [shadcn/ui](https://ui.shadcn.com) | pattern | Component patterns copied into `webapp/src/components/ui/` | MIT |
|
||||||
| [lucide-react](https://lucide.dev) | 1.47 | Icons | ISC |
|
| [lucide-react](https://lucide.dev) | 1.69 | Icons | ISC |
|
||||||
| [class-variance-authority](https://cva.style) | 0.7 | Component variants | Apache-2.0 |
|
| [class-variance-authority](https://cva.style) | 0.7 | Component variants | Apache-2.0 |
|
||||||
| [clsx](https://github.com/lukeed/clsx) | 2.1 | Class-name helper | MIT |
|
| [clsx](https://github.com/lukeed/clsx) | 2.1 | Class-name helper | MIT |
|
||||||
| [tailwind-merge](https://github.com/dcastil/tailwind-merge) | 3.7 | Class-name merging | MIT |
|
| [tailwind-merge](https://github.com/dcastil/tailwind-merge) | 3.7 | Class-name merging | MIT |
|
||||||
| [Tailwind CSS](https://tailwindcss.com) (`tailwindcss`, `@tailwindcss/vite`) and [tw-animate-css](https://github.com/Wombosvideo/tw-animate-css) | 4.3 / 1.4 | Generate the site's CSS at build time | MIT |
|
| [Tailwind CSS](https://tailwindcss.com) (`tailwindcss`, `@tailwindcss/vite`) and [tw-animate-css](https://github.com/Wombosvideo/tw-animate-css) | 4.3 / 1.4 | Generate the site's CSS at build time | MIT |
|
||||||
| [Geist and Geist Mono](https://vercel.com/font) (`@fontsource-variable/geist`, `@fontsource-variable/geist-mono`) | 5.3 | The site's typefaces | OFL-1.1 (fonts), MIT (Fontsource packaging) |
|
| [Geist and Geist Mono](https://vercel.com/font) (`@fontsource-variable/geist`, `@fontsource-variable/geist-mono`) | 5.3 | The site's typefaces | OFL-1.1 (fonts), MIT (Fontsource packaging) |
|
||||||
| [`@tauri-apps/api`](https://github.com/tauri-apps/tauri/tree/dev/packages/api) | 2.11 | App-only bridge to the native shell | Apache-2.0 OR MIT |
|
| [`@tauri-apps/api`](https://github.com/tauri-apps/tauri/tree/dev/packages/api) | 2.12 | App-only bridge to the native shell | Apache-2.0 OR MIT |
|
||||||
| [`@tauri-apps/plugin-opener`](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/opener) | 2.5 | App-only: opens itch.io links in the system browser | Apache-2.0 OR MIT |
|
| [`@tauri-apps/plugin-opener`](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/opener) | 2.7 | App-only: opens itch.io links in the system browser | Apache-2.0 OR MIT |
|
||||||
|
|
||||||
`@tanstack/react-query-devtools` (MIT) is listed as a dependency but only renders in development builds.
|
`@tanstack/react-query-devtools` (MIT) is listed as a dependency but only renders in development builds.
|
||||||
|
|
||||||
|
|||||||
@@ -173,6 +173,7 @@ the queue bookkeeping. Use it sparingly.
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
cd webapp
|
cd webapp
|
||||||
|
npm run check:tauri # Tauri crates and their npm packages share major.minor
|
||||||
npm run cf:types -- --check # worker-configuration.d.ts matches wrangler.jsonc
|
npm run cf:types -- --check # worker-configuration.d.ts matches wrangler.jsonc
|
||||||
npm run lint # ESLint
|
npm run lint # ESLint
|
||||||
npm run knip # unused files / exports / dependencies
|
npm run knip # unused files / exports / dependencies
|
||||||
|
|||||||
@@ -0,0 +1,195 @@
|
|||||||
|
# Trợ năng (Accessibility)
|
||||||
|
|
||||||
|
Cập nhật lần cuối: 2026-11-09
|
||||||
|
|
||||||
|
Áp dụng từ: khi phát hành phiên bản 4.6.0 (website và các ứng dụng desktop, Android).
|
||||||
|
|
||||||
|
> Bản dịch từ bản tiếng Anh cập nhật ngày 2026-11-09 (English source revision 2026-11-09). Nếu có khác biệt, bản tiếng Anh được ưu tiên. Bản gốc: [`ACCESSIBILITY.md`](../../../ACCESSIBILITY.md).
|
||||||
|
|
||||||
|
Đây là một dự án sở thích do một người vận hành, poli0981 (SkullMute), dưới đây gọi là "Người duy trì": một danh mục game itch.io miễn phí, có trên website https://freeitchgames.win và trong các ứng dụng desktop, Android hiển thị cùng các trang đó. Ai cũng nên dùng được, dù bạn chỉ dùng bàn phím, trình đọc màn hình, phóng to, giao diện tương phản cao, nhập liệu bằng giọng nói hay bất cứ công cụ nào khác. Tuyên bố này cho biết những gì đã hoạt động, cách kiểm tra, những gì chưa ổn, và cách báo cho Người duy trì khi có gì đó cản trở bạn.
|
||||||
|
|
||||||
|
> **Tóm tắt (TL;DR)**
|
||||||
|
>
|
||||||
|
> - Mục tiêu là [WCAG 2.2](https://www.w3.org/TR/WCAG22/) mức AA cho website và các ứng dụng. Đó là mục tiêu, không phải chứng nhận: chưa có ai ngoài dự án đánh giá.
|
||||||
|
> - Mọi trang đều dùng được chỉ với bàn phím và với trình đọc màn hình. Người duy trì kiểm tra bằng bàn phím (không dùng chuột) và Windows Narrator.
|
||||||
|
> - Màu sắc đạt tỉ lệ tương phản WCAG ở cả giao diện sáng và tối, và một bài test kiểm tra lại sau mỗi thay đổi. Hỗ trợ chế độ tương phản (Contrast themes) của Windows và làm theo thiết lập "giảm chuyển động" của hệ thống.
|
||||||
|
> - Mỗi biểu đồ đều có bảng dữ liệu đi kèm.
|
||||||
|
> - Các hạn chế đã biết nằm ở [§6](#6-các-hạn-chế-đã-biết).
|
||||||
|
> - Có gì cản trở bạn? Hãy mở một [issue trợ năng](https://github.com/poli0981/free-games-itchio-list/issues/new?template=accessibility.yml) hoặc email **contact@poli0981.dev**.
|
||||||
|
|
||||||
|
## 1. Phạm vi
|
||||||
|
|
||||||
|
Tuyên bố này áp dụng cho:
|
||||||
|
|
||||||
|
- **website** https://freeitchgames.win: mọi trang công khai (Trang chủ, Games, trang từng game, Charts, Removed, Suggest, Settings, About, các trang lỗi) và trang xác minh hiện ra trước đó;
|
||||||
|
- **các ứng dụng desktop** (Windows, macOS, Linux) **và ứng dụng Android**, vốn hiển thị cùng các trang trong web view của hệ thống.
|
||||||
|
|
||||||
|
Tuyên bố này không áp dụng cho:
|
||||||
|
|
||||||
|
- bản thân các game, trang itch.io của chúng, và những gì người tạo game viết hay làm ra (tên, mô tả, tag, ảnh bìa);
|
||||||
|
- Cloudflare Turnstile, bước kiểm tra của bên thứ ba trên trang xác minh và trên form Suggest (Cloudflare chịu trách nhiệm về trợ năng của nó);
|
||||||
|
- trang quản trị của Người duy trì, vốn chỉ có một người dùng;
|
||||||
|
- các trang web khác được liên kết tới, kể cả GitHub.
|
||||||
|
|
||||||
|
## 2. Mục tiêu và ưu tiên
|
||||||
|
|
||||||
|
- **Mục tiêu**: [WCAG 2.2](https://www.w3.org/TR/WCAG22/) mức AA, trong khả năng của một dự án sở thích do một người làm.
|
||||||
|
- **Trước hết**: các việc chính dùng được với bàn phím và trình đọc màn hình: tìm game, đọc thông tin, mở game trên itch.io, đổi cài đặt, gợi ý game.
|
||||||
|
- **Tiếp theo**: chữ và nút dễ đọc (tương phản, phóng to, dàn lại bố cục), không có chuyển động bạn không yêu cầu, và đúng ngôn ngữ cho trình đọc màn hình (tiếng Anh hoặc tiếng Việt).
|
||||||
|
- **Luôn luôn**: tính năng mới phải giữ được tất cả những điều trên (xem [§8](#8-dành-cho-người-đóng-góp)).
|
||||||
|
|
||||||
|
## 3. Những gì đã hoạt động
|
||||||
|
|
||||||
|
### Di chuyển trong trang
|
||||||
|
|
||||||
|
- "Chuyển đến nội dung" (Skip to content) là thứ đầu tiên phím Tab chạm tới.
|
||||||
|
- Mỗi trang có các vùng mốc (landmark) được đặt tên (đầu trang, menu chính, tìm kiếm, nội dung chính, phân trang, chân trang), một tiêu đề cấp 1 và tiêu đề trang riêng.
|
||||||
|
- Khi bạn bấm một liên kết bên trong site, focus chuyển tới tiêu đề của trang mới, nên trình đọc màn hình đọc tên trang và phím Tab đi tiếp từ đó. Khi quay lại, focus trở về liên kết bạn vừa dùng, ví dụ game bạn mở từ danh sách.
|
||||||
|
- Thanh đầu trang cố định không bao giờ che phần tử đang có focus bàn phím.
|
||||||
|
|
||||||
|
### Bàn phím
|
||||||
|
|
||||||
|
- Mọi thứ đều dùng được chỉ với bàn phím: menu, bộ lọc, hộp thoại và biểu đồ.
|
||||||
|
- Focus luôn nhìn thấy được: một đường viền tím, hoặc màu tô sáng của hệ thống trong chế độ tương phản.
|
||||||
|
- Hộp thoại giữ focus bên trong khi đang mở và trả focus về chỗ cũ khi đóng.
|
||||||
|
- Phím "/" đưa bạn tới ô tìm kiếm. Bạn có thể tắt phím tắt này trong **Settings → Trợ năng**, hữu ích khi nhập liệu bằng giọng nói hoặc khi phím này xung đột với trình đọc màn hình hay chức năng tìm nhanh của trình duyệt.
|
||||||
|
- Khi một nút biến mất sau khi bạn dùng nó (xoá ô tìm kiếm, bỏ một bộ lọc), focus chuyển tới chỗ hợp lý tiếp theo thay vì bị mất.
|
||||||
|
|
||||||
|
### Trình đọc màn hình
|
||||||
|
|
||||||
|
- Mọi nút điều khiển đều có tên, bằng tiếng Anh hoặc tiếng Việt. Biểu tượng được ẩn khỏi trình đọc màn hình.
|
||||||
|
- Số kết quả, gợi ý tìm kiếm, trạng thái đang tải và thông báo của form đều được đọc lên.
|
||||||
|
- Trên màn hình rộng, danh sách game là một bảng có tiêu đề cột; trên điện thoại là một danh sách đơn giản.
|
||||||
|
- Liên kết mở thẻ mới (trong ứng dụng: mở trình duyệt) đều nói rõ điều đó.
|
||||||
|
- Chữ thuộc ngôn ngữ kia, như tên các ngôn ngữ và tên tiếng Anh của các văn bản pháp lý, được đánh dấu đúng ngôn ngữ.
|
||||||
|
|
||||||
|
### Nhìn nội dung
|
||||||
|
|
||||||
|
- Chữ và nút đạt tỉ lệ tương phản WCAG 2.2 AA ở cả hai giao diện: 4.5:1 cho chữ, 3:1 cho viền ô nhập, đường viền focus và màu biểu đồ. Bài test [`webapp/scripts/check-contrast.test.mjs`](../../../webapp/scripts/check-contrast.test.mjs) kiểm tra màu sau mỗi thay đổi.
|
||||||
|
- Giao diện sáng, tối hoặc theo hệ thống; dòng gọn hoặc thường; ẩn thanh cuộn: tất cả nằm trong Settings.
|
||||||
|
- Chế độ tương phản của Windows (forced colors): tab đang chọn, nút bật/tắt đang bấm, trang hiện tại và các công tắc dùng màu tô sáng của hệ thống.
|
||||||
|
- Không bao giờ chặn phóng to. Ở mức phóng 400 % hoặc cửa sổ rộng 320 pixel, bố cục điện thoại được dùng và trang không phải cuộn ngang.
|
||||||
|
- Liên kết nằm trong câu đều được gạch chân. Không có gì chỉ dựa vào màu sắc: trạng thái luôn kèm thay đổi chữ, viền hoặc gạch chân.
|
||||||
|
|
||||||
|
### Chuyển động
|
||||||
|
|
||||||
|
- Khi bạn bật "giảm chuyển động" trong hệ thống, hiệu ứng, phần biểu đồ hiện ra và cuộn mượt đều tắt.
|
||||||
|
- Trên website, ảnh bìa thường được hiển thị dạng ảnh tĩnh (ảnh bìa động được chuyển thành ảnh tĩnh).
|
||||||
|
- Ngoài các khối giữ chỗ khi đang tải, không có gì tự chuyển động.
|
||||||
|
|
||||||
|
### Biểu đồ
|
||||||
|
|
||||||
|
- Mỗi biểu đồ được đặt tên theo tiêu đề của nó. Đưa focus vào biểu đồ rồi dùng phím mũi tên trái, phải: giá trị bạn chuyển tới sẽ được đọc lên.
|
||||||
|
- Dưới mỗi biểu đồ, **Bảng dữ liệu** mở cùng các số liệu dưới dạng bảng, kèm tỉ lệ từng phần với biểu đồ tròn.
|
||||||
|
|
||||||
|
### Ngôn ngữ
|
||||||
|
|
||||||
|
- Các trang có tiếng Anh và tiếng Việt (Settings), và ngôn ngữ của trang đi theo lựa chọn của bạn, nên trình đọc màn hình chọn đúng giọng đọc. Số và ngày tháng cũng theo ngôn ngữ đó.
|
||||||
|
|
||||||
|
## 4. Cách kiểm tra
|
||||||
|
|
||||||
|
- **Người duy trì kiểm tra thủ công** (tháng 11/2026): website trên Windows 11 và ứng dụng desktop Windows, chỉ dùng bàn phím (tắt chuột) và Windows Narrator. Không thấy lỗi nào chặn việc sử dụng.
|
||||||
|
- **Cho bản 4.6.0**: các trang chính và hộp thoại được đi hết bằng bàn phím, và cây trợ năng (accessibility tree) của chúng được kiểm tra (tên, vai trò, tiêu đề, vùng mốc, thông báo) bằng tiếng Anh và tiếng Việt, trên màn hình máy tính và màn hình cỡ điện thoại.
|
||||||
|
- **Tự động, sau mỗi thay đổi**: bài test tương phản ở trên và các unit test của ứng dụng (focus đi đâu sau khi đổi trang, bảng dữ liệu biểu đồ).
|
||||||
|
- **Trước mỗi lần phát hành**: một lượt kiểm tra nhanh. Gồm đi hết các việc chính bằng bàn phím, thử nhanh với trình đọc màn hình, phóng to 200 % và cửa sổ hẹp, giảm chuyển động, và một chế độ tương phản của Windows.
|
||||||
|
- **Chưa có**: quét tự động trên trình duyệt (như axe hay Lighthouse) trong CI, và việc kiểm tra bởi những người dùng hằng ngày nhiều công cụ hỗ trợ khác nhau. Mọi sự giúp đỡ đều được hoan nghênh.
|
||||||
|
|
||||||
|
## 5. Môi trường được hỗ trợ
|
||||||
|
|
||||||
|
| | Phiên bản |
|
||||||
|
|---|---|
|
||||||
|
| Website | Chrome, Edge, Firefox và Safari hiện hành trên máy tính và điện thoại. Các phiên bản cũ nhất mà site được build cho là Chrome và Edge 111, Firefox 114, Safari và iOS 15.4. |
|
||||||
|
| Ứng dụng desktop | Windows 10 và 11 (Microsoft Edge WebView2), macOS (WebKit 16.4 trở lên), Linux (WebKitGTK 4.1) |
|
||||||
|
| Ứng dụng Android | Android 11 trở lên |
|
||||||
|
|
||||||
|
Công cụ hỗ trợ (assistive technology):
|
||||||
|
|
||||||
|
- **Đã kiểm tra**: Windows Narrator trên Windows 11, và dùng chỉ bàn phím.
|
||||||
|
- **Dự kiến dùng được, chưa kiểm tra thường xuyên**: NVDA và JAWS trên Windows, VoiceOver trên macOS và iOS, TalkBack trên Android, phóng to của trình duyệt, chế độ tương phản của Windows, nhập liệu bằng giọng nói. Chúng dựa trên cùng mã HTML chuẩn.
|
||||||
|
- **Hạn chế**: Orca trong ứng dụng desktop Linux, vì WebKitGTK hỗ trợ trình đọc màn hình kém hơn các trình duyệt.
|
||||||
|
|
||||||
|
## 6. Các hạn chế đã biết
|
||||||
|
|
||||||
|
- **Chữ của người tạo game không được đánh dấu ngôn ngữ.** Tên, mô tả và tag của game lấy từ itch.io bằng nhiều ngôn ngữ, và trình đọc màn hình đọc chúng theo ngôn ngữ của trang.
|
||||||
|
- **Ảnh bìa chỉ có mô tả chung** ("Tên game cover"). Nội dung bức ảnh không được mô tả.
|
||||||
|
- **Biểu đồ**: phím mũi tên chỉ di chuyển trái và phải. Biểu đồ treemap thể loại không đi từng phần được, nhưng số liệu của nó có trong bảng dữ liệu và trong biểu đồ Genres. Chữ trong biểu đồ có cỡ pixel cố định, nên tăng cỡ chữ mặc định của trình duyệt không làm nó to lên (phóng to trang thì có).
|
||||||
|
- **Ứng dụng desktop**: không có phím phóng to bên trong ứng dụng, cửa sổ không phóng to toàn màn hình (maximize) được, và không thu nhỏ hơn 900 × 600. Nếu cần chữ lớn hơn, hãy dùng tỉ lệ hiển thị (display scaling) của hệ thống hoặc mở website trong trình duyệt.
|
||||||
|
- **Ứng dụng Android**: không phóng to bằng hai ngón tay được. Website trong trình duyệt điện thoại thì phóng to được.
|
||||||
|
- **Ảnh bìa động trong ứng dụng**: ứng dụng tải ảnh bìa trực tiếp từ itch.io, nên ảnh bìa động vẫn chạy ở đó.
|
||||||
|
- **Bước kiểm tra của Cloudflare**: bước xác minh (chỉ trên website) và bước chống spam của form Suggest là widget Cloudflare Turnstile. Thường chúng tự qua mà bạn không cần làm gì. Nếu có lúc chúng yêu cầu điều bạn không làm được, hãy email Người duy trì.
|
||||||
|
- **Trang trên GitHub**: các chính sách, tuyên bố này và các form issue nằm trên GitHub, nên trợ năng của chính GitHub áp dụng ở đó.
|
||||||
|
- **Chưa có đánh giá độc lập**, và chỉ có một người duy trì.
|
||||||
|
|
||||||
|
## 7. Báo cáo rào cản trợ năng
|
||||||
|
|
||||||
|
Nếu có gì ngăn bạn hoặc làm bạn chậm lại, hãy cho biết. Báo cáo chưa đầy đủ cũng có ích.
|
||||||
|
|
||||||
|
- **GitHub**: mở một [issue Accessibility barrier](https://github.com/poli0981/free-games-itchio-list/issues/new?template=accessibility.yml).
|
||||||
|
- **Email**: **contact@poli0981.dev**. Không cần tài khoản GitHub; viết tiếng Anh hay tiếng Việt đều được.
|
||||||
|
|
||||||
|
Những chi tiết có ích, trong chừng mực bạn thấy thoải mái chia sẻ (đừng bao giờ gửi thông tin sức khoẻ):
|
||||||
|
|
||||||
|
- bạn đang định làm gì, và điều gì đã xảy ra;
|
||||||
|
- trang (địa chỉ) hoặc ứng dụng và phiên bản của nó, xem trên trang About;
|
||||||
|
- thiết bị, hệ điều hành và trình duyệt;
|
||||||
|
- công cụ hỗ trợ bạn dùng và phiên bản, nếu có;
|
||||||
|
- ảnh chụp màn hình hoặc video, nếu được.
|
||||||
|
|
||||||
|
Mức độ ảnh hưởng:
|
||||||
|
|
||||||
|
| Mức độ | Ý nghĩa |
|
||||||
|
|---|---|
|
||||||
|
| Critical (nghiêm trọng nhất) | Bạn hoàn toàn không làm được một việc chính, ví dụ mở game hay đọc thông tin của nó. |
|
||||||
|
| Serious (nghiêm trọng) | Bạn làm được, nhưng rất vất vả hoặc phải đi đường vòng. |
|
||||||
|
| Moderate (trung bình) | Gây phiền hoặc không nhất quán, nhưng vẫn làm được. |
|
||||||
|
| Minor (nhỏ) | Một chi tiết nhỏ cần chỉnh. |
|
||||||
|
|
||||||
|
Điều gì xảy ra tiếp theo. Đây là mục tiêu, không phải cam kết, vì đây là dự án sở thích của một người:
|
||||||
|
|
||||||
|
- **Xác nhận đã nhận** trong vòng 7 ngày, thường sớm hơn.
|
||||||
|
- **Sửa lỗi hoặc đưa cách khắc phục tạm**: Critical trong 30 ngày, Serious trong 60 ngày, Moderate và Minor ở một bản phát hành sau.
|
||||||
|
- **Bản sửa cho website** có hiệu lực khi được deploy; **bản sửa cho ứng dụng** đi kèm bản phát hành tiếp theo.
|
||||||
|
- Bạn sẽ được hỏi bản sửa đã ổn với bạn chưa, và được ghi công trong release notes nếu muốn.
|
||||||
|
|
||||||
|
Lỗ hổng bảo mật không nên đưa vào issue công khai: xem [Chính sách bảo mật](SECURITY.md).
|
||||||
|
|
||||||
|
## 8. Dành cho người đóng góp
|
||||||
|
|
||||||
|
Thay đổi giao diện phải giữ đúng những điều ở [§3](#3-những-gì-đã-hoạt-động):
|
||||||
|
|
||||||
|
- **Bàn phím**: mọi nút đều tới được và dùng được, focus luôn nhìn thấy và không bị mất.
|
||||||
|
- **Tên**: mọi nút có nhãn, với chữ có trong cả `webapp/src/lib/i18n/en.ts` và `vi.ts`.
|
||||||
|
- **Màu sắc**: dùng các token của theme. `npm test` kiểm tra tương phản (4.5:1 cho chữ, 3:1 cho viền, focus và màu biểu đồ), và màu sắc không bao giờ là tín hiệu duy nhất.
|
||||||
|
- **Chuyển động**: tôn trọng `prefers-reduced-motion`; quy tắc CSS dùng chung và `SERIES_ANIMATION` đã làm việc đó.
|
||||||
|
- **Trình đọc màn hình**: kiểm tra thay đổi ít nhất một lần với một trình đọc (Narrator, NVDA, VoiceOver hoặc TalkBack).
|
||||||
|
- **Mã HTML**: ưu tiên phần tử gốc và các component Radix / shadcn đang dùng, chỉ thêm ARIA khi thật cần.
|
||||||
|
|
||||||
|
Tài liệu: tiêu đề theo đúng thứ tự, chữ của liên kết nói rõ nó dẫn tới đâu, ảnh có alt, bảng có ô tiêu đề, và bản tiếng Việt được cập nhật (hoặc ghi rõ trong pull request là chưa).
|
||||||
|
|
||||||
|
[Pull request template](../../../.github/pull_request_template.md) có sẵn danh sách kiểm tra.
|
||||||
|
|
||||||
|
## 9. Tìm game có hỗ trợ tiếp cận
|
||||||
|
|
||||||
|
Danh mục hiển thị các tính năng hỗ trợ tiếp cận mà người tạo game liệt kê trên trang itch.io của họ, như phụ đề, điều khiển tuỳ chỉnh được hay chế độ cho người mù màu:
|
||||||
|
|
||||||
|
- trên trang của từng game, ở mục "Hỗ trợ tiếp cận";
|
||||||
|
- trong bộ lọc Hỗ trợ tiếp cận ở trang Games, ví dụ https://freeitchgames.win/games?access=Subtitles;
|
||||||
|
- trong biểu đồ "Tính năng hỗ trợ tiếp cận" (Charts → Khám phá).
|
||||||
|
|
||||||
|
Người tạo game tự khai báo các tính năng này, và dự án không kiểm chứng. Nếu thông tin của một game sai, hãy báo bằng issue template "Bug Report".
|
||||||
|
|
||||||
|
## 10. Tài liệu tham khảo
|
||||||
|
|
||||||
|
- [Open Source Guides: Accessibility best practices for your project](https://opensource.guide/accessibility-best-practices-for-your-project/)
|
||||||
|
- [Open Source Accessibility toolkit](https://github.com/open-source-accessibility/accessibility-toolkit): tuyên bố này theo dàn ý của mẫu ACCESSIBILITY.md trong đó, với lời văn riêng.
|
||||||
|
- [Web Content Accessibility Guidelines (WCAG) 2.2](https://www.w3.org/TR/WCAG22/)
|
||||||
|
- [W3C: Developing an accessibility statement](https://www.w3.org/WAI/planning/statements/)
|
||||||
|
|
||||||
|
## 11. Liên hệ
|
||||||
|
|
||||||
|
- **Rào cản trợ năng**: [form issue](https://github.com/poli0981/free-games-itchio-list/issues/new?template=accessibility.yml) hoặc **contact@poli0981.dev**.
|
||||||
|
- **Mọi việc khác**: xem các địa chỉ trong [README → Pháp lý](../../../README.vi.md#pháp-lý).
|
||||||
|
|
||||||
|
## 12. Lời cuối
|
||||||
|
|
||||||
|
Một người, một danh mục, và mọi cách duyệt web. Nếu có gì ở đây không hợp với cách bạn dùng web, Người duy trì thật sự muốn được biết — đó là cách danh sách này ngày càng tốt hơn. 🚀
|
||||||
@@ -4,7 +4,7 @@ Cập nhật lần cuối: 2026-09-29
|
|||||||
|
|
||||||
Áp dụng từ: khi phát hành phiên bản 4.0.0.
|
Áp dụng từ: khi phát hành phiên bản 4.0.0.
|
||||||
|
|
||||||
> Bản dịch từ bản tiếng Anh cập nhật ngày 2026-09-18 (English source revision 2026-09-18). Nếu có khác biệt, bản tiếng Anh được ưu tiên. Bản gốc: [`CODE_OF_CONDUCT.md`](../../../CODE_OF_CONDUCT.md).
|
> Bản dịch từ bản tiếng Anh cập nhật ngày 2026-09-29 (English source revision 2026-09-29). Nếu có khác biệt, bản tiếng Anh được ưu tiên. Bản gốc: [`CODE_OF_CONDUCT.md`](../../../CODE_OF_CONDUCT.md).
|
||||||
|
|
||||||
Đây là một repo sở thích nhỏ về game itch.io miễn phí, do một dev noob đang thất nghiệp vận hành: poli0981 (SkullMute), dưới đây gọi là "Người duy trì". Nói đơn giản: hãy cư xử đàng hoàng. Người duy trì là introvert max level với kỹ năng xã hội bằng không, nên mình cùng giữ mọi thứ tích cực nhé.
|
Đây là một repo sở thích nhỏ về game itch.io miễn phí, do một dev noob đang thất nghiệp vận hành: poli0981 (SkullMute), dưới đây gọi là "Người duy trì". Nói đơn giản: hãy cư xử đàng hoàng. Người duy trì là introvert max level với kỹ năng xã hội bằng không, nên mình cùng giữ mọi thứ tích cực nhé.
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Hướng dẫn đóng góp
|
# Hướng dẫn đóng góp
|
||||||
|
|
||||||
> Bản dịch từ bản tiếng Anh cập nhật ngày 2026-10-13 (English source revision 2026-10-13). Nếu có khác biệt, bản tiếng Anh được ưu tiên.
|
> Bản dịch từ bản tiếng Anh cập nhật ngày 2026-11-09 (English source revision 2026-11-09). Nếu có khác biệt, bản tiếng Anh được ưu tiên.
|
||||||
>
|
>
|
||||||
> Bản tiếng Anh tại [`CONTRIBUTING.md`](../../../CONTRIBUTING.md) là bản chính thức.
|
> Bản tiếng Anh tại [`CONTRIBUTING.md`](../../../CONTRIBUTING.md) là bản chính thức.
|
||||||
|
|
||||||
@@ -45,6 +45,7 @@ Chi tiết có trong [Điều khoản sử dụng](ToS.md) và [Tuyên bố mi
|
|||||||
- Checkbox cho các lỗi thường gặp (link chết, cờ sai, trang hỏng, v.v.).
|
- Checkbox cho các lỗi thường gặp (link chết, cờ sai, trang hỏng, v.v.).
|
||||||
- Chi tiết + ảnh chụp màn hình + mức độ khẩn cấp.
|
- Chi tiết + ảnh chụp màn hình + mức độ khẩn cấp.
|
||||||
- **Vấn đề bảo mật không phải lỗi để đăng lên tracker công khai.** Hãy báo cáo riêng tư: xem [SECURITY](SECURITY.md).
|
- **Vấn đề bảo mật không phải lỗi để đăng lên tracker công khai.** Hãy báo cáo riêng tư: xem [SECURITY](SECURITY.md).
|
||||||
|
- **Rào cản trợ năng** (bàn phím, trình đọc màn hình, phóng to, tương phản, chuyển động…): dùng template **[Accessibility barrier]** ([link trực tiếp](https://github.com/poli0981/free-games-itchio-list/issues/new?template=accessibility.yml)), hoặc gửi email tới contact@poli0981.dev nếu bạn không muốn dùng GitHub. Điều gì xảy ra tiếp theo nằm trong [Trợ năng](ACCESSIBILITY.md#7-báo-cáo-rào-cản-trợ-năng).
|
||||||
- Nếu phức tạp, xem mục "Muốn thảo luận thêm?" bên dưới.
|
- Nếu phức tạp, xem mục "Muốn thảo luận thêm?" bên dưới.
|
||||||
|
|
||||||
### 4. Đề xuất tính năng / cải tiến
|
### 4. Đề xuất tính năng / cải tiến
|
||||||
@@ -71,14 +72,15 @@ Chi tiết có trong [Điều khoản sử dụng](ToS.md) và [Tuyên bố mi
|
|||||||
|
|
||||||
**Quy tắc PR** (phần không thương lượng):
|
**Quy tắc PR** (phần không thương lượng):
|
||||||
|
|
||||||
- **CI phải pass.** Python CI (ruff check + format, vulture, pytest, `validate.py`) và Webapp CI (kiểm tra type sinh ra, lint, knip, test, build, `wrangler deploy --dry-run`) đều chạy trên PR. CI đỏ = không merge. SonarQube Cloud cũng phân tích mỗi PR (kèm test coverage) và báo quality gate qua check "SonarCloud Code Analysis".
|
- **CI phải pass.** Python CI (ruff check + format, vulture, pytest, `validate.py`) và Webapp CI (kiểm tra phiên bản Tauri crate/npm, kiểm tra type sinh ra, lint, knip, test, build, `wrangler deploy --dry-run`) đều chạy trên PR. CI đỏ = không merge. SonarQube Cloud cũng phân tích mỗi PR (kèm test coverage) và báo quality gate qua check "SonarCloud Code Analysis".
|
||||||
- **PR được merge bằng squash** (một PR thành một commit trên `main`) **hoặc merge commit, không bao giờ fast-forward**, nên hãy đặt tiêu đề PR như một commit message tốt (repo dùng kiểu `type(scope): tóm tắt`, ví dụ `fix(web): …`).
|
- **PR được merge bằng squash** (một PR thành một commit trên `main`) **hoặc merge commit, không bao giờ fast-forward**, nên hãy đặt tiêu đề PR như một commit message tốt (repo dùng kiểu `type(scope): tóm tắt`, ví dụ `fix(web): …`).
|
||||||
- **Giấy phép theo nguyên tắc inbound = outbound.** Khi mở PR, bạn đồng ý rằng đóng góp của mình được cấp phép theo cùng giấy phép với phần mà nó thay đổi: **MIT** cho mã nguồn, **CC BY 4.0** cho dữ liệu danh mục và tài liệu (xem [README → Giấy phép](../../../README.vi.md#giấy-phép)). Chỉ gửi những gì bạn có quyền gửi.
|
- **Giấy phép theo nguyên tắc inbound = outbound.** Khi mở PR, bạn đồng ý rằng đóng góp của mình được cấp phép theo cùng giấy phép với phần mà nó thay đổi: **MIT** cho mã nguồn, **CC BY 4.0** cho dữ liệu danh mục và tài liệu (xem [README → Giấy phép](../../../README.vi.md#giấy-phép)). Chỉ gửi những gì bạn có quyền gửi.
|
||||||
- **Không bao giờ commit secret**: không token, API key, file `.dev.vars` / `.env`, private key (chẳng hạn khóa của GitHub App) hay keystore dùng để ký. Nếu lỡ push một cái, hãy báo riêng (security@poli0981.dev) và thay mới (rotate) nó; chỉ xóa commit là không đủ.
|
- **Không bao giờ commit secret**: không token, API key, file `.dev.vars` / `.env`, private key (chẳng hạn khóa của GitHub App) hay keystore dùng để ký. Nếu lỡ push một cái, hãy báo riêng (security@poli0981.dev) và thay mới (rotate) nó; chỉ xóa commit là không đủ.
|
||||||
- **Không sửa tay `data_game/`.** Thay đổi dữ liệu phải đi qua pipeline (một patch + `apply_patch.py`, có chạy `validate.py`), để các tiến trình ghi đồng thời không đè lên nhau.
|
- **Không sửa tay `data_game/`.** Thay đổi dữ liệu phải đi qua pipeline (một patch + `apply_patch.py`, có chạy `validate.py`), để các tiến trình ghi đồng thời không đè lên nhau.
|
||||||
- Không commit output build hay file sinh ra: `webapp/dist/`, `webapp/.wrangler/`, `webapp/src-tauri/target/`, `webapp/src-tauri/gen/`. (`webapp/src-tauri/Cargo.lock` **có** được commit; hãy cập nhật nó khi bạn sửa `Cargo.toml`.)
|
- Không commit output build hay file sinh ra: `webapp/dist/`, `webapp/.wrangler/`, `webapp/src-tauri/target/`, `webapp/src-tauri/gen/`. (`webapp/src-tauri/Cargo.lock` **có** được commit; hãy cập nhật nó khi bạn sửa `Cargo.toml`.)
|
||||||
- Thêm dependency npm? Thêm luôn vào danh sách `THIRD_PARTY` trong `webapp/src/lib/about.ts` để trang About ghi công.
|
- Thêm dependency npm? Thêm luôn vào danh sách `THIRD_PARTY` trong `webapp/src/lib/about.ts` để trang About ghi công.
|
||||||
- Link ngoài mới trong app? Dùng `<ExtLink href="…">` từ `webapp/src/components/ext-link.tsx`, đừng dùng `<a href="…" target="_blank">` thuần: anchor thuần chạy được trên web nhưng im lặng hỏng trong các app Tauri.
|
- Link ngoài mới trong app? Dùng `<ExtLink href="…">` từ `webapp/src/components/ext-link.tsx`, đừng dùng `<a href="…" target="_blank">` thuần: anchor thuần chạy được trên web nhưng im lặng hỏng trong các app Tauri (và ExtLink báo cho trình đọc màn hình rằng link mở thẻ mới).
|
||||||
|
- **Trợ năng**: thay đổi giao diện phải vẫn dùng được chỉ với bàn phím và với trình đọc màn hình, và giữ tỉ lệ tương phản (`npm test` kiểm tra màu). Danh sách kiểm tra nằm trong [Trợ năng → Dành cho người đóng góp](ACCESSIBILITY.md#8-dành-cho-người-đóng-góp) và trong pull request template.
|
||||||
|
|
||||||
### 8. Thiết lập môi trường dev (tóm tắt)
|
### 8. Thiết lập môi trường dev (tóm tắt)
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Cập nhật lần cuối: 2026-10-16
|
|||||||
|
|
||||||
Áp dụng từ: khi phát hành phiên bản 4.0.0.
|
Áp dụng từ: khi phát hành phiên bản 4.0.0.
|
||||||
|
|
||||||
> Bản dịch từ bản tiếng Anh cập nhật ngày 2026-10-13 (English source revision 2026-10-13). Nếu có khác biệt, bản tiếng Anh được ưu tiên. Bản gốc: [`docs/DISCLAIMER.md`](../../DISCLAIMER.md).
|
> Bản dịch từ bản tiếng Anh cập nhật ngày 2026-10-16 (English source revision 2026-10-16). Nếu có khác biệt, bản tiếng Anh được ưu tiên. Bản gốc: [`docs/DISCLAIMER.md`](../../DISCLAIMER.md).
|
||||||
|
|
||||||
Dự án này — repository `free-games-itchio-list` và website **[freeitchgames.win](https://freeitchgames.win)** — là một dự án sở thích: một danh mục được tuyển chọn và tự động cập nhật gồm các game miễn phí trên [itch.io](https://itch.io). Dự án do một dev người Việt đang thất nghiệp, poli0981 (SkullMute), vận hành — dưới đây gọi là "Người duy trì" — với các trợ lý AI gánh phần lớn việc nặng. Làm ra vì vibes, để khám phá game indie và giải khuây. Không hứa hẹn gì lớn lao — nhưng các điều khoản mang tính pháp lý dưới đây là thật.
|
Dự án này — repository `free-games-itchio-list` và website **[freeitchgames.win](https://freeitchgames.win)** — là một dự án sở thích: một danh mục được tuyển chọn và tự động cập nhật gồm các game miễn phí trên [itch.io](https://itch.io). Dự án do một dev người Việt đang thất nghiệp, poli0981 (SkullMute), vận hành — dưới đây gọi là "Người duy trì" — với các trợ lý AI gánh phần lớn việc nặng. Làm ra vì vibes, để khám phá game indie và giải khuây. Không hứa hẹn gì lớn lao — nhưng các điều khoản mang tính pháp lý dưới đây là thật.
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Cập nhật lần cuối: 2026-10-16
|
|||||||
|
|
||||||
Áp dụng từ: khi phát hành phiên bản 4.2.0.
|
Áp dụng từ: khi phát hành phiên bản 4.2.0.
|
||||||
|
|
||||||
Bản dịch từ bản tiếng Anh cập nhật ngày 2026-10-03 (English source revision 2026-10-03). Nếu có khác biệt, bản tiếng Anh được ưu tiên.
|
Bản dịch từ bản tiếng Anh cập nhật ngày 2026-10-16 (English source revision 2026-10-16). Nếu có khác biệt, bản tiếng Anh được ưu tiên.
|
||||||
|
|
||||||
> Bản tiếng Anh: [`docs/EULA.md`](../../EULA.md).
|
> Bản tiếng Anh: [`docs/EULA.md`](../../EULA.md).
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Cập nhật lần cuối: 2026-10-16
|
|||||||
|
|
||||||
Áp dụng từ: ngày 2026-10-13 đối với Website, và từ phiên bản 4.4.0 đối với các Ứng dụng.
|
Áp dụng từ: ngày 2026-10-13 đối với Website, và từ phiên bản 4.4.0 đối với các Ứng dụng.
|
||||||
|
|
||||||
> Bản dịch từ bản tiếng Anh cập nhật ngày 2026-10-13 (English source revision 2026-10-13). Nếu có khác biệt, bản tiếng Anh được ưu tiên. Bản gốc: [`docs/PrivacyPolicy.md`](../../PrivacyPolicy.md).
|
> Bản dịch từ bản tiếng Anh cập nhật ngày 2026-10-16 (English source revision 2026-10-16). Nếu có khác biệt, bản tiếng Anh được ưu tiên. Bản gốc: [`docs/PrivacyPolicy.md`](../../PrivacyPolicy.md).
|
||||||
|
|
||||||
Chính sách quyền riêng tư này giải thích dự án `free-games-itchio-list` xử lý những dữ liệu cá nhân nào, vì sao, ai hỗ trợ xử lý, dữ liệu được lưu trong bao lâu và bạn có những quyền gì. Chính sách áp dụng cho website **https://freeitchgames.win**, các ứng dụng desktop và Android, dữ liệu danh mục công khai và repository. Nói ngắn gọn: không có tài khoản, không quảng cáo, không cookie theo dõi. Dự án giữ ít dữ liệu nhất có thể, và phần lớn những gì tồn tại chỉ nằm trong trình duyệt của chính bạn.
|
Chính sách quyền riêng tư này giải thích dự án `free-games-itchio-list` xử lý những dữ liệu cá nhân nào, vì sao, ai hỗ trợ xử lý, dữ liệu được lưu trong bao lâu và bạn có những quyền gì. Chính sách áp dụng cho website **https://freeitchgames.win**, các ứng dụng desktop và Android, dữ liệu danh mục công khai và repository. Nói ngắn gọn: không có tài khoản, không quảng cáo, không cookie theo dõi. Dự án giữ ít dữ liệu nhất có thể, và phần lớn những gì tồn tại chỉ nằm trong trình duyệt của chính bạn.
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
# Chính sách bảo mật (Security Policy)
|
# Chính sách bảo mật (Security Policy)
|
||||||
|
|
||||||
Cập nhật lần cuối: 2026-10-16
|
Cập nhật lần cuối: 2026-10-27
|
||||||
|
|
||||||
Áp dụng từ: khi phát hành phiên bản 4.0.0.
|
Áp dụng từ: khi phát hành phiên bản 4.0.0.
|
||||||
|
|
||||||
> Bản dịch từ bản tiếng Anh cập nhật ngày 2026-09-18 (English source revision 2026-09-18). Nếu có khác biệt, bản tiếng Anh được ưu tiên. Bản gốc: [`SECURITY.md`](../../../SECURITY.md).
|
> Bản dịch từ bản tiếng Anh cập nhật ngày 2026-10-27 (English source revision 2026-10-27). Nếu có khác biệt, bản tiếng Anh được ưu tiên. Bản gốc: [`SECURITY.md`](../../../SECURITY.md).
|
||||||
|
|
||||||
Chào bạn — đây là một dự án sở thích do một người vận hành, poli0981 (SkullMute), dưới đây gọi là "Người duy trì": một danh mục được tuyển chọn gồm các game itch.io miễn phí. Từ v4, dự án gồm một **website chỉ đọc** tại https://freeitchgames.win (chạy trên một Cloudflare Worker), một **pipeline dữ liệu Python** trên GitHub Actions, và các **ứng dụng desktop và Android chỉ đọc**. Không có tài khoản công khai, không đăng nhập và không thanh toán; lần đăng nhập duy nhất là trang quản trị riêng của Người duy trì, được bảo vệ bởi Cloudflare Access. Bề mặt tấn công nhỏ — nhưng nếu bạn tìm thấy lỗ hổng, Người duy trì thực sự muốn được biết.
|
Chào bạn — đây là một dự án sở thích do một người vận hành, poli0981 (SkullMute), dưới đây gọi là "Người duy trì": một danh mục được tuyển chọn gồm các game itch.io miễn phí. Từ v4, dự án gồm một **website chỉ đọc** tại https://freeitchgames.win (chạy trên một Cloudflare Worker), một **pipeline dữ liệu Python** trên GitHub Actions, và các **ứng dụng desktop và Android chỉ đọc**. Không có tài khoản công khai, không đăng nhập và không thanh toán; lần đăng nhập duy nhất là trang quản trị riêng của Người duy trì, được bảo vệ bởi Cloudflare Access. Bề mặt tấn công nhỏ — nhưng nếu bạn tìm thấy lỗ hổng, Người duy trì thực sự muốn được biết.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ Cập nhật lần cuối: 2026-10-16
|
|||||||
|
|
||||||
Áp dụng từ: ngày 2026-10-13 đối với Website, và từ phiên bản 4.4.0 đối với các Ứng dụng.
|
Áp dụng từ: ngày 2026-10-13 đối với Website, và từ phiên bản 4.4.0 đối với các Ứng dụng.
|
||||||
|
|
||||||
Bản dịch từ bản tiếng Anh cập nhật ngày 2026-10-13 (English source revision 2026-10-13). Nếu có khác biệt, bản tiếng Anh được ưu tiên.
|
Bản dịch từ bản tiếng Anh cập nhật ngày 2026-10-16 (English source revision 2026-10-16). Nếu có khác biệt, bản tiếng Anh được ưu tiên.
|
||||||
|
|
||||||
Bản tiếng Anh: [`docs/ToS.md`](../../ToS.md).
|
Bản tiếng Anh: [`docs/ToS.md`](../../ToS.md).
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Môi trường phát triển
|
# Môi trường phát triển
|
||||||
|
|
||||||
> Bản dịch từ bản tiếng Anh cập nhật ngày 2026-09-24 (English source revision 2026-09-24). Nếu có khác biệt, bản tiếng Anh được ưu tiên.
|
> Bản dịch từ bản tiếng Anh cập nhật ngày 2026-11-09 (English source revision 2026-11-09). Nếu có khác biệt, bản tiếng Anh được ưu tiên.
|
||||||
> Bản gốc: [`dev_env.md`](../../dev_env.md).
|
> Bản gốc: [`dev_env.md`](../../dev_env.md).
|
||||||
|
|
||||||
Bộ công cụ Maintainer dùng để viết và kiểm thử code trong repo này, và cách chạy từng phần trên máy.
|
Bộ công cụ Maintainer dùng để viết và kiểm thử code trong repo này, và cách chạy từng phần trên máy.
|
||||||
@@ -174,6 +174,7 @@ các việc bảo trì queue. Hãy dùng hạn chế.
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
cd webapp
|
cd webapp
|
||||||
|
npm run check:tauri # crate Tauri và package npm tương ứng cùng major.minor
|
||||||
npm run cf:types -- --check # worker-configuration.d.ts khớp với wrangler.jsonc
|
npm run cf:types -- --check # worker-configuration.d.ts khớp với wrangler.jsonc
|
||||||
npm run lint # ESLint
|
npm run lint # ESLint
|
||||||
npm run knip # file / export / dependency không dùng
|
npm run knip # file / export / dependency không dùng
|
||||||
|
|||||||
+9
-4
@@ -214,14 +214,19 @@ Do these once (and again with the `-staging` names for the staging Worker).
|
|||||||
`webapp/src-tauri/tauri.conf.json`, `webapp/src-tauri/Cargo.toml` + `Cargo.lock`, and the version
|
`webapp/src-tauri/tauri.conf.json`, `webapp/src-tauri/Cargo.toml` + `Cargo.lock`, and the version
|
||||||
badges of `README.md` / `README.vi.md`. Write the notes in
|
badges of `README.md` / `README.vi.md`. Write the notes in
|
||||||
`changelog/<major>.x/ver<major>.<minor>.x.md` and add the row to [`CHANGELOG.md`](../CHANGELOG.md).
|
`changelog/<major>.x/ver<major>.<minor>.x.md` and add the row to [`CHANGELOG.md`](../CHANGELOG.md).
|
||||||
2. Open a PR; when CI is green, merge it with squash or a merge commit — never fast-forward. A push
|
2. Run the accessibility smoke test ([`ACCESSIBILITY.md`](../ACCESSIBILITY.md) §4) on the preview or the
|
||||||
|
merged site: the main tasks with the keyboard only, a screen reader spot check (Narrator, NVDA or
|
||||||
|
VoiceOver), 200 % zoom and a narrow window, reduced motion, and a Windows contrast theme. If a
|
||||||
|
change made a known limitation go away (or added one), update §6 of the statement and its
|
||||||
|
Vietnamese mirror.
|
||||||
|
3. Open a PR; when CI is green, merge it with squash or a merge commit — never fast-forward. A push
|
||||||
that touches the changelog posts to Discussions → General unless the head commit says
|
that touches the changelog posts to Discussions → General unless the head commit says
|
||||||
`[skip-discuss]` (the release announcement usually covers it).
|
`[skip-discuss]` (the release announcement usually covers it).
|
||||||
3. Apply any new D1 migration and set any new secret **before** the merge deploys code that needs them.
|
4. Apply any new D1 migration and set any new secret **before** the merge deploys code that needs them.
|
||||||
4. Tag from `main`: `git fetch origin && git tag -s vX.Y.Z origin/main -m "…"`, then
|
5. Tag from `main`: `git fetch origin && git tag -s vX.Y.Z origin/main -m "…"`, then
|
||||||
`git push origin vX.Y.Z`. `release_desktop.yml` opens one draft release and the desktop and Android
|
`git push origin vX.Y.Z`. `release_desktop.yml` opens one draft release and the desktop and Android
|
||||||
jobs upload into it (12 assets for 4.x). Never create the release by hand first.
|
jobs upload into it (12 assets for 4.x). Never create the release by hand first.
|
||||||
5. When every asset is there, edit the title and notes (from the changelog), then
|
6. When every asset is there, edit the title and notes (from the changelog), then
|
||||||
`gh release edit vX.Y.Z --draft=false` — that fires the Discord and Discussions announcements.
|
`gh release edit vX.Y.Z --draft=false` — that fires the Discord and Discussions announcements.
|
||||||
|
|
||||||
## 4. Routine
|
## 4. Routine
|
||||||
|
|||||||
+3
-2
@@ -28,7 +28,7 @@ key entries) and rewrites old `#/…` links to real paths ([`src/lib/legacy.ts`]
|
|||||||
| [`vite-plugins/catalog-data.ts`](vite-plugins/catalog-data.ts) | Bundles the catalog into `dist/data/` (packs + legacy JSON) + `sitemap.xml` |
|
| [`vite-plugins/catalog-data.ts`](vite-plugins/catalog-data.ts) | Bundles the catalog into `dist/data/` (packs + legacy JSON) + `sitemap.xml` |
|
||||||
| [`public/`](public/) | Static files; [`public/_headers`](public/_headers) sets headers + CSP for them |
|
| [`public/`](public/) | Static files; [`public/_headers`](public/_headers) sets headers + CSP for them |
|
||||||
| [`src-tauri/`](src-tauri/) | Tauri 2 shell for the desktop and Android apps |
|
| [`src-tauri/`](src-tauri/) | Tauri 2 shell for the desktop and Android apps |
|
||||||
| [`scripts/`](scripts/) | `gen_assets.py` (PWA icons + OG image), `i18n-edit.mjs` (edit `en`/`vi` keys together) |
|
| [`scripts/`](scripts/) | `gen_assets.py` (PWA icons + OG image), `i18n-edit.mjs` (edit `en`/`vi` keys together), `check-tauri-versions.mjs` (`npm run check:tauri`), and the repo-level tests `check-csp-hashes.test.mjs` (inline script hashes in the CSPs) and `check-contrast.test.mjs` (WCAG contrast of the colour tokens and the chart palette) |
|
||||||
| [`wrangler.jsonc`](wrangler.jsonc) | Worker config: assets, bindings, vars, cron, `staging` env |
|
| [`wrangler.jsonc`](wrangler.jsonc) | Worker config: assets, bindings, vars, cron, `staging` env |
|
||||||
|
|
||||||
## Local dev
|
## Local dev
|
||||||
@@ -73,6 +73,7 @@ Path alias `@/*` → `src/*`. Vite injects `__BUILD_DATE__` for the About page.
|
|||||||
The same steps as [`webapp-ci.yml`](../.github/workflows/webapp-ci.yml):
|
The same steps as [`webapp-ci.yml`](../.github/workflows/webapp-ci.yml):
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
npm run check:tauri # Tauri crates and their npm packages share major.minor
|
||||||
npm run cf:types -- --check # worker-configuration.d.ts matches wrangler.jsonc
|
npm run cf:types -- --check # worker-configuration.d.ts matches wrangler.jsonc
|
||||||
npm run lint # ESLint
|
npm run lint # ESLint
|
||||||
npm run knip # unused files / exports / deps
|
npm run knip # unused files / exports / deps
|
||||||
@@ -95,7 +96,7 @@ local secrets can't leak into it. Secrets are typed by hand in [`worker/env.ts`]
|
|||||||
| `/charts` | [src/routes/charts.tsx](src/routes/charts.tsx) | Charts + KPI cards across 4 tabs |
|
| `/charts` | [src/routes/charts.tsx](src/routes/charts.tsx) | Charts + KPI cards across 4 tabs |
|
||||||
| `/removed` | [src/routes/deleted.tsx](src/routes/deleted.tsx) | Removed games, with reasons (`/deleted` redirects here) |
|
| `/removed` | [src/routes/deleted.tsx](src/routes/deleted.tsx) | Removed games, with reasons (`/deleted` redirects here) |
|
||||||
| `/suggest` | [src/routes/suggest.tsx](src/routes/suggest.tsx) | Suggest a game (Turnstile, goes to the review queue) |
|
| `/suggest` | [src/routes/suggest.tsx](src/routes/suggest.tsx) | Suggest a game (Turnstile, goes to the review queue) |
|
||||||
| `/settings` | [src/routes/settings.tsx](src/routes/settings.tsx) | Theme, language, density, 18+ content opt-in (the header's display menu has the same) |
|
| `/settings` | [src/routes/settings.tsx](src/routes/settings.tsx) | Theme, language, density, hide scrollbars, accessibility (the "/" search shortcut), 18+ content opt-in (the header's display menu has most of them) |
|
||||||
| `/about` | [src/routes/about.tsx](src/routes/about.tsx) | Project info, legal links, third-party credits |
|
| `/about` | [src/routes/about.tsx](src/routes/about.tsx) | Project info, legal links, third-party credits |
|
||||||
| `/errors/:code` | [src/routes/error-preview.tsx](src/routes/error-preview.tsx) | Hidden error-page preview (not in the nav) |
|
| `/errors/:code` | [src/routes/error-preview.tsx](src/routes/error-preview.tsx) | Hidden error-page preview (not in the nav) |
|
||||||
|
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "webapp",
|
"name": "webapp",
|
||||||
"version": "4.5.0",
|
"version": "4.6.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "webapp",
|
"name": "webapp",
|
||||||
"version": "4.5.0",
|
"version": "4.6.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fontsource-variable/geist": "^5.3.0",
|
"@fontsource-variable/geist": "^5.3.0",
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "webapp",
|
"name": "webapp",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "4.5.0",
|
"version": "4.6.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
// WCAG 2.2 AA contrast of the design tokens (src/index.css, light and dark) and
|
||||||
|
// of the chart palette: 4.5:1 for text, 3:1 for the parts of controls and charts
|
||||||
|
// people need to see (field borders, the focus ring, chart marks). A colour
|
||||||
|
// change that breaks one of these fails CI with the pair and its ratio.
|
||||||
|
import { readFileSync } from 'node:fs'
|
||||||
|
import { describe, expect, it } from 'vitest'
|
||||||
|
import { NEUTRAL, PALETTE, PALETTE_LABEL } from '../src/components/charts/palette.ts'
|
||||||
|
import { contrastRatio } from '../src/lib/color.ts'
|
||||||
|
|
||||||
|
const TEXT = 4.5
|
||||||
|
const NON_TEXT = 3
|
||||||
|
|
||||||
|
const css = readFileSync(new URL('../src/index.css', import.meta.url), 'utf8').replace(/\r\n/g, '\n')
|
||||||
|
|
||||||
|
/** The 6-digit colour tokens of one `selector { … }` block (alpha tokens skipped). */
|
||||||
|
function tokens(selector) {
|
||||||
|
const start = css.indexOf(`\n${selector} {`)
|
||||||
|
if (start < 0) throw new Error(`index.css: no ${selector} block`)
|
||||||
|
const body = css.slice(start, css.indexOf('\n}', start))
|
||||||
|
return Object.fromEntries([...body.matchAll(/--([\w-]+):\s*(#[0-9a-f]{6})\s*;/gi)].map((m) => [m[1], m[2]]))
|
||||||
|
}
|
||||||
|
|
||||||
|
const LIGHT = tokens(':root')
|
||||||
|
const THEMES = { light: LIGHT, dark: { ...LIGHT, ...tokens('.dark') } }
|
||||||
|
|
||||||
|
// [foreground token, background token]
|
||||||
|
const TEXT_PAIRS = [
|
||||||
|
['foreground', 'background'],
|
||||||
|
['foreground', 'card'],
|
||||||
|
['foreground', 'popover'],
|
||||||
|
['foreground', 'muted'],
|
||||||
|
['muted-foreground', 'background'],
|
||||||
|
['muted-foreground', 'card'],
|
||||||
|
['muted-foreground', 'popover'],
|
||||||
|
['muted-foreground', 'muted'],
|
||||||
|
['muted-foreground', 'accent'],
|
||||||
|
['primary-foreground', 'primary'],
|
||||||
|
['primary-text', 'background'],
|
||||||
|
['primary-text', 'card'],
|
||||||
|
['primary-text', 'muted'],
|
||||||
|
['destructive', 'background'],
|
||||||
|
['destructive', 'card'],
|
||||||
|
['destructive-foreground', 'destructive-solid'],
|
||||||
|
['success', 'card'],
|
||||||
|
]
|
||||||
|
|
||||||
|
const NON_TEXT_PAIRS = [
|
||||||
|
['input', 'background'],
|
||||||
|
['input', 'card'],
|
||||||
|
['input', 'popover'],
|
||||||
|
['ring', 'background'],
|
||||||
|
['ring', 'card'],
|
||||||
|
['ring', 'popover'],
|
||||||
|
['primary', 'card'],
|
||||||
|
]
|
||||||
|
|
||||||
|
function failures(theme, pairs, min) {
|
||||||
|
return pairs.flatMap(([fg, bg]) => {
|
||||||
|
if (!theme[fg] || !theme[bg]) return [`missing --${fg} or --${bg}`]
|
||||||
|
const ratio = contrastRatio(theme[fg], theme[bg])
|
||||||
|
return ratio >= min ? [] : [`--${fg} on --${bg}: ${ratio.toFixed(2)}`]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('design tokens (src/index.css)', () => {
|
||||||
|
for (const [name, theme] of Object.entries(THEMES)) {
|
||||||
|
it(`${name}: text reaches ${TEXT}:1`, () => {
|
||||||
|
expect(failures(theme, TEXT_PAIRS, TEXT)).toEqual([])
|
||||||
|
})
|
||||||
|
it(`${name}: field borders, focus ring and accent reach ${NON_TEXT}:1`, () => {
|
||||||
|
expect(failures(theme, NON_TEXT_PAIRS, NON_TEXT)).toEqual([])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('chart palette', () => {
|
||||||
|
it(`every series colour reaches ${NON_TEXT}:1 on both themes' cards`, () => {
|
||||||
|
const low = Object.entries(THEMES).flatMap(([name, theme]) =>
|
||||||
|
[...PALETTE, NEUTRAL]
|
||||||
|
.filter((color) => contrastRatio(color, theme.card) < NON_TEXT)
|
||||||
|
.map((color) => `${color} on the ${name} card: ${contrastRatio(color, theme.card).toFixed(2)}`),
|
||||||
|
)
|
||||||
|
expect(low).toEqual([])
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`labels drawn on a colour (the treemap) reach ${TEXT}:1`, () => {
|
||||||
|
const low = PALETTE.map((color, i) => [color, PALETTE_LABEL[i], contrastRatio(color, PALETTE_LABEL[i])])
|
||||||
|
.filter(([, , ratio]) => ratio < TEXT)
|
||||||
|
.map(([color, label, ratio]) => `${label} on ${color}: ${ratio.toFixed(2)}`)
|
||||||
|
expect(low).toEqual([])
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -20,7 +20,7 @@ SANS = FONTS / "geist" / "files" / "geist-latin-wght-normal.woff2"
|
|||||||
MONO = FONTS / "geist-mono" / "files" / "geist-mono-latin-wght-normal.woff2"
|
MONO = FONTS / "geist-mono" / "files" / "geist-mono-latin-wght-normal.woff2"
|
||||||
|
|
||||||
# Same values as the dark theme tokens in src/index.css.
|
# Same values as the dark theme tokens in src/index.css.
|
||||||
ACCENT = (124, 92, 255) # --primary #7c5cff
|
ACCENT = (124, 92, 255) # --brand #7c5cff (the logo purple; buttons use the darker --primary)
|
||||||
BG = (11, 11, 12) # --background #0b0b0c
|
BG = (11, 11, 12) # --background #0b0b0c
|
||||||
TEXT = (237, 237, 239) # --foreground
|
TEXT = (237, 237, 239) # --foreground
|
||||||
MUTED = (155, 155, 164) # --muted-foreground
|
MUTED = (155, 155, 164) # --muted-foreground
|
||||||
|
|||||||
Generated
+1
-1
@@ -1027,7 +1027,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "free-games-itchio-webapp"
|
name = "free-games-itchio-webapp"
|
||||||
version = "4.5.0"
|
version = "4.6.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "free-games-itchio-webapp"
|
name = "free-games-itchio-webapp"
|
||||||
version = "4.5.0"
|
version = "4.6.0"
|
||||||
description = "Itch.io free games catalog viewer"
|
description = "Itch.io free games catalog viewer"
|
||||||
authors = ["poli0981"]
|
authors = ["poli0981"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "Itch.io Free Games DB",
|
"productName": "Itch.io Free Games DB",
|
||||||
"version": "4.5.0",
|
"version": "4.6.0",
|
||||||
"identifier": "com.poli0981.freegamesitchio",
|
"identifier": "com.poli0981.freegamesitchio",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "npm run dev",
|
"beforeDevCommand": "npm run dev",
|
||||||
|
|||||||
+69
-11
@@ -1,5 +1,12 @@
|
|||||||
import { lazy, Suspense, useEffect, useLayoutEffect, useRef } from 'react'
|
import { lazy, Suspense, useEffect, useLayoutEffect, useRef } from 'react'
|
||||||
import { Navigate, Routes, Route, useLocation, useNavigationType } from 'react-router'
|
import { Navigate, Routes, Route, useLocation, useNavigationType } from 'react-router'
|
||||||
|
import {
|
||||||
|
focusElement,
|
||||||
|
focusUntouchedSince,
|
||||||
|
pageHeading,
|
||||||
|
scrollBehavior,
|
||||||
|
whenPresent,
|
||||||
|
} from '@/components/focus-target'
|
||||||
import { LegalGate } from '@/components/legal-gate'
|
import { LegalGate } from '@/components/legal-gate'
|
||||||
import { NsfwDialog } from '@/components/nsfw-dialog'
|
import { NsfwDialog } from '@/components/nsfw-dialog'
|
||||||
import ScrollToTop from '@/components/scroll-to-top'
|
import ScrollToTop from '@/components/scroll-to-top'
|
||||||
@@ -13,6 +20,7 @@ import { useScrollbarsEffect } from '@/hooks/useScrollbarsEffect'
|
|||||||
import { useBackButton } from '@/hooks/useBackButton'
|
import { useBackButton } from '@/hooks/useBackButton'
|
||||||
import { useSeoHead } from '@/hooks/useSeoHead'
|
import { useSeoHead } from '@/hooks/useSeoHead'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
|
import { hashId, routeFocusTarget, type RouteSpot } from '@/lib/route-focus'
|
||||||
import Welcome from '@/routes/welcome'
|
import Welcome from '@/routes/welcome'
|
||||||
import Games from '@/routes/games'
|
import Games from '@/routes/games'
|
||||||
import NotFound from '@/routes/not-found'
|
import NotFound from '@/routes/not-found'
|
||||||
@@ -26,8 +34,10 @@ const Suggest = lazy(() => import('@/routes/suggest'))
|
|||||||
const ErrorPreview = lazy(() => import('@/routes/error-preview'))
|
const ErrorPreview = lazy(() => import('@/routes/error-preview'))
|
||||||
|
|
||||||
function RouteFallback() {
|
function RouteFallback() {
|
||||||
|
const t = useT()
|
||||||
return (
|
return (
|
||||||
<div className="mx-auto max-w-[1120px] space-y-3 px-4 pt-8 sm:px-8">
|
<div role="status" className="mx-auto max-w-[1120px] space-y-3 px-4 pt-8 sm:px-8">
|
||||||
|
<span className="sr-only">{t('common.loading')}</span>
|
||||||
<Skeleton className="h-8 w-48" />
|
<Skeleton className="h-8 w-48" />
|
||||||
<Skeleton className="h-[60vh]" />
|
<Skeleton className="h-[60vh]" />
|
||||||
</div>
|
</div>
|
||||||
@@ -39,36 +49,84 @@ function RouteFallback() {
|
|||||||
* (a link, the Games pager) starts at the top; a #hash scrolls to its section.
|
* (a link, the Games pager) starts at the top; a #hash scrolls to its section.
|
||||||
* Replaced entries (Games filters, typed searches) keep the position. The
|
* Replaced entries (Games filters, typed searches) keep the position. The
|
||||||
* browser's own restoration is off: it runs before React renders.
|
* browser's own restoration is off: it runs before React renders.
|
||||||
|
*
|
||||||
|
* Focus follows the page (lib/route-focus.ts): after a page change it moves
|
||||||
|
* to the new h1 (Back: to the link that was used there, e.g. the game row),
|
||||||
|
* after a #hash to that section — waiting for lazy routes to render.
|
||||||
*/
|
*/
|
||||||
function ScrollManager() {
|
function ScrollManager() {
|
||||||
const { key, pathname, hash } = useLocation()
|
const { key, pathname, search, hash } = useLocation()
|
||||||
const navigationType = useNavigationType()
|
const navigationType = useNavigationType()
|
||||||
const positions = useRef(new Map<string, number>())
|
const positions = useRef(new Map<string, number>())
|
||||||
|
const lastLinks = useRef(new Map<string, string>())
|
||||||
const currentKey = useRef(key)
|
const currentKey = useRef(key)
|
||||||
const lastPath = useRef(pathname)
|
const lastPath = useRef(pathname)
|
||||||
|
const lastSpot = useRef<RouteSpot | null>(null)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if ('scrollRestoration' in window.history) window.history.scrollRestoration = 'manual'
|
if ('scrollRestoration' in window.history) window.history.scrollRestoration = 'manual'
|
||||||
// The key is switched in the layout effect below, before any scroll event of the new page.
|
// The key is switched in the layout effect below, before any scroll event of the new page.
|
||||||
const save = () => positions.current.set(currentKey.current, window.scrollY)
|
const save = () => positions.current.set(currentKey.current, window.scrollY)
|
||||||
|
// The last link focused inside the page, so Back can return there.
|
||||||
|
const remember = (e: FocusEvent) => {
|
||||||
|
const el = e.target
|
||||||
|
if (!(el instanceof HTMLAnchorElement) || !el.closest('#main')) return
|
||||||
|
const href = el.getAttribute('href')
|
||||||
|
if (href) lastLinks.current.set(currentKey.current, href)
|
||||||
|
}
|
||||||
window.addEventListener('scroll', save, { passive: true })
|
window.addEventListener('scroll', save, { passive: true })
|
||||||
return () => window.removeEventListener('scroll', save)
|
document.addEventListener('focusin', remember)
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('scroll', save)
|
||||||
|
document.removeEventListener('focusin', remember)
|
||||||
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
currentKey.current = key
|
currentKey.current = key
|
||||||
const saved = positions.current.get(key)
|
const saved = positions.current.get(key)
|
||||||
if (navigationType === 'POP' && saved !== undefined) {
|
const sectionId = hashId(hash)
|
||||||
|
const cancels: (() => void)[] = []
|
||||||
|
const target = routeFocusTarget(lastSpot.current, { pathname, search, hash })
|
||||||
|
lastSpot.current = { pathname, search, hash }
|
||||||
|
const before = document.activeElement
|
||||||
|
const focus = (el: HTMLElement) => {
|
||||||
|
if (focusUntouchedSince(before)) focusElement(el)
|
||||||
|
}
|
||||||
|
const focusHeading = () => {
|
||||||
|
const main = document.getElementById('main')
|
||||||
|
cancels.push(whenPresent(pageHeading, focus, { missing: () => main && focus(main) }))
|
||||||
|
}
|
||||||
|
|
||||||
|
const restore = navigationType === 'POP' && saved !== undefined
|
||||||
|
if (restore) {
|
||||||
window.scrollTo(0, saved)
|
window.scrollTo(0, saved)
|
||||||
} else if (hash) {
|
} else if (!sectionId && (navigationType === 'PUSH' || pathname !== lastPath.current)) {
|
||||||
requestAnimationFrame(() =>
|
|
||||||
document.getElementById(hash.slice(1))?.scrollIntoView({ behavior: 'smooth', block: 'start' }),
|
|
||||||
)
|
|
||||||
} else if (navigationType === 'PUSH' || pathname !== lastPath.current) {
|
|
||||||
window.scrollTo(0, 0)
|
window.scrollTo(0, 0)
|
||||||
}
|
}
|
||||||
lastPath.current = pathname
|
lastPath.current = pathname
|
||||||
}, [key, pathname, hash, navigationType])
|
|
||||||
|
if (sectionId && (!restore || target?.kind === 'hash')) {
|
||||||
|
cancels.push(
|
||||||
|
whenPresent(
|
||||||
|
() => document.getElementById(sectionId),
|
||||||
|
(el) => {
|
||||||
|
if (!restore) el.scrollIntoView({ behavior: scrollBehavior(), block: 'start' })
|
||||||
|
if (target?.kind === 'hash') focus(el)
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
} else if (target?.kind === 'heading') {
|
||||||
|
const href = navigationType === 'POP' ? lastLinks.current.get(key) : undefined
|
||||||
|
if (href) {
|
||||||
|
const link = () => document.querySelector<HTMLAnchorElement>(`#main a[href="${CSS.escape(href)}"]`)
|
||||||
|
cancels.push(whenPresent(link, focus, { timeout: 2000, missing: focusHeading }))
|
||||||
|
} else {
|
||||||
|
focusHeading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return () => cancels.forEach((cancel) => cancel())
|
||||||
|
}, [key, pathname, search, hash, navigationType])
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -99,7 +157,7 @@ export default function App() {
|
|||||||
<ScrollManager />
|
<ScrollManager />
|
||||||
<SkipToContent />
|
<SkipToContent />
|
||||||
<SiteHeader />
|
<SiteHeader />
|
||||||
<main id="main" tabIndex={-1} className="flex-1 outline-hidden">
|
<main id="main" tabIndex={-1} className="flex-1 outline-none">
|
||||||
<RouteErrorBoundary>
|
<RouteErrorBoundary>
|
||||||
<Suspense fallback={<RouteFallback />}>
|
<Suspense fallback={<RouteFallback />}>
|
||||||
<Routes>
|
<Routes>
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
||||||
import { countByArray, topN } from '@/lib/analytics'
|
import { countByArray, topN } from '@/lib/analytics'
|
||||||
|
import { tableRows } from '@/lib/chart-table'
|
||||||
import { useFormat } from '@/lib/format'
|
import { useFormat } from '@/lib/format'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
import type { Game } from '@/types/game'
|
import type { Game } from '@/types/game'
|
||||||
import { ChartCard } from './chart-card'
|
import { ChartCard } from './chart-card'
|
||||||
import { BAR_CURSOR, SERIES_ANIMATION, TOOLTIP_BASE, truncateLabel } from './chart-theme'
|
import { BAR_CURSOR, chartAria, SERIES_ANIMATION, TOOLTIP_BASE, truncateLabel } from './chart-theme'
|
||||||
import { ChartTooltipContent } from './chart-tooltip'
|
import { ChartTooltipContent } from './chart-tooltip'
|
||||||
import { PALETTE } from './palette'
|
import { PALETTE } from './palette'
|
||||||
|
|
||||||
@@ -14,12 +15,21 @@ export function AccessibilityChart({ games }: { games: Game[] }) {
|
|||||||
const fmt = useFormat()
|
const fmt = useFormat()
|
||||||
const data = useMemo(() => topN(countByArray(games, 'accessibility'), 10), [games])
|
const data = useMemo(() => topN(countByArray(games, 'accessibility'), 10), [games])
|
||||||
return (
|
return (
|
||||||
<ChartCard title={t('charts.accessibility.title')} description={t('charts.accessibility.desc')}>
|
<ChartCard
|
||||||
|
id="accessibility"
|
||||||
|
title={t('charts.accessibility.title')}
|
||||||
|
description={t('charts.accessibility.desc')}
|
||||||
|
table={
|
||||||
|
data.length
|
||||||
|
? { label: t('games.filter.access'), value: t('charts.series.games'), rows: tableRows(data) }
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
>
|
||||||
{data.length === 0 ? (
|
{data.length === 0 ? (
|
||||||
<p className="flex h-full items-center justify-center text-sm text-muted-foreground">{t('charts.empty')}</p>
|
<p className="flex h-full items-center justify-center text-sm text-muted-foreground">{t('charts.empty')}</p>
|
||||||
) : (
|
) : (
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
<ResponsiveContainer width="100%" height="100%">
|
||||||
<BarChart data={data} layout="vertical" margin={{ left: 20 }}>
|
<BarChart {...chartAria('accessibility')} data={data} layout="vertical" margin={{ left: 20 }}>
|
||||||
<CartesianGrid horizontal={false} strokeDasharray="3 3" />
|
<CartesianGrid horizontal={false} strokeDasharray="3 3" />
|
||||||
<XAxis type="number" allowDecimals={false} tickFormatter={fmt.number} />
|
<XAxis type="number" allowDecimals={false} tickFormatter={fmt.number} />
|
||||||
<YAxis
|
<YAxis
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
||||||
import { countByArray } from '@/lib/analytics'
|
import { countByArray } from '@/lib/analytics'
|
||||||
|
import { tableRows } from '@/lib/chart-table'
|
||||||
import { useFormat } from '@/lib/format'
|
import { useFormat } from '@/lib/format'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
import type { Game } from '@/types/game'
|
import type { Game } from '@/types/game'
|
||||||
import { ChartCard } from './chart-card'
|
import { ChartCard } from './chart-card'
|
||||||
import { BAR_CURSOR, SERIES_ANIMATION, TOOLTIP_BASE } from './chart-theme'
|
import { BAR_CURSOR, chartAria, SERIES_ANIMATION, TOOLTIP_BASE } from './chart-theme'
|
||||||
import { ChartTooltipContent } from './chart-tooltip'
|
import { ChartTooltipContent } from './chart-tooltip'
|
||||||
import { PALETTE } from './palette'
|
import { PALETTE } from './palette'
|
||||||
|
|
||||||
@@ -15,12 +16,21 @@ export function AiContentChart({ games }: { games: Game[] }) {
|
|||||||
const fmt = useFormat()
|
const fmt = useFormat()
|
||||||
const data = useMemo(() => countByArray(games, 'ai_content'), [games])
|
const data = useMemo(() => countByArray(games, 'ai_content'), [games])
|
||||||
return (
|
return (
|
||||||
<ChartCard title={t('charts.aiContent.title')} description={t('charts.aiContent.desc')}>
|
<ChartCard
|
||||||
|
id="ai-content"
|
||||||
|
title={t('charts.aiContent.title')}
|
||||||
|
description={t('charts.aiContent.desc')}
|
||||||
|
table={
|
||||||
|
data.length
|
||||||
|
? { label: t('charts.table.use'), value: t('charts.series.games'), rows: tableRows(data) }
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
>
|
||||||
{data.length === 0 ? (
|
{data.length === 0 ? (
|
||||||
<p className="flex h-full items-center justify-center text-sm text-muted-foreground">{t('charts.empty')}</p>
|
<p className="flex h-full items-center justify-center text-sm text-muted-foreground">{t('charts.empty')}</p>
|
||||||
) : (
|
) : (
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
<ResponsiveContainer width="100%" height="100%">
|
||||||
<BarChart data={data} layout="vertical" margin={{ left: 20 }}>
|
<BarChart {...chartAria('ai-content')} data={data} layout="vertical" margin={{ left: 20 }}>
|
||||||
<CartesianGrid horizontal={false} strokeDasharray="3 3" />
|
<CartesianGrid horizontal={false} strokeDasharray="3 3" />
|
||||||
<XAxis type="number" allowDecimals={false} tickFormatter={fmt.number} />
|
<XAxis type="number" allowDecimals={false} tickFormatter={fmt.number} />
|
||||||
<YAxis dataKey="key" type="category" width={100} interval={0} tick={{ fontSize: 12 }} />
|
<YAxis dataKey="key" type="category" width={100} interval={0} tick={{ fontSize: 12 }} />
|
||||||
|
|||||||
@@ -2,11 +2,12 @@ import { useMemo } from 'react'
|
|||||||
import { Cell, Legend, Pie, PieChart, ResponsiveContainer, Tooltip } from 'recharts'
|
import { Cell, Legend, Pie, PieChart, ResponsiveContainer, Tooltip } from 'recharts'
|
||||||
import { aiLabel } from '@/lib/ai-disclosure'
|
import { aiLabel } from '@/lib/ai-disclosure'
|
||||||
import { aiDisclosureCounts } from '@/lib/analytics'
|
import { aiDisclosureCounts } from '@/lib/analytics'
|
||||||
|
import { tableRows } from '@/lib/chart-table'
|
||||||
import { AI_ASSISTED, AI_NONE, AI_UNDISCLOSED } from '@/lib/game-filters'
|
import { AI_ASSISTED, AI_NONE, AI_UNDISCLOSED } from '@/lib/game-filters'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
import type { Game } from '@/types/game'
|
import type { Game } from '@/types/game'
|
||||||
import { ChartCard } from './chart-card'
|
import { ChartCard } from './chart-card'
|
||||||
import { LEGEND_BASE, SERIES_ANIMATION, SLICE_STROKE, TOOLTIP_BASE } from './chart-theme'
|
import { chartAria, LEGEND_BASE, SERIES_ANIMATION, SLICE_STROKE, TOOLTIP_BASE } from './chart-theme'
|
||||||
import { ChartTooltipContent } from './chart-tooltip'
|
import { ChartTooltipContent } from './chart-tooltip'
|
||||||
import { NEUTRAL, PALETTE } from './palette'
|
import { NEUTRAL, PALETTE } from './palette'
|
||||||
|
|
||||||
@@ -25,11 +26,24 @@ export function AiDisclosureChart({ games }: { games: Game[] }) {
|
|||||||
)
|
)
|
||||||
const total = data.reduce((sum, d) => sum + d.count, 0)
|
const total = data.reduce((sum, d) => sum + d.count, 0)
|
||||||
return (
|
return (
|
||||||
<ChartCard title={t('charts.ai.title')} description={t('charts.ai.desc')}>
|
<ChartCard
|
||||||
|
id="ai-disclosure"
|
||||||
|
title={t('charts.ai.title')}
|
||||||
|
description={t('charts.ai.desc')}
|
||||||
|
table={{
|
||||||
|
label: t('games.filter.ai'),
|
||||||
|
value: t('charts.series.games'),
|
||||||
|
rows: tableRows(
|
||||||
|
data.map((d) => ({ key: d.label, count: d.count })),
|
||||||
|
total,
|
||||||
|
),
|
||||||
|
}}
|
||||||
|
>
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
<ResponsiveContainer width="100%" height="100%">
|
||||||
<PieChart>
|
<PieChart {...chartAria('ai-disclosure')}>
|
||||||
<Pie
|
<Pie
|
||||||
{...SERIES_ANIMATION}
|
{...SERIES_ANIMATION}
|
||||||
|
rootTabIndex={-1}
|
||||||
data={data}
|
data={data}
|
||||||
dataKey="count"
|
dataKey="count"
|
||||||
nameKey="label"
|
nameKey="label"
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
||||||
import { countBy, topN } from '@/lib/analytics'
|
import { countBy, topN } from '@/lib/analytics'
|
||||||
|
import { tableRows } from '@/lib/chart-table'
|
||||||
import { useFormat } from '@/lib/format'
|
import { useFormat } from '@/lib/format'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
import { useIsMobile } from '@/lib/use-is-mobile'
|
import { useIsMobile } from '@/lib/use-is-mobile'
|
||||||
import type { Game } from '@/types/game'
|
import type { Game } from '@/types/game'
|
||||||
import { ChartCard } from './chart-card'
|
import { ChartCard } from './chart-card'
|
||||||
import { BAR_CURSOR, SERIES_ANIMATION, singleLineTick, TOOLTIP_BASE, truncateLabel } from './chart-theme'
|
import { BAR_CURSOR, chartAria, SERIES_ANIMATION, singleLineTick, TOOLTIP_BASE, truncateLabel } from './chart-theme'
|
||||||
import { ChartTooltipContent } from './chart-tooltip'
|
import { ChartTooltipContent } from './chart-tooltip'
|
||||||
import { PALETTE } from './palette'
|
import { PALETTE } from './palette'
|
||||||
|
|
||||||
@@ -17,9 +18,13 @@ export function AvgSessionChart({ games }: { games: Game[] }) {
|
|||||||
const isMobile = useIsMobile()
|
const isMobile = useIsMobile()
|
||||||
const data = useMemo(() => topN(countBy(games, 'average_session'), 8), [games])
|
const data = useMemo(() => topN(countBy(games, 'average_session'), 8), [games])
|
||||||
return (
|
return (
|
||||||
<ChartCard title={t('charts.avgSession.title')}>
|
<ChartCard
|
||||||
|
id="avg-session"
|
||||||
|
title={t('charts.avgSession.title')}
|
||||||
|
table={{ label: t('detail.avgSession'), value: t('charts.series.games'), rows: tableRows(data) }}
|
||||||
|
>
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
<ResponsiveContainer width="100%" height="100%">
|
||||||
<BarChart data={data} layout={isMobile ? 'vertical' : 'horizontal'}>
|
<BarChart {...chartAria('avg-session')} data={data} layout={isMobile ? 'vertical' : 'horizontal'}>
|
||||||
<CartesianGrid horizontal={!isMobile} strokeDasharray="3 3" />
|
<CartesianGrid horizontal={!isMobile} strokeDasharray="3 3" />
|
||||||
{isMobile ? (
|
{isMobile ? (
|
||||||
<XAxis type="number" allowDecimals={false} tickFormatter={fmt.number} />
|
<XAxis type="number" allowDecimals={false} tickFormatter={fmt.number} />
|
||||||
|
|||||||
@@ -1,21 +1,68 @@
|
|||||||
|
import { useCallback, useRef, useState, type ReactNode } from 'react'
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
||||||
|
import type { TableRow } from '@/lib/chart-table'
|
||||||
|
import { useFormat } from '@/lib/format'
|
||||||
|
import { useT } from '@/lib/i18n'
|
||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
|
import { ChartAnnounce, chartIds } from './chart-theme'
|
||||||
|
|
||||||
interface ChartCardProps {
|
/** The chart's numbers as a table under it (lib/chart-table.ts builds the rows). */
|
||||||
title: string
|
interface ChartTableData {
|
||||||
description?: string
|
/** Heading of the first column (what each row is: genre, date, …). */
|
||||||
/** Extra classes for the chart area, e.g. a taller one on phones (`max-md:h-96`). */
|
label: string
|
||||||
contentClassName?: string
|
/** Heading of the value column (games, ratings, removed). */
|
||||||
children: React.ReactNode
|
value: string
|
||||||
|
rows: readonly TableRow[]
|
||||||
|
/** Formats the first column, e.g. an ISO date. */
|
||||||
|
formatKey?: (key: string) => string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ChartCard({ title, description, contentClassName, children }: ChartCardProps) {
|
interface ChartCardProps {
|
||||||
|
/** Unique on the page: the ids of the heading, description and hint derive from it (chartAria). */
|
||||||
|
id: string
|
||||||
|
title: string
|
||||||
|
description?: string
|
||||||
|
/** The same data as a table, for screen readers and anyone who'd rather read numbers. */
|
||||||
|
table?: ChartTableData
|
||||||
|
/** Recharts charts you can step through with the arrow keys (not the list cards or the treemap). */
|
||||||
|
keyboard?: boolean
|
||||||
|
/** Extra classes for the chart area, e.g. a taller one on phones (`max-md:h-96`). */
|
||||||
|
contentClassName?: string
|
||||||
|
children: ReactNode
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ChartCard({
|
||||||
|
id,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
table,
|
||||||
|
keyboard = true,
|
||||||
|
contentClassName,
|
||||||
|
children,
|
||||||
|
}: ChartCardProps) {
|
||||||
|
const t = useT()
|
||||||
|
const ids = chartIds(id)
|
||||||
|
// The tooltip's text goes straight into the live region: no state, so hovering
|
||||||
|
// never re-renders the card or the chart in it (charts stay mounted, gotcha 33).
|
||||||
|
const live = useRef<HTMLParagraphElement>(null)
|
||||||
|
const announce = useCallback((text: string) => {
|
||||||
|
if (live.current && live.current.textContent !== text) live.current.textContent = text
|
||||||
|
}, [])
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="text-base">{title}</CardTitle>
|
<CardTitle id={ids.title} className="text-base">
|
||||||
|
{title}
|
||||||
|
</CardTitle>
|
||||||
{description && (
|
{description && (
|
||||||
<p className="text-xs text-muted-foreground">{description}</p>
|
<p id={ids.desc} className="text-xs text-muted-foreground">
|
||||||
|
{description}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
{keyboard && (
|
||||||
|
<p id={ids.keys} className="sr-only">
|
||||||
|
{t('charts.a11y.keys')}
|
||||||
|
</p>
|
||||||
)}
|
)}
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
{/* Recharts 3 makes the chart focusable (keyboard navigation). A mouse
|
{/* Recharts 3 makes the chart focusable (keyboard navigation). A mouse
|
||||||
@@ -29,8 +76,66 @@ export function ChartCard({ title, description, contentClassName, children }: Ch
|
|||||||
if ((e.target as Element).closest('.recharts-wrapper')) e.preventDefault()
|
if ((e.target as Element).closest('.recharts-wrapper')) e.preventDefault()
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
<ChartAnnounce.Provider value={announce}>{children}</ChartAnnounce.Provider>
|
||||||
|
<p ref={live} className="sr-only" aria-live="polite" aria-atomic="true" />
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
{table && <ChartTable title={title} {...table} />}
|
||||||
</Card>
|
</Card>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A closed <details> under the chart; the table is only built once it is opened. */
|
||||||
|
function ChartTable({ title, label, value, rows, formatKey }: ChartTableData & { title: string }) {
|
||||||
|
const t = useT()
|
||||||
|
const fmt = useFormat()
|
||||||
|
const [open, setOpen] = useState(false)
|
||||||
|
const shares = rows.some((row) => row.share !== null)
|
||||||
|
return (
|
||||||
|
<details className="border-t px-5 py-3 text-sm" onToggle={(e) => setOpen(e.currentTarget.open)}>
|
||||||
|
<summary className="cursor-pointer text-xs font-medium text-muted-foreground hover:text-foreground">
|
||||||
|
{t('charts.table.show')}
|
||||||
|
</summary>
|
||||||
|
{open && (
|
||||||
|
// Scrolls on its own (the game count has a row per day). A scrolling area with nothing focusable
|
||||||
|
// inside must take focus itself, or the keyboard can't scroll it (WCAG 2.1.1; axe's
|
||||||
|
// scrollable-region-focusable): the labelled region + tabIndex 0 pattern. Sonar's S6845
|
||||||
|
// (no tabIndex on non-interactive elements) doesn't know that exception.
|
||||||
|
<div tabIndex={0} /* NOSONAR */ role="region" aria-label={title} className="mt-2 max-h-72 overflow-y-auto">
|
||||||
|
<table className="w-full border-collapse text-xs">
|
||||||
|
<caption className="sr-only">{title}</caption>
|
||||||
|
<thead className="sticky top-0 bg-card text-muted-foreground">
|
||||||
|
<tr className="border-b">
|
||||||
|
<th scope="col" className="py-1.5 pr-3 text-left font-medium">
|
||||||
|
{label}
|
||||||
|
</th>
|
||||||
|
<th scope="col" className="py-1.5 pl-3 text-right font-medium">
|
||||||
|
{value}
|
||||||
|
</th>
|
||||||
|
{shares && (
|
||||||
|
<th scope="col" className="py-1.5 pl-3 text-right font-medium">
|
||||||
|
{t('charts.table.share')}
|
||||||
|
</th>
|
||||||
|
)}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{rows.map((row) => (
|
||||||
|
<tr key={row.key} className="border-b last:border-b-0">
|
||||||
|
<th scope="row" className="py-1.5 pr-3 text-left font-normal">
|
||||||
|
{formatKey ? formatKey(row.key) : row.key}
|
||||||
|
</th>
|
||||||
|
<td className="py-1.5 pl-3 text-right font-mono tabular-nums">{fmt.number(row.count)}</td>
|
||||||
|
{shares && (
|
||||||
|
<td className="py-1.5 pl-3 text-right font-mono tabular-nums">
|
||||||
|
{row.share === null ? '' : fmt.percent(row.share)}
|
||||||
|
</td>
|
||||||
|
)}
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</details>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,11 +1,15 @@
|
|||||||
import { Card, CardContent, CardHeader } from '@/components/ui/card'
|
import { Card, CardContent, CardHeader } from '@/components/ui/card'
|
||||||
import { Skeleton } from '@/components/ui/skeleton'
|
import { Skeleton } from '@/components/ui/skeleton'
|
||||||
|
import { useT } from '@/lib/i18n'
|
||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
|
|
||||||
export type ChartTab = 'overview' | 'reach' | 'quality' | 'discovery'
|
export type ChartTab = 'overview' | 'reach' | 'quality' | 'discovery'
|
||||||
|
|
||||||
/** A ChartCard while its tab loads: the same header lines and chart area, so nothing moves when it arrives. */
|
/**
|
||||||
function CardSkeleton({ described, tall }: { described: boolean; tall?: boolean }) {
|
* A ChartCard while its tab loads: the same header lines, chart area and "Data table"
|
||||||
|
* line, so nothing moves when it arrives.
|
||||||
|
*/
|
||||||
|
function CardSkeleton({ described, tall, table }: CardShape) {
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
@@ -15,6 +19,11 @@ function CardSkeleton({ described, tall }: { described: boolean; tall?: boolean
|
|||||||
<CardContent className={cn('h-72', tall && 'max-md:h-96')}>
|
<CardContent className={cn('h-72', tall && 'max-md:h-96')}>
|
||||||
<Skeleton className="h-full w-full" />
|
<Skeleton className="h-full w-full" />
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
{table && (
|
||||||
|
<div className="border-t px-5 py-3">
|
||||||
|
<Skeleton className="h-4 w-24" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</Card>
|
</Card>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -34,17 +43,31 @@ function KpiSkeleton() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Each tab's cards in order: with a description line or not; the Genres chart is taller on phones.
|
interface CardShape {
|
||||||
const LAYOUT: Record<ChartTab, { described: boolean; tall?: boolean }[]> = {
|
described: boolean
|
||||||
overview: [{ described: true, tall: true }, ...Array.from({ length: 5 }, () => ({ described: true }))],
|
tall?: boolean
|
||||||
reach: [{ described: true }, { described: false }, { described: false }, { described: true }],
|
table?: boolean
|
||||||
quality: Array.from({ length: 4 }, () => ({ described: true })),
|
}
|
||||||
discovery: Array.from({ length: 4 }, () => ({ described: true })),
|
|
||||||
|
// Each tab's cards in order: with a description line or not, with a data table or not
|
||||||
|
// (all but the list of recent deletions); the Genres chart is taller on phones.
|
||||||
|
const LAYOUT: Record<ChartTab, CardShape[]> = {
|
||||||
|
overview: [{ described: true, tall: true, table: true }, ...Array.from({ length: 5 }, () => ({ described: true, table: true }))],
|
||||||
|
reach: [
|
||||||
|
{ described: true, table: true },
|
||||||
|
{ described: false, table: true },
|
||||||
|
{ described: false, table: true },
|
||||||
|
{ described: true },
|
||||||
|
],
|
||||||
|
quality: Array.from({ length: 4 }, () => ({ described: true, table: true })),
|
||||||
|
discovery: Array.from({ length: 4 }, () => ({ described: true, table: true })),
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TabSkeleton({ tab }: { tab: ChartTab }) {
|
export function TabSkeleton({ tab }: { tab: ChartTab }) {
|
||||||
|
const t = useT()
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4" aria-busy="true">
|
<div role="status" className="space-y-4" aria-busy="true">
|
||||||
|
<span className="sr-only">{t('common.loading')}</span>
|
||||||
{tab === 'overview' && <KpiSkeleton />}
|
{tab === 'overview' && <KpiSkeleton />}
|
||||||
<div className="grid gap-4 md:grid-cols-2">
|
<div className="grid gap-4 md:grid-cols-2">
|
||||||
{LAYOUT[tab].map((card, i) => (
|
{LAYOUT[tab].map((card, i) => (
|
||||||
|
|||||||
@@ -15,3 +15,31 @@ describe('chart series', () => {
|
|||||||
expect(series.filter((s) => !s.animated)).toEqual([])
|
expect(series.filter((s) => !s.animated)).toEqual([])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('chart accessibility', () => {
|
||||||
|
const sources = Object.entries(CHARTS)
|
||||||
|
|
||||||
|
it('every chart is named after its card (chartAria)', () => {
|
||||||
|
const containers = sources.flatMap(([file, src]) =>
|
||||||
|
[...src.matchAll(/<(BarChart|LineChart|PieChart|Treemap)\b[^>]*?>/gs)].map((m) => ({ file, tag: m[0] })),
|
||||||
|
)
|
||||||
|
expect(containers.length).toBeGreaterThanOrEqual(16)
|
||||||
|
expect(containers.filter((c) => !c.tag.includes('{...chartAria(')).map((c) => c.file)).toEqual([])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('pies keep one tab stop (rootTabIndex={-1})', () => {
|
||||||
|
const pies = sources.flatMap(([file, src]) =>
|
||||||
|
[...src.matchAll(/<Pie\b[^>]*?>/gs)].map((m) => ({ file, tag: m[0] })),
|
||||||
|
)
|
||||||
|
expect(pies.length).toBeGreaterThanOrEqual(6)
|
||||||
|
expect(pies.filter((p) => !p.tag.includes('rootTabIndex={-1}')).map((p) => p.file)).toEqual([])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('every chart card offers its data as a table (the recent-deletions list is text already)', () => {
|
||||||
|
const missing = sources
|
||||||
|
.filter(([file]) => !file.includes('recent-deleted'))
|
||||||
|
.filter(([, src]) => !src.includes('table={'))
|
||||||
|
.map(([file]) => file)
|
||||||
|
expect(missing).toEqual([])
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -1,6 +1,33 @@
|
|||||||
// Shared Recharts props. The design tokens in index.css are hex colours, so
|
// Shared Recharts props. The design tokens in index.css are hex colours, so
|
||||||
// reference them as `var(--x)` — `hsl(var(--x))` is an invalid colour, which
|
// reference them as `var(--x)` — `hsl(var(--x))` is an invalid colour, which
|
||||||
// SVG paints black and CSS drops (a transparent tooltip).
|
// SVG paints black and CSS drops (a transparent tooltip).
|
||||||
|
import { createContext } from 'react'
|
||||||
|
|
||||||
|
/** Element ids inside one chart card: its heading, description and keyboard hint. */
|
||||||
|
export function chartIds(id: string) {
|
||||||
|
return { title: `chart-${id}-title`, desc: `chart-${id}-desc`, keys: `chart-${id}-keys` }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spread on every chart (BarChart, LineChart, PieChart, Treemap). Recharts 3
|
||||||
|
* makes the chart a focusable role="application" with an empty <title>; this
|
||||||
|
* names it after its card's heading and describes it with the card's
|
||||||
|
* description and, for the charts you can step through, the arrow-key hint.
|
||||||
|
* (Recharts' own `title` prop would also show a browser tooltip.)
|
||||||
|
*/
|
||||||
|
export function chartAria(id: string, { keys = true }: { keys?: boolean } = {}) {
|
||||||
|
const ids = chartIds(id)
|
||||||
|
return {
|
||||||
|
'aria-labelledby': ids.title,
|
||||||
|
'aria-describedby': keys ? `${ids.desc} ${ids.keys}` : ids.desc,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a chart's tooltip out (chart-tooltip.tsx → the card's polite live
|
||||||
|
* region): Recharts' own tooltip is a live region, a custom one isn't.
|
||||||
|
*/
|
||||||
|
export const ChartAnnounce = createContext<(text: string) => void>(() => {})
|
||||||
|
|
||||||
/** Every <Tooltip>: no slide-in animation, no focus outline, above the legend. */
|
/** Every <Tooltip>: no slide-in animation, no focus outline, above the legend. */
|
||||||
export const TOOLTIP_BASE = {
|
export const TOOLTIP_BASE = {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
import { useContext, useEffect } from 'react'
|
||||||
import type { TooltipContentProps, TooltipPayloadEntry } from 'recharts'
|
import type { TooltipContentProps, TooltipPayloadEntry } from 'recharts'
|
||||||
import { useFormat } from '@/lib/format'
|
import { useFormat } from '@/lib/format'
|
||||||
|
import { ChartAnnounce } from './chart-theme'
|
||||||
|
|
||||||
interface ChartTooltipContentProps extends Partial<Pick<TooltipContentProps, 'active' | 'payload' | 'label'>> {
|
interface ChartTooltipContentProps extends Partial<Pick<TooltipContentProps, 'active' | 'payload' | 'label'>> {
|
||||||
/** Sum of all slices of a pie whose slices cover the whole: adds each value's share. */
|
/** Sum of all slices of a pie whose slices cover the whole: adds each value's share. */
|
||||||
@@ -14,26 +16,41 @@ interface ChartTooltipContentProps extends Partial<Pick<TooltipContentProps, 'ac
|
|||||||
* Tooltip body for every chart: popover colours from the theme tokens, a swatch
|
* Tooltip body for every chart: popover colours from the theme tokens, a swatch
|
||||||
* per series, and numbers formatted for the chosen language. Pass it as
|
* per series, and numbers formatted for the chosen language. Pass it as
|
||||||
* `content={<ChartTooltipContent />}`; Recharts fills in active/payload/label.
|
* `content={<ChartTooltipContent />}`; Recharts fills in active/payload/label.
|
||||||
|
* The same text goes to the card's live region (ChartAnnounce), so stepping
|
||||||
|
* through a chart with the arrow keys reads each value out.
|
||||||
*/
|
*/
|
||||||
export function ChartTooltipContent({ active, payload, label, total, labelFormat, colorOf }: ChartTooltipContentProps) {
|
export function ChartTooltipContent({ active, payload, label, total, labelFormat, colorOf }: ChartTooltipContentProps) {
|
||||||
const fmt = useFormat()
|
const fmt = useFormat()
|
||||||
if (!active || !payload?.length) return null
|
const announce = useContext(ChartAnnounce)
|
||||||
|
const shown = Boolean(active && payload?.length)
|
||||||
const heading = label === undefined || label === '' ? '' : labelFormat ? labelFormat(String(label)) : String(label)
|
const heading = label === undefined || label === '' ? '' : labelFormat ? labelFormat(String(label)) : String(label)
|
||||||
|
const rows = (shown ? (payload ?? []) : []).map((entry) => {
|
||||||
|
const value = Number(entry.value)
|
||||||
|
const number = Number.isFinite(value) ? fmt.number(value) : String(entry.value ?? '')
|
||||||
|
const share = total && Number.isFinite(value) ? ` (${fmt.percent(value / total)})` : ''
|
||||||
|
return { entry, text: `${number}${share}` }
|
||||||
|
})
|
||||||
|
const spoken = rows.length
|
||||||
|
? [heading, ...rows.map(({ entry, text }) => `${String(entry.name ?? '')} ${text}`.trim())].filter(Boolean).join(', ')
|
||||||
|
: ''
|
||||||
|
useEffect(() => announce(spoken), [announce, spoken])
|
||||||
|
|
||||||
|
if (!shown) return null
|
||||||
return (
|
return (
|
||||||
<div className="min-w-36 rounded-md border bg-popover px-3 py-2 text-xs text-popover-foreground shadow-md">
|
<div className="min-w-36 rounded-md border bg-popover px-3 py-2 text-xs text-popover-foreground shadow-md">
|
||||||
{heading && <p className="mb-1.5 font-medium">{heading}</p>}
|
{heading && <p className="mb-1.5 font-medium">{heading}</p>}
|
||||||
<ul className="space-y-1">
|
<ul className="space-y-1">
|
||||||
{payload.map((entry, i) => {
|
{rows.map(({ entry, text }, i) => {
|
||||||
const value = Number(entry.value)
|
|
||||||
const color = colorOf?.(entry) ?? entry.color ?? entry.fill
|
const color = colorOf?.(entry) ?? entry.color ?? entry.fill
|
||||||
return (
|
return (
|
||||||
<li key={`${String(entry.name)}-${i}`} className="flex items-center gap-2">
|
<li key={`${String(entry.name)}-${i}`} className="flex items-center gap-2">
|
||||||
<span aria-hidden="true" className="size-2.5 shrink-0 rounded-[3px]" style={{ background: color }} />
|
<span
|
||||||
|
aria-hidden="true"
|
||||||
|
className="size-2.5 shrink-0 rounded-[3px] forced-color-adjust-none"
|
||||||
|
style={{ background: color }}
|
||||||
|
/>
|
||||||
<span className="text-muted-foreground">{entry.name}</span>
|
<span className="text-muted-foreground">{entry.name}</span>
|
||||||
<span className="ml-auto pl-4 font-mono font-medium tabular-nums">
|
<span className="ml-auto pl-4 font-mono font-medium tabular-nums">{text}</span>
|
||||||
{Number.isFinite(value) ? fmt.number(value) : String(entry.value ?? '')}
|
|
||||||
{total && Number.isFinite(value) ? ` (${fmt.percent(value / total)})` : null}
|
|
||||||
</span>
|
|
||||||
</li>
|
</li>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { Cell, Legend, Pie, PieChart, ResponsiveContainer, Tooltip } from 'recharts'
|
import { Cell, Legend, Pie, PieChart, ResponsiveContainer, Tooltip } from 'recharts'
|
||||||
import { deletionReasonCounts } from '@/lib/analytics'
|
import { deletionReasonCounts } from '@/lib/analytics'
|
||||||
|
import { tableRows } from '@/lib/chart-table'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
import type { DeletedGameEntry } from '@/types/game'
|
import type { DeletedGameEntry } from '@/types/game'
|
||||||
import { ChartCard } from './chart-card'
|
import { ChartCard } from './chart-card'
|
||||||
import { LEGEND_BASE, SERIES_ANIMATION, SLICE_STROKE, TOOLTIP_BASE } from './chart-theme'
|
import { chartAria, LEGEND_BASE, SERIES_ANIMATION, SLICE_STROKE, TOOLTIP_BASE } from './chart-theme'
|
||||||
import { ChartTooltipContent } from './chart-tooltip'
|
import { ChartTooltipContent } from './chart-tooltip'
|
||||||
import { PALETTE } from './palette'
|
import { PALETTE } from './palette'
|
||||||
|
|
||||||
@@ -13,11 +14,17 @@ export function DeletionReasonsChart({ deleted }: { deleted: DeletedGameEntry[]
|
|||||||
const data = useMemo(() => deletionReasonCounts(deleted), [deleted])
|
const data = useMemo(() => deletionReasonCounts(deleted), [deleted])
|
||||||
const total = data.reduce((sum, d) => sum + d.count, 0)
|
const total = data.reduce((sum, d) => sum + d.count, 0)
|
||||||
return (
|
return (
|
||||||
<ChartCard title={t('charts.deletionReasons.title')} description={t('charts.deletionReasons.desc')}>
|
<ChartCard
|
||||||
|
id="deletion-reasons"
|
||||||
|
title={t('charts.deletionReasons.title')}
|
||||||
|
description={t('charts.deletionReasons.desc')}
|
||||||
|
table={{ label: t('deleted.col.reason'), value: t('charts.series.removed'), rows: tableRows(data, total) }}
|
||||||
|
>
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
<ResponsiveContainer width="100%" height="100%">
|
||||||
<PieChart>
|
<PieChart {...chartAria('deletion-reasons')}>
|
||||||
<Pie
|
<Pie
|
||||||
{...SERIES_ANIMATION}
|
{...SERIES_ANIMATION}
|
||||||
|
rootTabIndex={-1}
|
||||||
data={data}
|
data={data}
|
||||||
dataKey="count"
|
dataKey="count"
|
||||||
nameKey="key"
|
nameKey="key"
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
||||||
import { deletionsByMonth } from '@/lib/analytics'
|
import { deletionsByMonth } from '@/lib/analytics'
|
||||||
|
import { tableRows } from '@/lib/chart-table'
|
||||||
import { useFormat } from '@/lib/format'
|
import { useFormat } from '@/lib/format'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
import type { DeletedGameEntry } from '@/types/game'
|
import type { DeletedGameEntry } from '@/types/game'
|
||||||
import { ChartCard } from './chart-card'
|
import { ChartCard } from './chart-card'
|
||||||
import { BAR_CURSOR, SERIES_ANIMATION, TOOLTIP_BASE } from './chart-theme'
|
import { BAR_CURSOR, chartAria, SERIES_ANIMATION, TOOLTIP_BASE } from './chart-theme'
|
||||||
import { ChartTooltipContent } from './chart-tooltip'
|
import { ChartTooltipContent } from './chart-tooltip'
|
||||||
import { PALETTE } from './palette'
|
import { PALETTE } from './palette'
|
||||||
|
|
||||||
@@ -14,9 +15,14 @@ export function DeletionsOverTimeChart({ deleted }: { deleted: DeletedGameEntry[
|
|||||||
const fmt = useFormat()
|
const fmt = useFormat()
|
||||||
const data = useMemo(() => deletionsByMonth(deleted), [deleted])
|
const data = useMemo(() => deletionsByMonth(deleted), [deleted])
|
||||||
return (
|
return (
|
||||||
<ChartCard title={t('charts.deletionsOverTime.title')} description={t('charts.deletionsOverTime.desc')}>
|
<ChartCard
|
||||||
|
id="deletions-over-time"
|
||||||
|
title={t('charts.deletionsOverTime.title')}
|
||||||
|
description={t('charts.deletionsOverTime.desc')}
|
||||||
|
table={{ label: t('charts.table.month'), value: t('charts.series.removed'), rows: tableRows(data) }}
|
||||||
|
>
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
<ResponsiveContainer width="100%" height="100%">
|
||||||
<BarChart data={data}>
|
<BarChart {...chartAria('deletions-over-time')} data={data}>
|
||||||
<CartesianGrid strokeDasharray="3 3" />
|
<CartesianGrid strokeDasharray="3 3" />
|
||||||
<XAxis dataKey="key" tick={{ fontSize: 10 }} interval={0} angle={-25} textAnchor="end" height={60} />
|
<XAxis dataKey="key" tick={{ fontSize: 10 }} interval={0} angle={-25} textAnchor="end" height={60} />
|
||||||
<YAxis allowDecimals={false} tickFormatter={fmt.number} />
|
<YAxis allowDecimals={false} tickFormatter={fmt.number} />
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { CartesianGrid, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
import { CartesianGrid, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
||||||
|
import { historyRows } from '@/lib/chart-table'
|
||||||
import { useFormat } from '@/lib/format'
|
import { useFormat } from '@/lib/format'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
import type { CountHistoryPoint } from '@/types/game'
|
import type { CountHistoryPoint } from '@/types/game'
|
||||||
import { ChartCard } from './chart-card'
|
import { ChartCard } from './chart-card'
|
||||||
import { LINE_CURSOR, SERIES_ANIMATION, TOOLTIP_BASE } from './chart-theme'
|
import { chartAria, LINE_CURSOR, SERIES_ANIMATION, TOOLTIP_BASE } from './chart-theme'
|
||||||
import { ChartTooltipContent } from './chart-tooltip'
|
import { ChartTooltipContent } from './chart-tooltip'
|
||||||
import { PALETTE } from './palette'
|
import { PALETTE } from './palette'
|
||||||
|
|
||||||
@@ -11,14 +12,28 @@ export function GameCountChart({ history }: { history: CountHistoryPoint[] }) {
|
|||||||
const t = useT()
|
const t = useT()
|
||||||
const fmt = useFormat()
|
const fmt = useFormat()
|
||||||
return (
|
return (
|
||||||
<ChartCard title={t('charts.gameCount.title')} description={t('charts.gameCount.desc')}>
|
<ChartCard
|
||||||
|
id="game-count"
|
||||||
|
title={t('charts.gameCount.title')}
|
||||||
|
description={t('charts.gameCount.desc')}
|
||||||
|
table={
|
||||||
|
history.length
|
||||||
|
? {
|
||||||
|
label: t('charts.table.date'),
|
||||||
|
value: t('charts.series.games'),
|
||||||
|
rows: historyRows(history),
|
||||||
|
formatKey: fmt.date,
|
||||||
|
}
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
>
|
||||||
{history.length === 0 ? (
|
{history.length === 0 ? (
|
||||||
<p className="flex h-full items-center justify-center text-sm text-muted-foreground">
|
<p className="flex h-full items-center justify-center text-sm text-muted-foreground">
|
||||||
{t('charts.gameCount.empty')}
|
{t('charts.gameCount.empty')}
|
||||||
</p>
|
</p>
|
||||||
) : (
|
) : (
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
<ResponsiveContainer width="100%" height="100%">
|
||||||
<LineChart data={history} margin={{ left: 4, right: 8 }}>
|
<LineChart {...chartAria('game-count')} data={history} margin={{ left: 4, right: 8 }}>
|
||||||
<CartesianGrid strokeDasharray="3 3" />
|
<CartesianGrid strokeDasharray="3 3" />
|
||||||
<XAxis dataKey="date" tick={{ fontSize: 10 }} minTickGap={24} />
|
<XAxis dataKey="date" tick={{ fontSize: 10 }} minTickGap={24} />
|
||||||
<YAxis
|
<YAxis
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
||||||
import { countBy, topN } from '@/lib/analytics'
|
import { countBy, topN } from '@/lib/analytics'
|
||||||
|
import { tableRows } from '@/lib/chart-table'
|
||||||
import { useFormat } from '@/lib/format'
|
import { useFormat } from '@/lib/format'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
import type { Game } from '@/types/game'
|
import type { Game } from '@/types/game'
|
||||||
import { ChartCard } from './chart-card'
|
import { ChartCard } from './chart-card'
|
||||||
import { BAR_CURSOR, SERIES_ANIMATION, singleLineTick, TOOLTIP_BASE } from './chart-theme'
|
import { BAR_CURSOR, chartAria, SERIES_ANIMATION, singleLineTick, TOOLTIP_BASE } from './chart-theme'
|
||||||
import { ChartTooltipContent } from './chart-tooltip'
|
import { ChartTooltipContent } from './chart-tooltip'
|
||||||
import { PALETTE } from './palette'
|
import { PALETTE } from './palette'
|
||||||
|
|
||||||
@@ -15,9 +16,15 @@ export function GenreChart({ games }: { games: Game[] }) {
|
|||||||
const data = useMemo(() => topN(countBy(games, 'genre'), 15), [games])
|
const data = useMemo(() => topN(countBy(games, 'genre'), 15), [games])
|
||||||
return (
|
return (
|
||||||
// Taller on phones, where the cards stack: 15 rows get room to breathe.
|
// Taller on phones, where the cards stack: 15 rows get room to breathe.
|
||||||
<ChartCard title={t('charts.genre.title')} description={t('charts.genre.desc')} contentClassName="max-md:h-96">
|
<ChartCard
|
||||||
|
id="genre"
|
||||||
|
title={t('charts.genre.title')}
|
||||||
|
description={t('charts.genre.desc')}
|
||||||
|
contentClassName="max-md:h-96"
|
||||||
|
table={{ label: t('games.filter.genre'), value: t('charts.series.games'), rows: tableRows(data) }}
|
||||||
|
>
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
<ResponsiveContainer width="100%" height="100%">
|
||||||
<BarChart data={data} layout="vertical" margin={{ left: 20 }}>
|
<BarChart {...chartAria('genre')} data={data} layout="vertical" margin={{ left: 20 }}>
|
||||||
<CartesianGrid horizontal={false} strokeDasharray="3 3" />
|
<CartesianGrid horizontal={false} strokeDasharray="3 3" />
|
||||||
<XAxis type="number" tickFormatter={fmt.number} />
|
<XAxis type="number" tickFormatter={fmt.number} />
|
||||||
{/* interval 0: every label. The default drops those whose line box doesn't
|
{/* interval 0: every label. The default drops those whose line box doesn't
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { ResponsiveContainer, Tooltip, Treemap, type TooltipPayloadEntry } from 'recharts'
|
import { ResponsiveContainer, Tooltip, Treemap, type TooltipPayloadEntry } from 'recharts'
|
||||||
import { genreTreemapData } from '@/lib/analytics'
|
import { genreTreemapData } from '@/lib/analytics'
|
||||||
|
import { treemapRows } from '@/lib/chart-table'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
import type { Game } from '@/types/game'
|
import type { Game } from '@/types/game'
|
||||||
import { ChartCard } from './chart-card'
|
import { ChartCard } from './chart-card'
|
||||||
import { SERIES_ANIMATION, TOOLTIP_BASE, truncateLabel } from './chart-theme'
|
import { chartAria, SERIES_ANIMATION, TOOLTIP_BASE, truncateLabel } from './chart-theme'
|
||||||
import { ChartTooltipContent } from './chart-tooltip'
|
import { ChartTooltipContent } from './chart-tooltip'
|
||||||
import { PALETTE } from './palette'
|
import { PALETTE, PALETTE_LABEL } from './palette'
|
||||||
|
|
||||||
interface TreemapCellProps {
|
interface TreemapCellProps {
|
||||||
x?: number
|
x?: number
|
||||||
@@ -41,7 +42,7 @@ function TreemapCell(props: TreemapCellProps) {
|
|||||||
strokeWidth={2}
|
strokeWidth={2}
|
||||||
/>
|
/>
|
||||||
{label && height > 24 && (
|
{label && height > 24 && (
|
||||||
<text x={x + 6} y={y + 18} fill="var(--background)" fontSize={12} fontWeight={600}>
|
<text x={x + 6} y={y + 18} fill={PALETTE_LABEL[index % PALETTE.length]} fontSize={12} fontWeight={600}>
|
||||||
{label}
|
{label}
|
||||||
</text>
|
</text>
|
||||||
)}
|
)}
|
||||||
@@ -62,9 +63,23 @@ export function GenreTreemapChart({ games }: { games: Game[] }) {
|
|||||||
// are valid treemap data at runtime, so cast through unknown.
|
// are valid treemap data at runtime, so cast through unknown.
|
||||||
const treemapData = data as unknown as React.ComponentProps<typeof Treemap>['data']
|
const treemapData = data as unknown as React.ComponentProps<typeof Treemap>['data']
|
||||||
return (
|
return (
|
||||||
<ChartCard title={t('charts.genreTreemap.title')} description={t('charts.genreTreemap.desc')}>
|
// The treemap can't be stepped through with the keyboard: its table (and the Genres chart) carry the numbers.
|
||||||
|
<ChartCard
|
||||||
|
id="genre-treemap"
|
||||||
|
title={t('charts.genreTreemap.title')}
|
||||||
|
description={t('charts.genreTreemap.desc')}
|
||||||
|
keyboard={false}
|
||||||
|
table={{ label: t('games.filter.genre'), value: t('charts.series.games'), rows: treemapRows(data) }}
|
||||||
|
>
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
<ResponsiveContainer width="100%" height="100%">
|
||||||
<Treemap {...SERIES_ANIMATION} data={treemapData} dataKey="size" nameKey="name" content={<TreemapCell />}>
|
<Treemap
|
||||||
|
{...SERIES_ANIMATION}
|
||||||
|
{...chartAria('genre-treemap', { keys: false })}
|
||||||
|
data={treemapData}
|
||||||
|
dataKey="size"
|
||||||
|
nameKey="name"
|
||||||
|
content={<TreemapCell />}
|
||||||
|
>
|
||||||
<Tooltip {...TOOLTIP_BASE} content={<ChartTooltipContent colorOf={cellColor} />} />
|
<Tooltip {...TOOLTIP_BASE} content={<ChartTooltipContent colorOf={cellColor} />} />
|
||||||
</Treemap>
|
</Treemap>
|
||||||
</ResponsiveContainer>
|
</ResponsiveContainer>
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
||||||
import { countByArray, topN } from '@/lib/analytics'
|
import { countByArray, topN } from '@/lib/analytics'
|
||||||
|
import { tableRows } from '@/lib/chart-table'
|
||||||
import { useFormat } from '@/lib/format'
|
import { useFormat } from '@/lib/format'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
import { useIsMobile } from '@/lib/use-is-mobile'
|
import { useIsMobile } from '@/lib/use-is-mobile'
|
||||||
import type { Game } from '@/types/game'
|
import type { Game } from '@/types/game'
|
||||||
import { ChartCard } from './chart-card'
|
import { ChartCard } from './chart-card'
|
||||||
import { BAR_CURSOR, SERIES_ANIMATION, singleLineTick, TOOLTIP_BASE, truncateLabel } from './chart-theme'
|
import { BAR_CURSOR, chartAria, SERIES_ANIMATION, singleLineTick, TOOLTIP_BASE, truncateLabel } from './chart-theme'
|
||||||
import { ChartTooltipContent } from './chart-tooltip'
|
import { ChartTooltipContent } from './chart-tooltip'
|
||||||
import { PALETTE } from './palette'
|
import { PALETTE } from './palette'
|
||||||
|
|
||||||
@@ -17,9 +18,13 @@ export function LanguagesChart({ games }: { games: Game[] }) {
|
|||||||
const isMobile = useIsMobile()
|
const isMobile = useIsMobile()
|
||||||
const data = useMemo(() => topN(countByArray(games, 'languages'), 10), [games])
|
const data = useMemo(() => topN(countByArray(games, 'languages'), 10), [games])
|
||||||
return (
|
return (
|
||||||
<ChartCard title={t('charts.languages.title')}>
|
<ChartCard
|
||||||
|
id="languages"
|
||||||
|
title={t('charts.languages.title')}
|
||||||
|
table={{ label: t('games.filter.lang'), value: t('charts.series.games'), rows: tableRows(data) }}
|
||||||
|
>
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
<ResponsiveContainer width="100%" height="100%">
|
||||||
<BarChart data={data} layout={isMobile ? 'vertical' : 'horizontal'}>
|
<BarChart {...chartAria('languages')} data={data} layout={isMobile ? 'vertical' : 'horizontal'}>
|
||||||
<CartesianGrid horizontal={!isMobile} strokeDasharray="3 3" />
|
<CartesianGrid horizontal={!isMobile} strokeDasharray="3 3" />
|
||||||
{isMobile ? (
|
{isMobile ? (
|
||||||
<XAxis type="number" allowDecimals={false} tickFormatter={fmt.number} />
|
<XAxis type="number" allowDecimals={false} tickFormatter={fmt.number} />
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { Cell, Legend, Pie, PieChart, ResponsiveContainer, Tooltip } from 'recharts'
|
import { Cell, Legend, Pie, PieChart, ResponsiveContainer, Tooltip } from 'recharts'
|
||||||
import { topMadeWith } from '@/lib/analytics'
|
import { topMadeWith } from '@/lib/analytics'
|
||||||
|
import { tableRows } from '@/lib/chart-table'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
import type { Game } from '@/types/game'
|
import type { Game } from '@/types/game'
|
||||||
import { ChartCard } from './chart-card'
|
import { ChartCard } from './chart-card'
|
||||||
import { LEGEND_BASE, SERIES_ANIMATION, SLICE_STROKE, TOOLTIP_BASE } from './chart-theme'
|
import { chartAria, LEGEND_BASE, SERIES_ANIMATION, SLICE_STROKE, TOOLTIP_BASE } from './chart-theme'
|
||||||
import { ChartTooltipContent } from './chart-tooltip'
|
import { ChartTooltipContent } from './chart-tooltip'
|
||||||
import { PALETTE } from './palette'
|
import { PALETTE } from './palette'
|
||||||
|
|
||||||
@@ -12,11 +13,17 @@ export function MadeWithChart({ games }: { games: Game[] }) {
|
|||||||
const t = useT()
|
const t = useT()
|
||||||
const data = useMemo(() => topMadeWith(games, 8), [games])
|
const data = useMemo(() => topMadeWith(games, 8), [games])
|
||||||
return (
|
return (
|
||||||
<ChartCard title={t('charts.madeWith.title')} description={t('charts.madeWith.desc')}>
|
<ChartCard
|
||||||
|
id="made-with"
|
||||||
|
title={t('charts.madeWith.title')}
|
||||||
|
description={t('charts.madeWith.desc')}
|
||||||
|
table={{ label: t('games.filter.engine'), value: t('charts.series.games'), rows: tableRows(data) }}
|
||||||
|
>
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
<ResponsiveContainer width="100%" height="100%">
|
||||||
<PieChart>
|
<PieChart {...chartAria('made-with')}>
|
||||||
<Pie
|
<Pie
|
||||||
{...SERIES_ANIMATION}
|
{...SERIES_ANIMATION}
|
||||||
|
rootTabIndex={-1}
|
||||||
data={data}
|
data={data}
|
||||||
dataKey="count"
|
dataKey="count"
|
||||||
nameKey="key"
|
nameKey="key"
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { Cell, Legend, Pie, PieChart, ResponsiveContainer, Tooltip } from 'recharts'
|
import { Cell, Legend, Pie, PieChart, ResponsiveContainer, Tooltip } from 'recharts'
|
||||||
import { classifyOnline } from '@/lib/analytics'
|
import { classifyOnline } from '@/lib/analytics'
|
||||||
|
import { tableRows } from '@/lib/chart-table'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
import type { Game } from '@/types/game'
|
import type { Game } from '@/types/game'
|
||||||
import { ChartCard } from './chart-card'
|
import { ChartCard } from './chart-card'
|
||||||
import { LEGEND_BASE, SERIES_ANIMATION, SLICE_STROKE, TOOLTIP_BASE } from './chart-theme'
|
import { chartAria, LEGEND_BASE, SERIES_ANIMATION, SLICE_STROKE, TOOLTIP_BASE } from './chart-theme'
|
||||||
import { ChartTooltipContent } from './chart-tooltip'
|
import { ChartTooltipContent } from './chart-tooltip'
|
||||||
import { PALETTE } from './palette'
|
import { PALETTE } from './palette'
|
||||||
|
|
||||||
@@ -16,12 +17,32 @@ export function OnlineOfflineChart({ games }: { games: Game[] }) {
|
|||||||
{ key: t('charts.onlineOffline.offline'), count: split.offline },
|
{ key: t('charts.onlineOffline.offline'), count: split.offline },
|
||||||
]
|
]
|
||||||
return (
|
return (
|
||||||
<ChartCard title={t('charts.onlineOffline.title')} description={t('charts.onlineOffline.desc')}>
|
<ChartCard
|
||||||
|
id="online-offline"
|
||||||
|
title={t('charts.onlineOffline.title')}
|
||||||
|
description={t('charts.onlineOffline.desc')}
|
||||||
|
table={{
|
||||||
|
label: t('charts.table.kind'),
|
||||||
|
value: t('charts.series.games'),
|
||||||
|
rows: tableRows(data, split.online + split.offline),
|
||||||
|
}}
|
||||||
|
>
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
<ResponsiveContainer width="100%" height="100%">
|
||||||
<PieChart>
|
<PieChart {...chartAria('online-offline')}>
|
||||||
<Pie {...SERIES_ANIMATION} data={data} dataKey="count" nameKey="key" innerRadius="50%" outerRadius="80%" stroke={SLICE_STROKE}>
|
{/* Blue and orange: apart in lightness and for colour-blind readers (green and amber were not). */}
|
||||||
<Cell fill={PALETTE[2]} />
|
<Pie
|
||||||
<Cell fill={PALETTE[3]} />
|
{...SERIES_ANIMATION}
|
||||||
|
rootTabIndex={-1}
|
||||||
|
data={data}
|
||||||
|
dataKey="count"
|
||||||
|
nameKey="key"
|
||||||
|
innerRadius="50%"
|
||||||
|
outerRadius="80%"
|
||||||
|
paddingAngle={2}
|
||||||
|
stroke={SLICE_STROKE}
|
||||||
|
>
|
||||||
|
<Cell fill={PALETTE[4]} />
|
||||||
|
<Cell fill={PALETTE[6]} />
|
||||||
</Pie>
|
</Pie>
|
||||||
<Tooltip {...TOOLTIP_BASE} content={<ChartTooltipContent total={split.online + split.offline} />} />
|
<Tooltip {...TOOLTIP_BASE} content={<ChartTooltipContent total={split.online + split.offline} />} />
|
||||||
<Legend {...LEGEND_BASE} />
|
<Legend {...LEGEND_BASE} />
|
||||||
|
|||||||
@@ -1,17 +1,25 @@
|
|||||||
|
import { readableOn } from '@/lib/color'
|
||||||
|
|
||||||
// Shared chart colour palette. Kept in its own file so chart-card.tsx
|
// Shared chart colour palette. Kept in its own file so chart-card.tsx
|
||||||
// stays a component-only module (React Fast Refresh friendly).
|
// stays a component-only module (React Fast Refresh friendly).
|
||||||
|
// Every colour keeps 3:1 against the card in both themes (WCAG 1.4.11; the
|
||||||
|
// green, amber, sky, orange and emerald were darkened for the light card) —
|
||||||
|
// src/contrast.test.ts checks it.
|
||||||
export const PALETTE = [
|
export const PALETTE = [
|
||||||
'#7c5cff', // the site accent (--primary)
|
'#7c5cff', // the brand purple (--brand)
|
||||||
'hsl(330 81% 60%)',
|
'#ec4699',
|
||||||
'hsl(142 71% 45%)',
|
'#1b9d4a',
|
||||||
'hsl(38 92% 50%)',
|
'#c76c05',
|
||||||
'hsl(217 91% 60%)',
|
'#3c83f6',
|
||||||
'hsl(199 89% 48%)',
|
'#0b84bc',
|
||||||
'hsl(20 90% 55%)',
|
'#e9560c',
|
||||||
'hsl(173 58% 39%)',
|
'#2a9d90',
|
||||||
'hsl(280 65% 60%)',
|
'#af57db',
|
||||||
'hsl(160 60% 45%)',
|
'#238b68',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
/** Label colour for text drawn on each palette colour (the treemap cells), 4.5:1 or better. */
|
||||||
|
export const PALETTE_LABEL = PALETTE.map((color) => readableOn(color))
|
||||||
|
|
||||||
/** "Unknown / not disclosed" slices: a mid gray that reads on both themes' cards. */
|
/** "Unknown / not disclosed" slices: a mid gray that reads on both themes' cards. */
|
||||||
export const NEUTRAL = '#6b6b74'
|
export const NEUTRAL = '#6b6b74'
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { Cell, Legend, Pie, PieChart, ResponsiveContainer, Tooltip } from 'recharts'
|
import { Cell, Legend, Pie, PieChart, ResponsiveContainer, Tooltip } from 'recharts'
|
||||||
import { countByArray } from '@/lib/analytics'
|
import { countByArray } from '@/lib/analytics'
|
||||||
|
import { tableRows } from '@/lib/chart-table'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
import type { Game } from '@/types/game'
|
import type { Game } from '@/types/game'
|
||||||
import { ChartCard } from './chart-card'
|
import { ChartCard } from './chart-card'
|
||||||
import { LEGEND_BASE, SERIES_ANIMATION, SLICE_STROKE, TOOLTIP_BASE } from './chart-theme'
|
import { chartAria, LEGEND_BASE, SERIES_ANIMATION, SLICE_STROKE, TOOLTIP_BASE } from './chart-theme'
|
||||||
import { ChartTooltipContent } from './chart-tooltip'
|
import { ChartTooltipContent } from './chart-tooltip'
|
||||||
import { PALETTE } from './palette'
|
import { PALETTE } from './palette'
|
||||||
|
|
||||||
@@ -12,11 +13,18 @@ export function PlatformChart({ games }: { games: Game[] }) {
|
|||||||
const t = useT()
|
const t = useT()
|
||||||
const data = useMemo(() => countByArray(games, 'platforms'), [games])
|
const data = useMemo(() => countByArray(games, 'platforms'), [games])
|
||||||
return (
|
return (
|
||||||
<ChartCard title={t('charts.platform.title')} description={t('charts.platform.desc')}>
|
// No shares in the table: a game can count for several platforms.
|
||||||
|
<ChartCard
|
||||||
|
id="platform"
|
||||||
|
title={t('charts.platform.title')}
|
||||||
|
description={t('charts.platform.desc')}
|
||||||
|
table={{ label: t('games.filter.platform'), value: t('charts.series.games'), rows: tableRows(data) }}
|
||||||
|
>
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
<ResponsiveContainer width="100%" height="100%">
|
||||||
<PieChart>
|
<PieChart {...chartAria('platform')}>
|
||||||
<Pie
|
<Pie
|
||||||
{...SERIES_ANIMATION}
|
{...SERIES_ANIMATION}
|
||||||
|
rootTabIndex={-1}
|
||||||
data={data}
|
data={data}
|
||||||
dataKey="count"
|
dataKey="count"
|
||||||
nameKey="key"
|
nameKey="key"
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
||||||
import { ratingHistogram } from '@/lib/analytics'
|
import { ratingHistogram } from '@/lib/analytics'
|
||||||
|
import { tableRows } from '@/lib/chart-table'
|
||||||
import { useFormat } from '@/lib/format'
|
import { useFormat } from '@/lib/format'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
import type { Game } from '@/types/game'
|
import type { Game } from '@/types/game'
|
||||||
import { ChartCard } from './chart-card'
|
import { ChartCard } from './chart-card'
|
||||||
import { BAR_CURSOR, SERIES_ANIMATION, TOOLTIP_BASE } from './chart-theme'
|
import { BAR_CURSOR, chartAria, SERIES_ANIMATION, TOOLTIP_BASE } from './chart-theme'
|
||||||
import { ChartTooltipContent } from './chart-tooltip'
|
import { ChartTooltipContent } from './chart-tooltip'
|
||||||
import { PALETTE } from './palette'
|
import { PALETTE } from './palette'
|
||||||
|
|
||||||
@@ -14,9 +15,14 @@ export function RatingChart({ games }: { games: Game[] }) {
|
|||||||
const fmt = useFormat()
|
const fmt = useFormat()
|
||||||
const data = useMemo(() => ratingHistogram(games, 10), [games])
|
const data = useMemo(() => ratingHistogram(games, 10), [games])
|
||||||
return (
|
return (
|
||||||
<ChartCard title={t('charts.rating.title')} description={t('charts.rating.desc')}>
|
<ChartCard
|
||||||
|
id="rating"
|
||||||
|
title={t('charts.rating.title')}
|
||||||
|
description={t('charts.rating.desc')}
|
||||||
|
table={{ label: t('games.filter.rating'), value: t('charts.series.games'), rows: tableRows(data) }}
|
||||||
|
>
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
<ResponsiveContainer width="100%" height="100%">
|
||||||
<BarChart data={data}>
|
<BarChart {...chartAria('rating')} data={data}>
|
||||||
<CartesianGrid strokeDasharray="3 3" />
|
<CartesianGrid strokeDasharray="3 3" />
|
||||||
<XAxis dataKey="key" tick={{ fontSize: 10 }} />
|
<XAxis dataKey="key" tick={{ fontSize: 10 }} />
|
||||||
<YAxis tickFormatter={fmt.number} />
|
<YAxis tickFormatter={fmt.number} />
|
||||||
|
|||||||
@@ -18,15 +18,17 @@ export function RecentDeletedChart({ deleted }: { deleted: DeletedGameEntry[] })
|
|||||||
)
|
)
|
||||||
return (
|
return (
|
||||||
<ChartCard
|
<ChartCard
|
||||||
|
id="recent-deleted"
|
||||||
|
keyboard={false}
|
||||||
title={t('charts.recentDeleted.title')}
|
title={t('charts.recentDeleted.title')}
|
||||||
description={t('charts.recentDeleted.desc', { shown: recent.length, total: fmt.number(deleted.length) })}
|
description={t('charts.recentDeleted.desc', { shown: recent.length, total: fmt.number(deleted.length) })}
|
||||||
>
|
>
|
||||||
<div className="h-full overflow-y-auto pr-2">
|
<div className="h-full overflow-y-auto pr-2">
|
||||||
<ul className="space-y-1.5 text-sm">
|
{recent.length === 0 ? (
|
||||||
{recent.length === 0 ? (
|
<p className="text-sm text-muted-foreground">{t('charts.recentDeleted.empty')}</p>
|
||||||
<p className="text-muted-foreground">{t('charts.recentDeleted.empty')}</p>
|
) : (
|
||||||
) : (
|
<ul className="space-y-1.5 text-sm">
|
||||||
recent.map((d) => {
|
{recent.map((d) => {
|
||||||
const key = reasonKey(d.reason)
|
const key = reasonKey(d.reason)
|
||||||
return (
|
return (
|
||||||
// Phones: the reason goes under the name, which would otherwise shrink to a few letters.
|
// Phones: the reason goes under the name, which would otherwise shrink to a few letters.
|
||||||
@@ -44,9 +46,9 @@ export function RecentDeletedChart({ deleted }: { deleted: DeletedGameEntry[] })
|
|||||||
</Badge>
|
</Badge>
|
||||||
</li>
|
</li>
|
||||||
)
|
)
|
||||||
})
|
})}
|
||||||
)}
|
</ul>
|
||||||
</ul>
|
)}
|
||||||
</div>
|
</div>
|
||||||
</ChartCard>
|
</ChartCard>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { Cell, Legend, Pie, PieChart, ResponsiveContainer, Tooltip } from 'recharts'
|
import { Cell, Legend, Pie, PieChart, ResponsiveContainer, Tooltip } from 'recharts'
|
||||||
import { countBy } from '@/lib/analytics'
|
import { countBy } from '@/lib/analytics'
|
||||||
|
import { tableRows } from '@/lib/chart-table'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
import type { Game } from '@/types/game'
|
import type { Game } from '@/types/game'
|
||||||
import { ChartCard } from './chart-card'
|
import { ChartCard } from './chart-card'
|
||||||
import { LEGEND_BASE, SERIES_ANIMATION, SLICE_STROKE, TOOLTIP_BASE } from './chart-theme'
|
import { chartAria, LEGEND_BASE, SERIES_ANIMATION, SLICE_STROKE, TOOLTIP_BASE } from './chart-theme'
|
||||||
import { ChartTooltipContent } from './chart-tooltip'
|
import { ChartTooltipContent } from './chart-tooltip'
|
||||||
import { PALETTE } from './palette'
|
import { PALETTE } from './palette'
|
||||||
|
|
||||||
@@ -13,10 +14,23 @@ export function StatusChart({ games }: { games: Game[] }) {
|
|||||||
const data = useMemo(() => countBy(games, 'status'), [games])
|
const data = useMemo(() => countBy(games, 'status'), [games])
|
||||||
const total = data.reduce((sum, d) => sum + d.count, 0)
|
const total = data.reduce((sum, d) => sum + d.count, 0)
|
||||||
return (
|
return (
|
||||||
<ChartCard title={t('charts.status.title')} description={t('charts.status.desc')}>
|
<ChartCard
|
||||||
|
id="status"
|
||||||
|
title={t('charts.status.title')}
|
||||||
|
description={t('charts.status.desc')}
|
||||||
|
table={{ label: t('games.filter.status'), value: t('charts.series.games'), rows: tableRows(data, total) }}
|
||||||
|
>
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
<ResponsiveContainer width="100%" height="100%">
|
||||||
<PieChart>
|
<PieChart {...chartAria('status')}>
|
||||||
<Pie {...SERIES_ANIMATION} data={data} dataKey="count" nameKey="key" outerRadius="80%" stroke={SLICE_STROKE}>
|
<Pie
|
||||||
|
{...SERIES_ANIMATION}
|
||||||
|
rootTabIndex={-1}
|
||||||
|
data={data}
|
||||||
|
dataKey="count"
|
||||||
|
nameKey="key"
|
||||||
|
outerRadius="80%"
|
||||||
|
stroke={SLICE_STROKE}
|
||||||
|
>
|
||||||
{data.map((_, i) => (
|
{data.map((_, i) => (
|
||||||
<Cell key={i} fill={PALETTE[i % PALETTE.length]} />
|
<Cell key={i} fill={PALETTE[i % PALETTE.length]} />
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
|
||||||
import { topByRatingCount } from '@/lib/analytics'
|
import { topByRatingCount } from '@/lib/analytics'
|
||||||
|
import { tableRows } from '@/lib/chart-table'
|
||||||
import { useFormat } from '@/lib/format'
|
import { useFormat } from '@/lib/format'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
import type { Game } from '@/types/game'
|
import type { Game } from '@/types/game'
|
||||||
import { ChartCard } from './chart-card'
|
import { ChartCard } from './chart-card'
|
||||||
import { BAR_CURSOR, SERIES_ANIMATION, TOOLTIP_BASE, truncateLabel } from './chart-theme'
|
import { BAR_CURSOR, chartAria, SERIES_ANIMATION, TOOLTIP_BASE, truncateLabel } from './chart-theme'
|
||||||
import { ChartTooltipContent } from './chart-tooltip'
|
import { ChartTooltipContent } from './chart-tooltip'
|
||||||
import { PALETTE } from './palette'
|
import { PALETTE } from './palette'
|
||||||
|
|
||||||
@@ -14,9 +15,14 @@ export function TopRatedCountChart({ games }: { games: Game[] }) {
|
|||||||
const fmt = useFormat()
|
const fmt = useFormat()
|
||||||
const data = useMemo(() => topByRatingCount(games, 10), [games])
|
const data = useMemo(() => topByRatingCount(games, 10), [games])
|
||||||
return (
|
return (
|
||||||
<ChartCard title={t('charts.topRatedCount.title')} description={t('charts.topRatedCount.desc')}>
|
<ChartCard
|
||||||
|
id="top-rated-count"
|
||||||
|
title={t('charts.topRatedCount.title')}
|
||||||
|
description={t('charts.topRatedCount.desc')}
|
||||||
|
table={{ label: t('games.col.game'), value: t('charts.series.ratings'), rows: tableRows(data) }}
|
||||||
|
>
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
<ResponsiveContainer width="100%" height="100%">
|
||||||
<BarChart data={data} layout="vertical" margin={{ left: 20 }}>
|
<BarChart {...chartAria('top-rated-count')} data={data} layout="vertical" margin={{ left: 20 }}>
|
||||||
<CartesianGrid horizontal={false} strokeDasharray="3 3" />
|
<CartesianGrid horizontal={false} strokeDasharray="3 3" />
|
||||||
<XAxis type="number" allowDecimals={false} tickFormatter={fmt.number} />
|
<XAxis type="number" allowDecimals={false} tickFormatter={fmt.number} />
|
||||||
<YAxis
|
<YAxis
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { countByArray, topN } from '@/lib/analytics'
|
import { countByArray, topN } from '@/lib/analytics'
|
||||||
|
import { tableRows } from '@/lib/chart-table'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
import type { Game } from '@/types/game'
|
import type { Game } from '@/types/game'
|
||||||
import { ChartCard } from './chart-card'
|
import { ChartCard } from './chart-card'
|
||||||
@@ -8,7 +9,14 @@ export function TopTagsChart({ games }: { games: Game[] }) {
|
|||||||
const t = useT()
|
const t = useT()
|
||||||
const data = useMemo(() => topN(countByArray(games, 'tags'), 30), [games])
|
const data = useMemo(() => topN(countByArray(games, 'tags'), 30), [games])
|
||||||
return (
|
return (
|
||||||
<ChartCard title={t('charts.topTags.title')} description={t('charts.topTags.desc')}>
|
// The counts are shown only by size here (and in a hover title): the table reads them out.
|
||||||
|
<ChartCard
|
||||||
|
id="top-tags"
|
||||||
|
title={t('charts.topTags.title')}
|
||||||
|
description={t('charts.topTags.desc')}
|
||||||
|
keyboard={false}
|
||||||
|
table={{ label: t('games.filter.tag'), value: t('charts.series.games'), rows: tableRows(data) }}
|
||||||
|
>
|
||||||
<div className="flex h-full flex-wrap content-start items-baseline gap-2 overflow-y-auto p-2">
|
<div className="flex h-full flex-wrap content-start items-baseline gap-2 overflow-y-auto p-2">
|
||||||
{data.map((tag) => {
|
{data.map((tag) => {
|
||||||
const fontSize = computeTagFontSize(tag.count, data[0]?.count ?? 1)
|
const fontSize = computeTagFontSize(tag.count, data[0]?.count ?? 1)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { forwardRef, type AnchorHTMLAttributes, type MouseEvent } from 'react'
|
import { forwardRef, type AnchorHTMLAttributes, type MouseEvent } from 'react'
|
||||||
|
import { useT } from '@/lib/i18n'
|
||||||
import { isTauri } from '@/lib/runtime'
|
import { isTauri } from '@/lib/runtime'
|
||||||
import { openExternal } from '@/lib/external-link'
|
import { openExternal } from '@/lib/external-link'
|
||||||
|
|
||||||
@@ -6,8 +7,14 @@ export interface ExtLinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElemen
|
|||||||
href: string
|
href: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A link that leaves the app: a new tab on the website, the system browser in
|
||||||
|
* the apps. Screen readers hear where it opens (a hidden hint after the text,
|
||||||
|
* or appended to an aria-label), since the visible arrow isn't always there.
|
||||||
|
*/
|
||||||
export const ExtLink = forwardRef<HTMLAnchorElement, ExtLinkProps>(
|
export const ExtLink = forwardRef<HTMLAnchorElement, ExtLinkProps>(
|
||||||
({ href, onClick, children, ...rest }, ref) => {
|
({ href, onClick, children, 'aria-label': ariaLabel, ...rest }, ref) => {
|
||||||
|
const t = useT()
|
||||||
const handleClick = (e: MouseEvent<HTMLAnchorElement>) => {
|
const handleClick = (e: MouseEvent<HTMLAnchorElement>) => {
|
||||||
onClick?.(e)
|
onClick?.(e)
|
||||||
if (e.defaultPrevented) return
|
if (e.defaultPrevented) return
|
||||||
@@ -18,6 +25,7 @@ export const ExtLink = forwardRef<HTMLAnchorElement, ExtLinkProps>(
|
|||||||
}
|
}
|
||||||
// mailto: hands off to the mail client; a new tab would just stay blank.
|
// mailto: hands off to the mail client; a new tab would just stay blank.
|
||||||
const newTab = !href.startsWith('mailto:')
|
const newTab = !href.startsWith('mailto:')
|
||||||
|
const hint = newTab ? t(isTauri() ? 'common.opensBrowser' : 'common.newTab') : null
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
ref={ref}
|
ref={ref}
|
||||||
@@ -25,9 +33,11 @@ export const ExtLink = forwardRef<HTMLAnchorElement, ExtLinkProps>(
|
|||||||
target={newTab ? '_blank' : undefined}
|
target={newTab ? '_blank' : undefined}
|
||||||
rel={newTab ? 'noopener noreferrer' : undefined}
|
rel={newTab ? 'noopener noreferrer' : undefined}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
|
aria-label={ariaLabel && hint ? `${ariaLabel} ${hint}` : ariaLabel}
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
{hint && !ariaLabel && <span className="sr-only"> {hint}</span>}
|
||||||
</a>
|
</a>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
// DOM helpers for moving keyboard focus where a screen reader should start
|
||||||
|
// reading: the new page's heading after a navigation, a #section, or back to
|
||||||
|
// the control a dialog was opened from. Kept out of src/lib (they need a DOM).
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls `found` with what `find` returns, right away or as soon as it appears
|
||||||
|
* inside <main> (routes are lazy chunks; on a slow connection their content
|
||||||
|
* can take seconds). Gives up after `timeout` ms and calls `missing`, if
|
||||||
|
* given. Returns a cancel.
|
||||||
|
*/
|
||||||
|
export function whenPresent<T extends Element>(
|
||||||
|
find: () => T | null,
|
||||||
|
found: (el: T) => void,
|
||||||
|
{ timeout = 10_000, missing }: { timeout?: number; missing?: () => void } = {},
|
||||||
|
): () => void {
|
||||||
|
const now = find()
|
||||||
|
if (now) {
|
||||||
|
found(now)
|
||||||
|
return () => {}
|
||||||
|
}
|
||||||
|
const observer = new MutationObserver(() => {
|
||||||
|
const el = find()
|
||||||
|
if (!el) return
|
||||||
|
stop()
|
||||||
|
found(el)
|
||||||
|
})
|
||||||
|
const timer = window.setTimeout(() => {
|
||||||
|
stop()
|
||||||
|
missing?.()
|
||||||
|
}, timeout)
|
||||||
|
function stop() {
|
||||||
|
observer.disconnect()
|
||||||
|
window.clearTimeout(timer)
|
||||||
|
}
|
||||||
|
observer.observe(document.getElementById('main') ?? document.body, { childList: true, subtree: true })
|
||||||
|
return stop
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Focuses an element without scrolling. One that can't take focus by itself
|
||||||
|
* (a heading, a section; links and buttons can) gets tabindex=-1 and
|
||||||
|
* `data-focus-target`, which hides the focus ring there (index.css): it marks
|
||||||
|
* where reading starts, it isn't a control.
|
||||||
|
*/
|
||||||
|
export function focusElement(el: HTMLElement): void {
|
||||||
|
if (el.tabIndex < 0 && !el.hasAttribute('tabindex')) {
|
||||||
|
el.setAttribute('tabindex', '-1')
|
||||||
|
el.setAttribute('data-focus-target', '')
|
||||||
|
}
|
||||||
|
el.focus({ preventScroll: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The current page's h1. */
|
||||||
|
export function pageHeading(): HTMLElement | null {
|
||||||
|
return document.querySelector<HTMLElement>('#main h1')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Focus the page's h1, or <main> while there is none (a loading page). */
|
||||||
|
export function focusPageHeading(): void {
|
||||||
|
const el = pageHeading() ?? document.getElementById('main')
|
||||||
|
if (el) focusElement(el)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True while focus is still where it was when a wait started (or nowhere):
|
||||||
|
* a late focus move must not pull the visitor back from where they went.
|
||||||
|
*/
|
||||||
|
export function focusUntouchedSince(before: Element | null): boolean {
|
||||||
|
const now = document.activeElement
|
||||||
|
return now === before || now === null || now === document.body
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Smooth scrolling, unless the visitor asked the system for less motion. */
|
||||||
|
export function scrollBehavior(): ScrollBehavior {
|
||||||
|
return window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'smooth'
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useMemo, useState, type ReactNode } from 'react'
|
import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
|
||||||
import { ChevronDown, Eye, EyeOff, X } from 'lucide-react'
|
import { ChevronDown, Eye, EyeOff, X } from 'lucide-react'
|
||||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
|
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
|
||||||
import { fold, RATING_STEPS } from '@/lib/game-filters'
|
import { fold, RATING_STEPS } from '@/lib/game-filters'
|
||||||
@@ -66,9 +66,21 @@ export function FilterMenu({
|
|||||||
/** Called when the menu opens, so counts are only computed for the open menu. */
|
/** Called when the menu opens, so counts are only computed for the open menu. */
|
||||||
getOptions: () => FilterOption[]
|
getOptions: () => FilterOption[]
|
||||||
}) {
|
}) {
|
||||||
|
const t = useT()
|
||||||
return (
|
return (
|
||||||
<ChipPopover
|
<ChipPopover
|
||||||
label={selected.length ? `${label} · ${selected.length}` : label}
|
label={
|
||||||
|
selected.length ? (
|
||||||
|
<>
|
||||||
|
{label}
|
||||||
|
{/* "Genre · 2" on screen, "Genre, 2 selected" for screen readers (the visible words stay first). */}
|
||||||
|
<span aria-hidden="true"> · {selected.length}</span>
|
||||||
|
<span className="sr-only">, {t('games.filter.selected', { n: selected.length })}</span>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
label
|
||||||
|
)
|
||||||
|
}
|
||||||
name={label}
|
name={label}
|
||||||
active={selected.length > 0}
|
active={selected.length > 0}
|
||||||
wide
|
wide
|
||||||
@@ -93,6 +105,8 @@ function FilterOptions({
|
|||||||
const fmt = useFormat()
|
const fmt = useFormat()
|
||||||
const [find, setFind] = useState('')
|
const [find, setFind] = useState('')
|
||||||
const options = useMemo(() => getOptions(), [getOptions])
|
const options = useMemo(() => getOptions(), [getOptions])
|
||||||
|
const finder = useRef<HTMLInputElement>(null)
|
||||||
|
const group = useRef<HTMLDivElement>(null)
|
||||||
|
|
||||||
const needle = fold(find.trim())
|
const needle = fold(find.trim())
|
||||||
const matching = needle ? options.filter((o) => fold(o.label).includes(needle)) : options
|
const matching = needle ? options.filter((o) => fold(o.label).includes(needle)) : options
|
||||||
@@ -109,16 +123,17 @@ function FilterOptions({
|
|||||||
{options.length > 8 && (
|
{options.length > 8 && (
|
||||||
<div className="border-b p-2">
|
<div className="border-b p-2">
|
||||||
<input
|
<input
|
||||||
|
ref={finder}
|
||||||
type="search"
|
type="search"
|
||||||
value={find}
|
value={find}
|
||||||
onChange={(e) => setFind(e.target.value)}
|
onChange={(e) => setFind(e.target.value)}
|
||||||
placeholder={t('common.search')}
|
placeholder={t('common.search')}
|
||||||
aria-label={`${t('common.search')}: ${label}`}
|
aria-label={`${t('common.search')}: ${label}`}
|
||||||
className="h-8 w-full rounded-md border bg-background px-2.5 text-sm outline-hidden focus:border-primary"
|
className="h-8 w-full rounded-md border border-input bg-background px-2.5 text-sm focus:border-primary focus:ring-1 focus:ring-primary focus-visible:outline-hidden"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div role="group" aria-label={label} className="min-h-0 flex-1 overflow-y-auto overscroll-contain p-1">
|
<div ref={group} role="group" aria-label={label} className="min-h-0 flex-1 overflow-y-auto overscroll-contain p-1">
|
||||||
<ul>
|
<ul>
|
||||||
{listed.map((o) => (
|
{listed.map((o) => (
|
||||||
<li key={o.value}>
|
<li key={o.value}>
|
||||||
@@ -130,7 +145,12 @@ function FilterOptions({
|
|||||||
className="size-4 shrink-0 accent-primary"
|
className="size-4 shrink-0 accent-primary"
|
||||||
/>
|
/>
|
||||||
<span className="min-w-0 flex-1 truncate">{o.label}</span>
|
<span className="min-w-0 flex-1 truncate">{o.label}</span>
|
||||||
<span className="font-mono text-xs text-muted-foreground">{fmt.number(o.count)}</span>
|
<span className="font-mono text-xs text-muted-foreground">
|
||||||
|
<span aria-hidden="true">{fmt.number(o.count)}</span>
|
||||||
|
<span className="sr-only">
|
||||||
|
, {t(o.count === 1 ? 'games.countShort.one' : 'games.countShort', { n: fmt.number(o.count) })}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
@@ -148,7 +168,12 @@ function FilterOptions({
|
|||||||
<div className="border-t p-1.5">
|
<div className="border-t p-1.5">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => onChange([])}
|
onClick={() => {
|
||||||
|
onChange([])
|
||||||
|
// This button goes away with the selection: keep focus inside the menu.
|
||||||
|
const next = finder.current ?? group.current?.querySelector('input')
|
||||||
|
next?.focus()
|
||||||
|
}}
|
||||||
className="h-8 w-full rounded-md text-sm text-muted-foreground hover:bg-accent hover:text-foreground"
|
className="h-8 w-full rounded-md text-sm text-muted-foreground hover:bg-accent hover:text-foreground"
|
||||||
>
|
>
|
||||||
{t('games.filter.clear')}
|
{t('games.filter.clear')}
|
||||||
@@ -165,7 +190,21 @@ export function RatingMenu({ value, onChange }: { value: number | null; onChange
|
|||||||
const fmt = useFormat()
|
const fmt = useFormat()
|
||||||
const label = t('games.filter.rating')
|
const label = t('games.filter.rating')
|
||||||
return (
|
return (
|
||||||
<ChipPopover label={value === null ? label : `${label} · ${fmt.rating(value)}+`} name={label} active={value !== null}>
|
<ChipPopover
|
||||||
|
label={
|
||||||
|
value === null ? (
|
||||||
|
label
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{label}
|
||||||
|
<span aria-hidden="true"> · {fmt.rating(value)}+</span>
|
||||||
|
<span className="sr-only">, {t('games.filter.ratingMin', { n: fmt.rating(value) })}</span>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
name={label}
|
||||||
|
active={value !== null}
|
||||||
|
>
|
||||||
<div role="radiogroup" aria-label={label} className="p-1">
|
<div role="radiogroup" aria-label={label} className="p-1">
|
||||||
{[null, ...RATING_STEPS].map((step) => (
|
{[null, ...RATING_STEPS].map((step) => (
|
||||||
<label
|
<label
|
||||||
@@ -209,6 +248,8 @@ export function NsfwChip({ shown, onShow, onHide }: { shown: boolean; onShow: ()
|
|||||||
>
|
>
|
||||||
<Icon className="size-3.5" aria-hidden="true" />
|
<Icon className="size-3.5" aria-hidden="true" />
|
||||||
{t(shown ? 'games.nsfw.shown' : 'games.nsfw.hidden')}
|
{t(shown ? 'games.nsfw.shown' : 'games.nsfw.hidden')}
|
||||||
|
{/* The title tooltip isn't read out: say what pressing it does. */}
|
||||||
|
<span className="sr-only">, {t(shown ? 'games.nsfw.hide' : 'games.nsfw.show')}</span>
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -219,19 +260,46 @@ export interface ActivePill {
|
|||||||
onRemove: () => void
|
onRemove: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
/** "Filters: Visual Novel ✕ · Rating ≥ 4.5 ✕ · Clear all". */
|
/**
|
||||||
export function ActiveFilters({ pills, onClearAll }: { pills: ActivePill[]; onClearAll: () => void }) {
|
* "Filters: Visual Novel ✕ · Rating ≥ 4.5 ✕ · Clear all". A removed pill takes its
|
||||||
|
* button with it: focus moves to the next remove button, or to `onEmpty` (the search
|
||||||
|
* box) once none is left.
|
||||||
|
*/
|
||||||
|
export function ActiveFilters({
|
||||||
|
pills,
|
||||||
|
onClearAll,
|
||||||
|
onEmpty,
|
||||||
|
}: {
|
||||||
|
pills: ActivePill[]
|
||||||
|
onClearAll: () => void
|
||||||
|
onEmpty?: () => void
|
||||||
|
}) {
|
||||||
const t = useT()
|
const t = useT()
|
||||||
|
const wrap = useRef<HTMLDivElement>(null)
|
||||||
|
const refocus = useRef<number | null>(null)
|
||||||
|
useEffect(() => {
|
||||||
|
const index = refocus.current
|
||||||
|
if (index === null) return
|
||||||
|
refocus.current = null
|
||||||
|
const buttons = wrap.current?.querySelectorAll<HTMLButtonElement>('button[data-remove]')
|
||||||
|
const next = buttons?.[Math.min(index, buttons.length - 1)]
|
||||||
|
if (next) next.focus()
|
||||||
|
else onEmpty?.()
|
||||||
|
}, [pills, onEmpty])
|
||||||
if (pills.length === 0) return null
|
if (pills.length === 0) return null
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-wrap items-center gap-2 text-[13px] text-muted-foreground">
|
<div ref={wrap} className="flex flex-wrap items-center gap-2 text-[13px] text-muted-foreground">
|
||||||
<span>{t('games.active')}</span>
|
<span>{t('games.active')}</span>
|
||||||
{pills.map((p) => (
|
{pills.map((p, i) => (
|
||||||
<span key={p.key} className="flex items-center gap-1 rounded-full bg-brand-soft py-0.5 pr-1 pl-2.5 text-foreground">
|
<span key={p.key} className="flex items-center gap-1 rounded-full bg-brand-soft py-0.5 pr-1 pl-2.5 text-foreground">
|
||||||
{p.label}
|
{p.label}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={p.onRemove}
|
data-remove
|
||||||
|
onClick={() => {
|
||||||
|
refocus.current = i
|
||||||
|
p.onRemove()
|
||||||
|
}}
|
||||||
aria-label={t('games.pill.remove', { label: p.label })}
|
aria-label={t('games.pill.remove', { label: p.label })}
|
||||||
className="flex size-6 items-center justify-center rounded-full text-muted-foreground hover:text-foreground"
|
className="flex size-6 items-center justify-center rounded-full text-muted-foreground hover:text-foreground"
|
||||||
>
|
>
|
||||||
@@ -239,7 +307,14 @@ export function ActiveFilters({ pills, onClearAll }: { pills: ActivePill[]; onCl
|
|||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
<button type="button" onClick={onClearAll} className="ml-1 underline underline-offset-4 hover:text-foreground">
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => {
|
||||||
|
refocus.current = 0
|
||||||
|
onClearAll()
|
||||||
|
}}
|
||||||
|
className="ml-1 underline underline-offset-4 hover:text-foreground"
|
||||||
|
>
|
||||||
{t('games.clearAll')}
|
{t('games.clearAll')}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ function Rating({ game, withCount }: { game: Game; withCount?: boolean }) {
|
|||||||
if (rating === null) {
|
if (rating === null) {
|
||||||
return (
|
return (
|
||||||
<span className="text-muted-foreground" title={t('games.noRating')}>
|
<span className="text-muted-foreground" title={t('games.noRating')}>
|
||||||
—
|
<span aria-hidden="true">—</span>
|
||||||
|
<span className="sr-only">{t('games.noRating')}</span>
|
||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -43,14 +44,18 @@ function Rating({ game, withCount }: { game: Game; withCount?: boolean }) {
|
|||||||
return (
|
return (
|
||||||
<span className="font-mono text-[13px] whitespace-nowrap">
|
<span className="font-mono text-[13px] whitespace-nowrap">
|
||||||
<span aria-hidden="true">★ </span>
|
<span aria-hidden="true">★ </span>
|
||||||
|
{/* The phone list has no column header: say what the number is. */}
|
||||||
|
{!withCount && <span className="sr-only">{t('detail.rating')} </span>}
|
||||||
{fmt.rating(rating)}
|
{fmt.rating(rating)}
|
||||||
{withCount && count > 0 && (
|
{withCount && count > 0 && (
|
||||||
<span
|
<span
|
||||||
className="text-muted-foreground"
|
className="text-muted-foreground"
|
||||||
title={t(count === 1 ? 'games.ratingCount.one' : 'games.ratingCount', { count: fmt.number(count) })}
|
title={t(count === 1 ? 'games.ratingCount.one' : 'games.ratingCount', { count: fmt.number(count) })}
|
||||||
>
|
>
|
||||||
{' '}
|
<span aria-hidden="true"> ({fmt.number(count)})</span>
|
||||||
({fmt.number(count)})
|
<span className="sr-only">
|
||||||
|
, {t(count === 1 ? 'games.ratingCount.one' : 'games.ratingCount', { count: fmt.number(count) })}
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { useState, type ReactNode } from 'react'
|
import { useRef, useState, type ReactNode } from 'react'
|
||||||
import * as DialogPrimitive from '@radix-ui/react-dialog'
|
import * as DialogPrimitive from '@radix-ui/react-dialog'
|
||||||
import { ArrowUpRight } from 'lucide-react'
|
import { ArrowUpRight } from 'lucide-react'
|
||||||
import { ExtLink } from '@/components/ext-link'
|
import { ExtLink } from '@/components/ext-link'
|
||||||
|
import { focusElement, focusPageHeading, pageHeading, whenPresent } from '@/components/focus-target'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { Checkbox } from '@/components/ui/checkbox'
|
import { Checkbox } from '@/components/ui/checkbox'
|
||||||
import { LEGAL_LINKS, LEGAL_VI_INDEX_URL } from '@/lib/about'
|
import { LEGAL_LINKS, LEGAL_VI_INDEX_URL } from '@/lib/about'
|
||||||
@@ -14,9 +15,10 @@ import { usePrefs, LEGAL_VERSION } from '@/stores/prefs'
|
|||||||
* renders behind it (a deep link lands where it pointed once accepted; its
|
* renders behind it (a deep link lands where it pointed once accepted; its
|
||||||
* data and covers come from this site). The apps load covers straight from
|
* data and covers come from this site). The apps load covers straight from
|
||||||
* itch.io, so there nothing behind the gate loads until it is accepted.
|
* itch.io, so there nothing behind the gate loads until it is accepted.
|
||||||
* Radix Dialog provides the focus trap, aria-modal and hides the rest of the
|
* Radix Dialog traps focus and hides the rest of the page from assistive
|
||||||
* page from assistive technology while it is open. It re-appears whenever
|
* technology while it is open (aria-hidden on everything else; it sets no
|
||||||
* `LEGAL_VERSION` changes.
|
* aria-modal). After Accept, focus moves to the page's heading. It re-appears
|
||||||
|
* whenever `LEGAL_VERSION` changes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// The documents being accepted — URLs come from about.ts, never hardcoded.
|
// The documents being accepted — URLs come from about.ts, never hardcoded.
|
||||||
@@ -48,6 +50,7 @@ function LegalGateDialog() {
|
|||||||
const lang = usePrefs((s) => s.language)
|
const lang = usePrefs((s) => s.language)
|
||||||
const acceptLegal = usePrefs((s) => s.acceptLegal)
|
const acceptLegal = usePrefs((s) => s.acceptLegal)
|
||||||
const [checked, setChecked] = useState(false)
|
const [checked, setChecked] = useState(false)
|
||||||
|
const checkbox = useRef<HTMLButtonElement>(null)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DialogPrimitive.Root open>
|
<DialogPrimitive.Root open>
|
||||||
@@ -57,6 +60,11 @@ function LegalGateDialog() {
|
|||||||
onEscapeKeyDown={(e) => e.preventDefault()}
|
onEscapeKeyDown={(e) => e.preventDefault()}
|
||||||
onPointerDownOutside={(e) => e.preventDefault()}
|
onPointerDownOutside={(e) => e.preventDefault()}
|
||||||
onInteractOutside={(e) => e.preventDefault()}
|
onInteractOutside={(e) => e.preventDefault()}
|
||||||
|
// Accepted: start reading at the page (in the apps it only mounts now).
|
||||||
|
onCloseAutoFocus={(e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
whenPresent(pageHeading, focusElement, { missing: focusPageHeading })
|
||||||
|
}}
|
||||||
className="fixed top-1/2 left-1/2 z-50 flex max-h-[92dvh] w-[calc(100%-2rem)] max-w-[540px] -translate-x-1/2 -translate-y-1/2 flex-col gap-[18px] overflow-y-auto rounded-2xl border bg-popover p-6 text-popover-foreground shadow-2xl sm:p-7"
|
className="fixed top-1/2 left-1/2 z-50 flex max-h-[92dvh] w-[calc(100%-2rem)] max-w-[540px] -translate-x-1/2 -translate-y-1/2 flex-col gap-[18px] overflow-y-auto rounded-2xl border bg-popover p-6 text-popover-foreground shadow-2xl sm:p-7"
|
||||||
>
|
>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
@@ -73,7 +81,10 @@ function LegalGateDialog() {
|
|||||||
const text = DOC_TEXT[link.name]
|
const text = DOC_TEXT[link.name]
|
||||||
return (
|
return (
|
||||||
<li key={link.name} className="border-b last:border-b-0">
|
<li key={link.name} className="border-b last:border-b-0">
|
||||||
<ExtLink href={link.url} className="flex items-center gap-3 px-3.5 py-3 hover:bg-accent">
|
<ExtLink
|
||||||
|
href={link.url}
|
||||||
|
className="flex items-center gap-3 px-3.5 py-3 hover:bg-accent focus-visible:-outline-offset-2"
|
||||||
|
>
|
||||||
<span className="flex min-w-0 flex-1 flex-col gap-0.5">
|
<span className="flex min-w-0 flex-1 flex-col gap-0.5">
|
||||||
<span className="text-sm font-medium">{text ? t(text.name) : link.name}</span>
|
<span className="text-sm font-medium">{text ? t(text.name) : link.name}</span>
|
||||||
<span className="text-[13px] text-muted-foreground">
|
<span className="text-[13px] text-muted-foreground">
|
||||||
@@ -89,7 +100,7 @@ function LegalGateDialog() {
|
|||||||
|
|
||||||
{lang === 'vi' && (
|
{lang === 'vi' && (
|
||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-xs text-muted-foreground">
|
||||||
<ExtLink href={LEGAL_VI_INDEX_URL} className="font-medium underline-offset-4 hover:underline">
|
<ExtLink href={LEGAL_VI_INDEX_URL} className="font-medium underline underline-offset-4">
|
||||||
docs/i18n/vi/
|
docs/i18n/vi/
|
||||||
</ExtLink>{' '}
|
</ExtLink>{' '}
|
||||||
— {t('legal.gate.viLink')}
|
— {t('legal.gate.viLink')}
|
||||||
@@ -97,7 +108,12 @@ function LegalGateDialog() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<label className="flex items-start gap-2.5 text-sm leading-normal">
|
<label className="flex items-start gap-2.5 text-sm leading-normal">
|
||||||
<Checkbox checked={checked} onCheckedChange={(v) => setChecked(v === true)} className="mt-0.5 size-[18px]" />
|
<Checkbox
|
||||||
|
ref={checkbox}
|
||||||
|
checked={checked}
|
||||||
|
onCheckedChange={(v) => setChecked(v === true)}
|
||||||
|
className="mt-0.5 size-[18px]"
|
||||||
|
/>
|
||||||
<span>{t('legal.gate.checkboxLabel')}</span>
|
<span>{t('legal.gate.checkboxLabel')}</span>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
@@ -108,7 +124,12 @@ function LegalGateDialog() {
|
|||||||
<a href="https://itch.io">{t('legal.gate.leave')}</a>
|
<a href="https://itch.io">{t('legal.gate.leave')}</a>
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<Button disabled={!checked} onClick={() => acceptLegal()}>
|
{/* aria-disabled, not disabled: the button stays reachable with Tab and says
|
||||||
|
why it doesn't work yet — pressing it moves focus to the checkbox. */}
|
||||||
|
<Button
|
||||||
|
aria-disabled={!checked}
|
||||||
|
onClick={() => (checked ? acceptLegal() : checkbox.current?.focus())}
|
||||||
|
>
|
||||||
{t('legal.gate.accept')}
|
{t('legal.gate.accept')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import { useRef } from 'react'
|
||||||
import * as DialogPrimitive from '@radix-ui/react-dialog'
|
import * as DialogPrimitive from '@radix-ui/react-dialog'
|
||||||
|
import { focusPageHeading } from '@/components/focus-target'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
import { useNsfwPrompt } from '@/lib/nsfw'
|
import { useNsfwPrompt } from '@/lib/nsfw'
|
||||||
@@ -9,13 +11,28 @@ export function NsfwDialog() {
|
|||||||
const t = useT()
|
const t = useT()
|
||||||
const open = useNsfwPrompt((s) => s.open)
|
const open = useNsfwPrompt((s) => s.open)
|
||||||
const setShowNsfw = usePrefs((s) => s.setShowNsfw)
|
const setShowNsfw = usePrefs((s) => s.setShowNsfw)
|
||||||
|
const opener = useRef<Element | null>(null)
|
||||||
const close = () => useNsfwPrompt.setState({ open: false })
|
const close = () => useNsfwPrompt.setState({ open: false })
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DialogPrimitive.Root open={open} onOpenChange={(next) => !next && close()}>
|
<DialogPrimitive.Root open={open} onOpenChange={(next) => !next && close()}>
|
||||||
<DialogPrimitive.Portal>
|
<DialogPrimitive.Portal>
|
||||||
<DialogPrimitive.Overlay className="fixed inset-0 z-50 bg-black/60" />
|
<DialogPrimitive.Overlay className="fixed inset-0 z-50 bg-black/60" />
|
||||||
<DialogPrimitive.Content className="fixed top-1/2 left-1/2 z-50 flex w-[calc(100%-2rem)] max-w-[420px] -translate-x-1/2 -translate-y-1/2 flex-col gap-4 rounded-2xl border bg-popover p-6 text-popover-foreground shadow-2xl">
|
<DialogPrimitive.Content
|
||||||
|
// There is no Radix trigger: remember the control that opened the dialog
|
||||||
|
// (still focused at this point) and return there — or to the page's
|
||||||
|
// heading when it is gone (the 18+ gate is replaced by the game page).
|
||||||
|
onOpenAutoFocus={() => {
|
||||||
|
opener.current = document.activeElement
|
||||||
|
}}
|
||||||
|
onCloseAutoFocus={(e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
const target = useNsfwPrompt.getState().returnFocus ?? opener.current
|
||||||
|
if (target instanceof HTMLElement && target.isConnected) target.focus({ preventScroll: true })
|
||||||
|
else focusPageHeading()
|
||||||
|
}}
|
||||||
|
className="fixed top-1/2 left-1/2 z-50 flex max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-[420px] -translate-x-1/2 -translate-y-1/2 flex-col gap-4 overflow-y-auto rounded-2xl border bg-popover p-6 text-popover-foreground shadow-2xl"
|
||||||
|
>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<DialogPrimitive.Title className="text-lg font-semibold tracking-tight">
|
<DialogPrimitive.Title className="text-lg font-semibold tracking-tight">
|
||||||
{t('nsfw.dialog.title')}
|
{t('nsfw.dialog.title')}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { ArrowUp } from 'lucide-react'
|
import { ArrowUp } from 'lucide-react'
|
||||||
|
import { focusPageHeading, scrollBehavior } from '@/components/focus-target'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
|
|
||||||
/** Floating "back to top" button once the window has scrolled a screen or so. */
|
/** Floating "back to top" button once the window has scrolled a screen or so. */
|
||||||
@@ -20,7 +21,11 @@ export default function ScrollToTop() {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
aria-label={t('common.scrollToTop')}
|
aria-label={t('common.scrollToTop')}
|
||||||
onClick={() => window.scrollTo({ top: 0, behavior: 'smooth' })}
|
onClick={() => {
|
||||||
|
window.scrollTo({ top: 0, behavior: scrollBehavior() })
|
||||||
|
// The button disappears at the top: keyboard focus continues from the page's heading.
|
||||||
|
focusPageHeading()
|
||||||
|
}}
|
||||||
className="fixed right-5 bottom-[calc(1.25rem+env(safe-area-inset-bottom))] z-30 flex size-11 items-center justify-center rounded-full border bg-card text-foreground shadow-lg hover:bg-accent"
|
className="fixed right-5 bottom-[calc(1.25rem+env(safe-area-inset-bottom))] z-30 flex size-11 items-center justify-center rounded-full border bg-card text-foreground shadow-lg hover:bg-accent"
|
||||||
>
|
>
|
||||||
<ArrowUp className="size-5" aria-hidden="true" />
|
<ArrowUp className="size-5" aria-hidden="true" />
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Link } from 'react-router'
|
import { useRef } from 'react'
|
||||||
|
import { Link, useLocation } from 'react-router'
|
||||||
import { Popover, PopoverClose, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
|
import { Popover, PopoverClose, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
|
||||||
import { Switch } from '@/components/ui/switch'
|
import { Switch } from '@/components/ui/switch'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
@@ -12,14 +13,22 @@ import { DensityChoice, LanguageChoice, ScrollbarsToggle, ThemeChoice } from './
|
|||||||
/** Theme, language, density, scrollbars and 18+ — the settings people change often. */
|
/** Theme, language, density, scrollbars and 18+ — the settings people change often. */
|
||||||
export function DisplayMenu({ className }: { className?: string }) {
|
export function DisplayMenu({ className }: { className?: string }) {
|
||||||
const t = useT()
|
const t = useT()
|
||||||
|
const { pathname } = useLocation()
|
||||||
|
const openedOn = useRef(pathname)
|
||||||
|
const trigger = useRef<HTMLButtonElement>(null)
|
||||||
const showNsfw = usePrefs((s) => s.showNsfw)
|
const showNsfw = usePrefs((s) => s.showNsfw)
|
||||||
const setShowNsfw = usePrefs((s) => s.setShowNsfw)
|
const setShowNsfw = usePrefs((s) => s.setShowNsfw)
|
||||||
// The button shows the theme in use: light, dark or following the system.
|
// The button shows the theme in use: light, dark or following the system.
|
||||||
const ThemeIcon = THEME_ICON[useThemeStore((s) => s.theme)]
|
const ThemeIcon = THEME_ICON[useThemeStore((s) => s.theme)]
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover>
|
<Popover
|
||||||
|
onOpenChange={(open) => {
|
||||||
|
if (open) openedOn.current = pathname
|
||||||
|
}}
|
||||||
|
>
|
||||||
<PopoverTrigger
|
<PopoverTrigger
|
||||||
|
ref={trigger}
|
||||||
aria-label={t('header.display')}
|
aria-label={t('header.display')}
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex size-9 items-center justify-center rounded-lg border text-muted-foreground hover:bg-accent hover:text-foreground',
|
'flex size-9 items-center justify-center rounded-lg border text-muted-foreground hover:bg-accent hover:text-foreground',
|
||||||
@@ -28,7 +37,15 @@ export function DisplayMenu({ className }: { className?: string }) {
|
|||||||
>
|
>
|
||||||
<ThemeIcon className="size-4" aria-hidden="true" />
|
<ThemeIcon className="size-4" aria-hidden="true" />
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent align="end" aria-label={t('header.display')} className="w-72 space-y-4">
|
<PopoverContent
|
||||||
|
align="end"
|
||||||
|
aria-label={t('header.display')}
|
||||||
|
// "All settings" opened another page: focus belongs to its heading, not back on this button.
|
||||||
|
onCloseAutoFocus={(e) => {
|
||||||
|
if (pathname !== openedOn.current) e.preventDefault()
|
||||||
|
}}
|
||||||
|
className="max-h-[var(--radix-popover-content-available-height)] w-72 space-y-4 overflow-y-auto"
|
||||||
|
>
|
||||||
<ThemeChoice />
|
<ThemeChoice />
|
||||||
<LanguageChoice />
|
<LanguageChoice />
|
||||||
<DensityChoice />
|
<DensityChoice />
|
||||||
@@ -40,7 +57,8 @@ export function DisplayMenu({ className }: { className?: string }) {
|
|||||||
<Switch
|
<Switch
|
||||||
id="menu-nsfw"
|
id="menu-nsfw"
|
||||||
checked={showNsfw}
|
checked={showNsfw}
|
||||||
onCheckedChange={(on) => (on ? requestNsfw() : setShowNsfw(false))}
|
// The menu closes when the dialog opens: focus returns to its button afterwards.
|
||||||
|
onCheckedChange={(on) => (on ? requestNsfw(trigger.current) : setShowNsfw(false))}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<PopoverClose asChild>
|
<PopoverClose asChild>
|
||||||
|
|||||||
@@ -6,39 +6,50 @@ import { fold } from '@/lib/game-filters'
|
|||||||
import { useFormat } from '@/lib/format'
|
import { useFormat } from '@/lib/format'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
import { cn, slugify } from '@/lib/utils'
|
import { cn, slugify } from '@/lib/utils'
|
||||||
|
import { usePrefs } from '@/stores/prefs'
|
||||||
|
|
||||||
const MAX_SUGGESTIONS = 6
|
const MAX_SUGGESTIONS = 6
|
||||||
|
|
||||||
/** "/" focuses the search box unless the visitor is already typing somewhere. */
|
/**
|
||||||
function useSlashShortcut(target: RefObject<HTMLInputElement | null>) {
|
* "/" focuses the search box unless the visitor is already typing somewhere,
|
||||||
|
* the box isn't on screen (the phone header has none) or a dialog is open
|
||||||
|
* (Radix hides the rest of the page from assistive technology then). It can be
|
||||||
|
* switched off in Settings (WCAG 2.1.4).
|
||||||
|
*/
|
||||||
|
function useSlashShortcut(target: RefObject<HTMLInputElement | null>, enabled: boolean) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!enabled) return
|
||||||
const onKey = (e: globalThis.KeyboardEvent) => {
|
const onKey = (e: globalThis.KeyboardEvent) => {
|
||||||
if (e.key !== '/' || e.ctrlKey || e.metaKey || e.altKey) return
|
if (e.key !== '/' || e.ctrlKey || e.metaKey || e.altKey || e.defaultPrevented || e.isComposing) return
|
||||||
const el = e.target as HTMLElement | null
|
const el = e.target as HTMLElement | null
|
||||||
if (el && (el.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(el.tagName))) return
|
if (el && (el.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(el.tagName))) return
|
||||||
|
const input = target.current
|
||||||
|
if (!input || !input.getClientRects().length || input.closest('[aria-hidden="true"],[inert]')) return
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
target.current?.focus()
|
input.focus()
|
||||||
}
|
}
|
||||||
window.addEventListener('keydown', onKey)
|
window.addEventListener('keydown', onKey)
|
||||||
return () => window.removeEventListener('keydown', onKey)
|
return () => window.removeEventListener('keydown', onKey)
|
||||||
}, [target])
|
}, [target, enabled])
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Header search: suggests matching games while typing (Enter or click opens
|
* Header search: suggests matching games while typing (Enter or click opens
|
||||||
* one); Enter without a pick shows all results on the Games page.
|
* one); Enter without a pick, or the last option, shows all results on the
|
||||||
|
* Games page.
|
||||||
*/
|
*/
|
||||||
export function GlobalSearch({ className }: { className?: string }) {
|
export function GlobalSearch({ className }: { className?: string }) {
|
||||||
const t = useT()
|
const t = useT()
|
||||||
const fmt = useFormat()
|
const fmt = useFormat()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const games = useVisibleGames()
|
const games = useVisibleGames()
|
||||||
|
const shortcut = usePrefs((s) => s.slashShortcut)
|
||||||
const input = useRef<HTMLInputElement>(null)
|
const input = useRef<HTMLInputElement>(null)
|
||||||
const listId = useId()
|
const listId = useId()
|
||||||
const [value, setValue] = useState('')
|
const [value, setValue] = useState('')
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
const [active, setActive] = useState(-1)
|
const [active, setActive] = useState(-1)
|
||||||
useSlashShortcut(input)
|
useSlashShortcut(input, shortcut)
|
||||||
|
|
||||||
const suggestions = useMemo(() => {
|
const suggestions = useMemo(() => {
|
||||||
const needle = fold(value.trim())
|
const needle = fold(value.trim())
|
||||||
@@ -68,16 +79,21 @@ export function GlobalSearch({ className }: { className?: string }) {
|
|||||||
input.current?.blur()
|
input.current?.blur()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The options: every suggestion, then "see all results" (index = suggestions.length).
|
||||||
|
const optionCount = suggestions.length + 1
|
||||||
|
const hasQuery = value.trim().length > 0
|
||||||
|
|
||||||
const onKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
|
const onKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
|
||||||
// Enter / arrows that finish an IME composition (e.g. Vietnamese Telex) aren't commands.
|
// Enter / arrows that finish an IME composition (e.g. Vietnamese Telex) aren't commands.
|
||||||
if (e.nativeEvent.isComposing || e.keyCode === 229) return
|
if (e.nativeEvent.isComposing || e.keyCode === 229) return
|
||||||
if (e.key === 'ArrowDown' && suggestions.length) {
|
if (e.key === 'ArrowDown' && hasQuery) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
setOpen(true)
|
setOpen(true)
|
||||||
setActive((i) => (i + 1) % suggestions.length)
|
setActive((i) => (i + 1) % optionCount)
|
||||||
} else if (e.key === 'ArrowUp' && suggestions.length) {
|
} else if (e.key === 'ArrowUp' && hasQuery) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
setActive((i) => (i <= 0 ? suggestions.length - 1 : i - 1))
|
setOpen(true)
|
||||||
|
setActive((i) => (i <= 0 ? optionCount - 1 : i - 1))
|
||||||
} else if (e.key === 'Enter') {
|
} else if (e.key === 'Enter') {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
if (active >= 0 && suggestions[active]) goToGame(suggestions[active].url)
|
if (active >= 0 && suggestions[active]) goToGame(suggestions[active].url)
|
||||||
@@ -90,11 +106,18 @@ export function GlobalSearch({ className }: { className?: string }) {
|
|||||||
|
|
||||||
// The catalog size, as on the Welcome page (18+ games count even while hidden).
|
// The catalog size, as on the Welcome page (18+ games count even while hidden).
|
||||||
const total = games.data ? games.data.games.length + games.hiddenNsfw : undefined
|
const total = games.data ? games.data.games.length + games.hiddenNsfw : undefined
|
||||||
const showList = open && value.trim().length > 0
|
const showList = open && hasQuery
|
||||||
|
const allIndex = suggestions.length
|
||||||
|
const count = suggestions.length
|
||||||
|
const countText = !showList
|
||||||
|
? ''
|
||||||
|
: count === 0
|
||||||
|
? t('header.search.count.none')
|
||||||
|
: t(count === 1 ? 'header.search.count.one' : 'header.search.count', { n: count })
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cn('relative', className)}>
|
<search className={cn('relative', className)}>
|
||||||
<label className="flex h-9 items-center gap-2 rounded-lg border bg-card px-3 text-muted-foreground focus-within:border-primary">
|
<label className="flex h-9 items-center gap-2 rounded-lg border border-input bg-card px-3 text-muted-foreground focus-within:border-primary focus-within:ring-1 focus-within:ring-primary">
|
||||||
<Search className="size-4 shrink-0" aria-hidden="true" />
|
<Search className="size-4 shrink-0" aria-hidden="true" />
|
||||||
<input
|
<input
|
||||||
ref={input}
|
ref={input}
|
||||||
@@ -104,7 +127,8 @@ export function GlobalSearch({ className }: { className?: string }) {
|
|||||||
aria-expanded={showList}
|
aria-expanded={showList}
|
||||||
aria-controls={listId}
|
aria-controls={listId}
|
||||||
aria-autocomplete="list"
|
aria-autocomplete="list"
|
||||||
aria-activedescendant={active >= 0 ? `${listId}-${active}` : undefined}
|
aria-activedescendant={showList && active >= 0 ? `${listId}-${active}` : undefined}
|
||||||
|
aria-keyshortcuts={shortcut ? '/' : undefined}
|
||||||
value={value}
|
value={value}
|
||||||
placeholder={total ? t('header.search.placeholder', { n: fmt.number(total) }) : t('header.search.label')}
|
placeholder={total ? t('header.search.placeholder', { n: fmt.number(total) }) : t('header.search.label')}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
@@ -115,12 +139,18 @@ export function GlobalSearch({ className }: { className?: string }) {
|
|||||||
onFocus={() => setOpen(true)}
|
onFocus={() => setOpen(true)}
|
||||||
onBlur={() => setTimeout(close, 120)}
|
onBlur={() => setTimeout(close, 120)}
|
||||||
onKeyDown={onKeyDown}
|
onKeyDown={onKeyDown}
|
||||||
className="min-w-0 flex-1 bg-transparent text-sm text-foreground outline-hidden placeholder:text-muted-foreground [&::-webkit-search-cancel-button]:hidden"
|
className="min-w-0 flex-1 bg-transparent text-sm text-foreground placeholder:text-muted-foreground focus-visible:outline-hidden [&::-webkit-search-cancel-button]:hidden"
|
||||||
/>
|
/>
|
||||||
<kbd className="rounded border px-1.5 font-mono text-[11px]" aria-hidden="true">
|
{shortcut && (
|
||||||
/
|
<kbd className="rounded border px-1.5 font-mono text-[11px]" aria-hidden="true">
|
||||||
</kbd>
|
/
|
||||||
|
</kbd>
|
||||||
|
)}
|
||||||
</label>
|
</label>
|
||||||
|
{/* How many suggestions there are, read out politely while typing. */}
|
||||||
|
<p role="status" className="sr-only">
|
||||||
|
{countText}
|
||||||
|
</p>
|
||||||
{showList && (
|
{showList && (
|
||||||
<ul
|
<ul
|
||||||
id={listId}
|
id={listId}
|
||||||
@@ -136,18 +166,25 @@ export function GlobalSearch({ className }: { className?: string }) {
|
|||||||
aria-selected={i === active}
|
aria-selected={i === active}
|
||||||
onMouseDown={(e) => e.preventDefault()}
|
onMouseDown={(e) => e.preventDefault()}
|
||||||
onClick={() => goToGame(game.url)}
|
onClick={() => goToGame(game.url)}
|
||||||
className={cn('flex cursor-pointer flex-col px-3 py-2', i === active && 'bg-accent')}
|
className={cn(
|
||||||
|
'flex cursor-pointer flex-col px-3 py-2',
|
||||||
|
i === active && 'bg-accent shadow-[inset_3px_0_0_var(--primary)]',
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
<span className="truncate font-medium">{game.name}</span>
|
<span className="truncate font-medium">{game.name}</span>
|
||||||
<span className="truncate text-xs text-muted-foreground">{game.dev}</span>
|
<span className="truncate text-xs text-muted-foreground">{game.dev}</span>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
<li
|
<li
|
||||||
|
id={`${listId}-${allIndex}`}
|
||||||
role="option"
|
role="option"
|
||||||
aria-selected={false}
|
aria-selected={active === allIndex}
|
||||||
onMouseDown={(e) => e.preventDefault()}
|
onMouseDown={(e) => e.preventDefault()}
|
||||||
onClick={goToResults}
|
onClick={goToResults}
|
||||||
className="cursor-pointer border-t px-3 py-2 text-muted-foreground hover:bg-accent"
|
className={cn(
|
||||||
|
'cursor-pointer border-t px-3 py-2 text-muted-foreground hover:bg-accent',
|
||||||
|
active === allIndex && 'bg-accent shadow-[inset_3px_0_0_var(--primary)]',
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
{suggestions.length
|
{suggestions.length
|
||||||
? t('header.search.all', { q: value.trim() })
|
? t('header.search.all', { q: value.trim() })
|
||||||
@@ -155,6 +192,6 @@ export function GlobalSearch({ className }: { className?: string }) {
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
)}
|
)}
|
||||||
</div>
|
</search>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ const THEMES: { value: Theme; key: MessageKey }[] = [
|
|||||||
{ value: 'system', key: 'theme.system' },
|
{ value: 'system', key: 'theme.system' },
|
||||||
]
|
]
|
||||||
|
|
||||||
/** A small single-choice button row. */
|
/** A small single-choice button row. An option's `lang` marks a label in another language. */
|
||||||
function Segmented<T extends string>({
|
function Segmented<T extends string>({
|
||||||
label,
|
label,
|
||||||
value,
|
value,
|
||||||
@@ -21,7 +21,7 @@ function Segmented<T extends string>({
|
|||||||
}: {
|
}: {
|
||||||
label: string
|
label: string
|
||||||
value: T
|
value: T
|
||||||
options: { value: T; label: string; icon?: LucideIcon }[]
|
options: { value: T; label: string; icon?: LucideIcon; lang?: string }[]
|
||||||
onChange: (v: T) => void
|
onChange: (v: T) => void
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
@@ -36,11 +36,11 @@ function Segmented<T extends string>({
|
|||||||
onClick={() => onChange(o.value)}
|
onClick={() => onChange(o.value)}
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex h-8 items-center justify-center gap-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground',
|
'flex h-8 items-center justify-center gap-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground',
|
||||||
value === o.value && 'bg-card font-medium text-foreground shadow-xs',
|
value === o.value && 'bg-card font-medium text-foreground shadow-xs ring-1 ring-primary',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{o.icon && <o.icon className="size-3.5" aria-hidden="true" />}
|
{o.icon && <o.icon className="size-3.5" aria-hidden="true" />}
|
||||||
{o.label}
|
{o.lang ? <span lang={o.lang}>{o.label}</span> : o.label}
|
||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -71,8 +71,8 @@ export function LanguageChoice() {
|
|||||||
value={language}
|
value={language}
|
||||||
onChange={(l) => void switchLanguage(l)}
|
onChange={(l) => void switchLanguage(l)}
|
||||||
options={[
|
options={[
|
||||||
{ value: 'en', label: 'English' },
|
{ value: 'en', label: 'English', lang: 'en' },
|
||||||
{ value: 'vi', label: 'Tiếng Việt' },
|
{ value: 'vi', label: 'Tiếng Việt', lang: 'vi' },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
@@ -95,20 +95,72 @@ export function DensityChoice() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A labelled switch; the optional description is tied to it (aria-describedby). */
|
||||||
|
export function SwitchRow({
|
||||||
|
id,
|
||||||
|
label,
|
||||||
|
description,
|
||||||
|
checked,
|
||||||
|
onCheckedChange,
|
||||||
|
strong = Boolean(description),
|
||||||
|
}: {
|
||||||
|
id: string
|
||||||
|
label: string
|
||||||
|
description?: string
|
||||||
|
checked: boolean
|
||||||
|
onCheckedChange: (on: boolean) => void
|
||||||
|
strong?: boolean
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div className="flex items-center justify-between gap-4">
|
||||||
|
<div className="space-y-0.5">
|
||||||
|
<label htmlFor={id} className={cn('text-sm', strong && 'font-medium')}>
|
||||||
|
{label}
|
||||||
|
</label>
|
||||||
|
{description && (
|
||||||
|
<p id={`${id}-desc`} className="text-sm text-muted-foreground">
|
||||||
|
{description}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
|
id={id}
|
||||||
|
checked={checked}
|
||||||
|
onCheckedChange={onCheckedChange}
|
||||||
|
aria-describedby={description ? `${id}-desc` : undefined}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/** The "Hide scrollbars" switch row; `describe` adds the longer explanation (Settings). */
|
/** The "Hide scrollbars" switch row; `describe` adds the longer explanation (Settings). */
|
||||||
export function ScrollbarsToggle({ id, describe = false }: { id: string; describe?: boolean }) {
|
export function ScrollbarsToggle({ id, describe = false }: { id: string; describe?: boolean }) {
|
||||||
const t = useT()
|
const t = useT()
|
||||||
const hide = usePrefs((s) => s.hideScrollbars)
|
const hide = usePrefs((s) => s.hideScrollbars)
|
||||||
const setHide = usePrefs((s) => s.setHideScrollbars)
|
const setHide = usePrefs((s) => s.setHideScrollbars)
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-between gap-4">
|
<SwitchRow
|
||||||
<div className="space-y-0.5">
|
id={id}
|
||||||
<label htmlFor={id} className={cn('text-sm', describe && 'font-medium')}>
|
label={t('settings.appearance.scrollbars')}
|
||||||
{t('settings.appearance.scrollbars')}
|
description={describe ? t('settings.appearance.scrollbarsDesc') : undefined}
|
||||||
</label>
|
checked={hide}
|
||||||
{describe && <p className="text-sm text-muted-foreground">{t('settings.appearance.scrollbarsDesc')}</p>}
|
onCheckedChange={setHide}
|
||||||
</div>
|
/>
|
||||||
<Switch id={id} checked={hide} onCheckedChange={setHide} />
|
)
|
||||||
</div>
|
}
|
||||||
|
|
||||||
|
/** Turns the "/" search shortcut on or off (WCAG 2.1.4). */
|
||||||
|
export function SlashShortcutToggle({ id }: { id: string }) {
|
||||||
|
const t = useT()
|
||||||
|
const enabled = usePrefs((s) => s.slashShortcut)
|
||||||
|
const setEnabled = usePrefs((s) => s.setSlashShortcut)
|
||||||
|
return (
|
||||||
|
<SwitchRow
|
||||||
|
id={id}
|
||||||
|
label={t('settings.a11y.slash')}
|
||||||
|
description={t('settings.a11y.slashDesc')}
|
||||||
|
checked={enabled}
|
||||||
|
onCheckedChange={setEnabled}
|
||||||
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
import { Link } from 'react-router'
|
import { Link } from 'react-router'
|
||||||
import { ExtLink } from '@/components/ext-link'
|
import { ExtLink } from '@/components/ext-link'
|
||||||
|
import { ACCESSIBILITY_URLS } from '@/lib/about'
|
||||||
import { useT, type MessageKey } from '@/lib/i18n'
|
import { useT, type MessageKey } from '@/lib/i18n'
|
||||||
import { isAndroid, isTauri } from '@/lib/runtime'
|
import { isAndroid, isTauri } from '@/lib/runtime'
|
||||||
|
import { usePrefs } from '@/stores/prefs'
|
||||||
import { REPO_URL } from './site-header'
|
import { REPO_URL } from './site-header'
|
||||||
|
|
||||||
const DOCS = `${REPO_URL}/blob/main`
|
const DOCS = `${REPO_URL}/blob/main`
|
||||||
@@ -16,6 +18,7 @@ const LINKS: { key: MessageKey; href: string }[] = [
|
|||||||
|
|
||||||
export function SiteFooter() {
|
export function SiteFooter() {
|
||||||
const t = useT()
|
const t = useT()
|
||||||
|
const language = usePrefs((s) => s.language)
|
||||||
return (
|
return (
|
||||||
<footer className="border-t pb-[env(safe-area-inset-bottom)]">
|
<footer className="border-t pb-[env(safe-area-inset-bottom)]">
|
||||||
<div className="mx-auto flex max-w-[1440px] flex-col gap-3 px-4 py-5 text-[13px] text-muted-foreground sm:px-8 lg:flex-row lg:items-center lg:gap-6">
|
<div className="mx-auto flex max-w-[1440px] flex-col gap-3 px-4 py-5 text-[13px] text-muted-foreground sm:px-8 lg:flex-row lg:items-center lg:gap-6">
|
||||||
@@ -33,6 +36,10 @@ export function SiteFooter() {
|
|||||||
{t(l.key)}
|
{t(l.key)}
|
||||||
</ExtLink>
|
</ExtLink>
|
||||||
))}
|
))}
|
||||||
|
{/* The accessibility statement in the visitor's language. */}
|
||||||
|
<ExtLink href={ACCESSIBILITY_URLS[language]} className="hover:text-foreground">
|
||||||
|
{t('footer.accessibility')}
|
||||||
|
</ExtLink>
|
||||||
<Link to="/about#support" className="hover:text-foreground">
|
<Link to="/about#support" className="hover:text-foreground">
|
||||||
{t('footer.support')}
|
{t('footer.support')}
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useRef, useState } from 'react'
|
||||||
import { Link, NavLink, useLocation } from 'react-router'
|
import { Link, NavLink, useLocation } from 'react-router'
|
||||||
import { Code2, Menu } from 'lucide-react'
|
import { Code2, Menu } from 'lucide-react'
|
||||||
import { ExtLink } from '@/components/ext-link'
|
import { ExtLink } from '@/components/ext-link'
|
||||||
@@ -26,8 +26,8 @@ const MENU: { to: string; key: MessageKey; end?: boolean }[] = [
|
|||||||
|
|
||||||
function BrandMark({ className }: { className?: string }) {
|
function BrandMark({ className }: { className?: string }) {
|
||||||
return (
|
return (
|
||||||
<span className={cn('flex size-[26px] items-center justify-center rounded-[7px] bg-primary', className)}>
|
<span className={cn('flex size-[26px] items-center justify-center rounded-[7px] bg-brand text-white', className)}>
|
||||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="#ffffff" aria-hidden="true">
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
||||||
<path d="M13 2 4 14h7l-1 8 9-12h-7l1-8z" />
|
<path d="M13 2 4 14h7l-1 8 9-12h-7l1-8z" />
|
||||||
</svg>
|
</svg>
|
||||||
</span>
|
</span>
|
||||||
@@ -45,23 +45,38 @@ function MobileMenu() {
|
|||||||
const t = useT()
|
const t = useT()
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
|
const openedOn = useRef(location.pathname)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Back/forward navigation doesn't go through the links' onClick.
|
// Back/forward navigation doesn't go through the links' onClick.
|
||||||
// eslint-disable-next-line react-hooks/set-state-in-effect
|
// eslint-disable-next-line react-hooks/set-state-in-effect
|
||||||
setOpen(false)
|
setOpen(false)
|
||||||
}, [location.pathname])
|
}, [location.pathname])
|
||||||
return (
|
return (
|
||||||
<Sheet open={open} onOpenChange={setOpen}>
|
<Sheet
|
||||||
|
open={open}
|
||||||
|
onOpenChange={(next) => {
|
||||||
|
if (next) openedOn.current = location.pathname
|
||||||
|
setOpen(next)
|
||||||
|
}}
|
||||||
|
>
|
||||||
<SheetTrigger
|
<SheetTrigger
|
||||||
aria-label={t('header.menu')}
|
aria-label={t('header.menu')}
|
||||||
className="flex size-11 items-center justify-center rounded-lg text-foreground hover:bg-accent"
|
className="flex size-11 items-center justify-center rounded-lg text-foreground hover:bg-accent"
|
||||||
>
|
>
|
||||||
<Menu className="size-5" aria-hidden="true" />
|
<Menu className="size-5" aria-hidden="true" />
|
||||||
</SheetTrigger>
|
</SheetTrigger>
|
||||||
<SheetContent side="right" className="w-72 p-0 pt-[env(safe-area-inset-top)]">
|
<SheetContent
|
||||||
|
side="right"
|
||||||
|
closeLabel={t('common.close')}
|
||||||
|
// A link in the menu opened another page: focus belongs to its heading (App.tsx), not to this button.
|
||||||
|
onCloseAutoFocus={(e) => {
|
||||||
|
if (location.pathname !== openedOn.current) e.preventDefault()
|
||||||
|
}}
|
||||||
|
className="w-72 p-0 pt-[env(safe-area-inset-top)]"
|
||||||
|
>
|
||||||
<SheetTitle className="sr-only">{t('header.nav')}</SheetTitle>
|
<SheetTitle className="sr-only">{t('header.nav')}</SheetTitle>
|
||||||
<SheetDescription className="sr-only">{t('header.navDescription')}</SheetDescription>
|
<SheetDescription className="sr-only">{t('header.navDescription')}</SheetDescription>
|
||||||
<nav aria-label={t('header.nav')} className="flex flex-col gap-1 p-4 pt-14">
|
<nav aria-label={t('header.mainNav')} className="flex flex-col gap-1 p-4 pt-14">
|
||||||
{MENU.map((m) => (
|
{MENU.map((m) => (
|
||||||
<NavLink
|
<NavLink
|
||||||
key={m.to}
|
key={m.to}
|
||||||
@@ -71,7 +86,9 @@ function MobileMenu() {
|
|||||||
className={({ isActive }) =>
|
className={({ isActive }) =>
|
||||||
cn(
|
cn(
|
||||||
'flex min-h-11 items-center rounded-lg px-3 text-[15px]',
|
'flex min-h-11 items-center rounded-lg px-3 text-[15px]',
|
||||||
isActive ? 'bg-accent font-medium' : 'text-muted-foreground hover:bg-accent',
|
isActive
|
||||||
|
? 'bg-accent font-medium underline decoration-primary decoration-2 underline-offset-[6px]'
|
||||||
|
: 'text-muted-foreground hover:bg-accent',
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@@ -99,7 +116,7 @@ export function SiteHeader() {
|
|||||||
<BrandMark />
|
<BrandMark />
|
||||||
<span className="text-[15px] font-semibold tracking-tight">Free Itch Games</span>
|
<span className="text-[15px] font-semibold tracking-tight">Free Itch Games</span>
|
||||||
</Link>
|
</Link>
|
||||||
<nav aria-label={t('header.nav')} className="flex items-center gap-1">
|
<nav aria-label={t('header.mainNav')} className="flex items-center gap-1">
|
||||||
{NAV.map((n) => (
|
{NAV.map((n) => (
|
||||||
<NavLink
|
<NavLink
|
||||||
key={n.to}
|
key={n.to}
|
||||||
@@ -107,7 +124,10 @@ export function SiteHeader() {
|
|||||||
className={({ isActive }) =>
|
className={({ isActive }) =>
|
||||||
cn(
|
cn(
|
||||||
'rounded-md px-2.5 py-1.5 text-sm',
|
'rounded-md px-2.5 py-1.5 text-sm',
|
||||||
isActive ? 'bg-accent font-medium text-foreground' : 'text-muted-foreground hover:text-foreground',
|
// The current page is underlined too: the fill alone is too faint to see.
|
||||||
|
isActive
|
||||||
|
? 'bg-accent font-medium text-foreground underline decoration-primary decoration-2 underline-offset-[6px]'
|
||||||
|
: 'text-muted-foreground hover:text-foreground',
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const badgeVariants = cva(
|
|||||||
secondary:
|
secondary:
|
||||||
'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
||||||
destructive:
|
destructive:
|
||||||
'border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80',
|
'border-transparent bg-destructive-solid text-destructive-foreground hover:bg-destructive-solid/80',
|
||||||
outline: 'text-foreground',
|
outline: 'text-foreground',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,16 +4,16 @@ import { forwardRef, type ButtonHTMLAttributes } from 'react'
|
|||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
|
|
||||||
const buttonVariants = cva(
|
const buttonVariants = cva(
|
||||||
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
|
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50',
|
||||||
{
|
{
|
||||||
variants: {
|
variants: {
|
||||||
variant: {
|
variant: {
|
||||||
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
|
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
|
||||||
destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
|
destructive: 'bg-destructive-solid text-destructive-foreground hover:bg-destructive-solid/90',
|
||||||
outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
|
outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
|
||||||
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
||||||
ghost: 'hover:bg-accent hover:text-accent-foreground',
|
ghost: 'hover:bg-accent hover:text-accent-foreground',
|
||||||
link: 'text-primary underline-offset-4 hover:underline',
|
link: 'text-primary-text underline-offset-4 hover:underline',
|
||||||
},
|
},
|
||||||
size: {
|
size: {
|
||||||
default: 'h-10 px-4 py-2',
|
default: 'h-10 px-4 py-2',
|
||||||
|
|||||||
@@ -19,13 +19,12 @@ export const CardHeader = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivEleme
|
|||||||
)
|
)
|
||||||
CardHeader.displayName = 'CardHeader'
|
CardHeader.displayName = 'CardHeader'
|
||||||
|
|
||||||
export const CardTitle = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
|
/** A real heading (h2): the About cards and the chart cards sit right under the page's h1. */
|
||||||
({ className, ...props }, ref) => (
|
export const CardTitle = forwardRef<HTMLHeadingElement, HTMLAttributes<HTMLHeadingElement>>(
|
||||||
<div
|
({ className, children, ...props }, ref) => (
|
||||||
ref={ref}
|
<h2 ref={ref} className={cn('text-2xl font-semibold leading-none tracking-tight', className)} {...props}>
|
||||||
className={cn('text-2xl font-semibold leading-none tracking-tight', className)}
|
{children}
|
||||||
{...props}
|
</h2>
|
||||||
/>
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
CardTitle.displayName = 'CardTitle'
|
CardTitle.displayName = 'CardTitle'
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export const PopoverContent = forwardRef<
|
|||||||
align={align}
|
align={align}
|
||||||
sideOffset={sideOffset}
|
sideOffset={sideOffset}
|
||||||
className={cn(
|
className={cn(
|
||||||
'z-50 w-72 rounded-xl border bg-popover p-4 text-popover-foreground shadow-md outline-hidden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
|
'z-50 w-72 rounded-xl border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const SheetOverlay = forwardRef<
|
|||||||
SheetOverlay.displayName = 'SheetOverlay'
|
SheetOverlay.displayName = 'SheetOverlay'
|
||||||
|
|
||||||
const sheetVariants = cva(
|
const sheetVariants = cva(
|
||||||
'fixed z-50 flex flex-col bg-background shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:duration-300',
|
'fixed z-50 flex flex-col overflow-y-auto bg-background shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:duration-300',
|
||||||
{
|
{
|
||||||
variants: {
|
variants: {
|
||||||
side: {
|
side: {
|
||||||
@@ -42,20 +42,22 @@ export interface SheetContentProps
|
|||||||
extends ComponentPropsWithoutRef<typeof DialogPrimitive.Content>,
|
extends ComponentPropsWithoutRef<typeof DialogPrimitive.Content>,
|
||||||
VariantProps<typeof sheetVariants> {
|
VariantProps<typeof sheetVariants> {
|
||||||
showClose?: boolean
|
showClose?: boolean
|
||||||
|
/** The close button's accessible name (translated by the caller). */
|
||||||
|
closeLabel?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SheetContent = forwardRef<
|
export const SheetContent = forwardRef<
|
||||||
ElementRef<typeof DialogPrimitive.Content>,
|
ElementRef<typeof DialogPrimitive.Content>,
|
||||||
SheetContentProps
|
SheetContentProps
|
||||||
>(({ side = 'right', className, children, showClose = true, ...props }, ref) => (
|
>(({ side = 'right', className, children, showClose = true, closeLabel = 'Close', ...props }, ref) => (
|
||||||
<SheetPortal>
|
<SheetPortal>
|
||||||
<SheetOverlay />
|
<SheetOverlay />
|
||||||
<DialogPrimitive.Content ref={ref} className={cn(sheetVariants({ side }), className)} {...props}>
|
<DialogPrimitive.Content ref={ref} className={cn(sheetVariants({ side }), className)} {...props}>
|
||||||
{children}
|
{children}
|
||||||
{showClose && (
|
{showClose && (
|
||||||
<DialogPrimitive.Close className="absolute right-3 top-3 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none">
|
<DialogPrimitive.Close className="absolute top-2 right-2 flex size-9 items-center justify-center rounded-md opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none">
|
||||||
<X className="h-4 w-4" />
|
<X className="size-4" aria-hidden="true" />
|
||||||
<span className="sr-only">Close</span>
|
<span className="sr-only">{closeLabel}</span>
|
||||||
</DialogPrimitive.Close>
|
</DialogPrimitive.Close>
|
||||||
)}
|
)}
|
||||||
</DialogPrimitive.Content>
|
</DialogPrimitive.Content>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export const TabsTrigger = forwardRef<
|
|||||||
<TabsPrimitive.Trigger
|
<TabsPrimitive.Trigger
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn(
|
className={cn(
|
||||||
'inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-xs',
|
'inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-xs data-[state=active]:ring-1 data-[state=active]:ring-primary',
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
|
|||||||
+91
-7
@@ -12,6 +12,12 @@
|
|||||||
* for active chips and selected filters, `--thumb` the cover placeholder,
|
* for active chips and selected filters, `--thumb` the cover placeholder,
|
||||||
* `--scrollbar-*` the scrollbar thumb (muted-foreground with alpha; the
|
* `--scrollbar-*` the scrollbar thumb (muted-foreground with alpha; the
|
||||||
* accent while dragged).
|
* accent while dragged).
|
||||||
|
*
|
||||||
|
* Contrast (WCAG 2.2 AA, checked by src/contrast.test.ts): `--primary` is a
|
||||||
|
* shade darker than the brand purple so white text on it reaches 4.5:1;
|
||||||
|
* `--primary-text` is the accent as text (lighter in dark mode); `--brand` is
|
||||||
|
* the logo's own purple (logos are exempt); `--input` outlines fields and the
|
||||||
|
* off switch at 3:1; `--destructive-solid` fills destructive buttons.
|
||||||
*/
|
*/
|
||||||
:root {
|
:root {
|
||||||
--background: #fafaf9;
|
--background: #fafaf9;
|
||||||
@@ -20,8 +26,10 @@
|
|||||||
--card-foreground: #17171a;
|
--card-foreground: #17171a;
|
||||||
--popover: #ffffff;
|
--popover: #ffffff;
|
||||||
--popover-foreground: #17171a;
|
--popover-foreground: #17171a;
|
||||||
--primary: #7c5cff;
|
--primary: #6a48f5;
|
||||||
--primary-foreground: #ffffff;
|
--primary-foreground: #ffffff;
|
||||||
|
--primary-text: #6a48f5;
|
||||||
|
--brand: #7c5cff;
|
||||||
--secondary: #f0efec;
|
--secondary: #f0efec;
|
||||||
--secondary-foreground: #17171a;
|
--secondary-foreground: #17171a;
|
||||||
--muted: #f0efec;
|
--muted: #f0efec;
|
||||||
@@ -30,9 +38,10 @@
|
|||||||
--accent-foreground: #17171a;
|
--accent-foreground: #17171a;
|
||||||
--destructive: #dc2626;
|
--destructive: #dc2626;
|
||||||
--destructive-foreground: #ffffff;
|
--destructive-foreground: #ffffff;
|
||||||
--success: #16a34a;
|
--destructive-solid: #dc2626;
|
||||||
|
--success: #15803d;
|
||||||
--border: #e4e4e0;
|
--border: #e4e4e0;
|
||||||
--input: #e4e4e0;
|
--input: #8a8a93;
|
||||||
--ring: #7c5cff;
|
--ring: #7c5cff;
|
||||||
--brand-soft: #7c5cff24; /* the accent at 14 % (8-digit hex: no color-mix, iOS 15 safe) */
|
--brand-soft: #7c5cff24; /* the accent at 14 % (8-digit hex: no color-mix, iOS 15 safe) */
|
||||||
--thumb: #e7e5ef;
|
--thumb: #e7e5ef;
|
||||||
@@ -49,8 +58,10 @@
|
|||||||
--card-foreground: #ededef;
|
--card-foreground: #ededef;
|
||||||
--popover: #131316;
|
--popover: #131316;
|
||||||
--popover-foreground: #ededef;
|
--popover-foreground: #ededef;
|
||||||
--primary: #7c5cff;
|
--primary: #6a48f5;
|
||||||
--primary-foreground: #ffffff;
|
--primary-foreground: #ffffff;
|
||||||
|
--primary-text: #9a83ff;
|
||||||
|
--brand: #7c5cff;
|
||||||
--secondary: #1c1c22;
|
--secondary: #1c1c22;
|
||||||
--secondary-foreground: #ededef;
|
--secondary-foreground: #ededef;
|
||||||
--muted: #1c1c22;
|
--muted: #1c1c22;
|
||||||
@@ -59,9 +70,10 @@
|
|||||||
--accent-foreground: #ededef;
|
--accent-foreground: #ededef;
|
||||||
--destructive: #ef4444;
|
--destructive: #ef4444;
|
||||||
--destructive-foreground: #ffffff;
|
--destructive-foreground: #ffffff;
|
||||||
|
--destructive-solid: #dc2626;
|
||||||
--success: #22c55e;
|
--success: #22c55e;
|
||||||
--border: #232328;
|
--border: #232328;
|
||||||
--input: #26262b;
|
--input: #6b6b75;
|
||||||
--ring: #7c5cff;
|
--ring: #7c5cff;
|
||||||
--brand-soft: #7c5cff38; /* 22 % */
|
--brand-soft: #7c5cff38; /* 22 % */
|
||||||
--thumb: #1f1d27;
|
--thumb: #1f1d27;
|
||||||
@@ -81,6 +93,8 @@
|
|||||||
--color-popover-foreground: var(--popover-foreground);
|
--color-popover-foreground: var(--popover-foreground);
|
||||||
--color-primary: var(--primary);
|
--color-primary: var(--primary);
|
||||||
--color-primary-foreground: var(--primary-foreground);
|
--color-primary-foreground: var(--primary-foreground);
|
||||||
|
--color-primary-text: var(--primary-text);
|
||||||
|
--color-brand: var(--brand);
|
||||||
--color-secondary: var(--secondary);
|
--color-secondary: var(--secondary);
|
||||||
--color-secondary-foreground: var(--secondary-foreground);
|
--color-secondary-foreground: var(--secondary-foreground);
|
||||||
--color-muted: var(--muted);
|
--color-muted: var(--muted);
|
||||||
@@ -89,6 +103,7 @@
|
|||||||
--color-accent-foreground: var(--accent-foreground);
|
--color-accent-foreground: var(--accent-foreground);
|
||||||
--color-destructive: var(--destructive);
|
--color-destructive: var(--destructive);
|
||||||
--color-destructive-foreground: var(--destructive-foreground);
|
--color-destructive-foreground: var(--destructive-foreground);
|
||||||
|
--color-destructive-solid: var(--destructive-solid);
|
||||||
--color-success: var(--success);
|
--color-success: var(--success);
|
||||||
--color-border: var(--border);
|
--color-border: var(--border);
|
||||||
--color-input: var(--input);
|
--color-input: var(--input);
|
||||||
@@ -122,6 +137,9 @@
|
|||||||
|
|
||||||
html {
|
html {
|
||||||
color-scheme: light;
|
color-scheme: light;
|
||||||
|
/* What keyboard focus or a #link scrolls to stays clear of the sticky header
|
||||||
|
(3.5rem, plus the notch on phones) — WCAG 2.4.11. */
|
||||||
|
scroll-padding-top: calc(3.5rem + env(safe-area-inset-top) + 0.5rem);
|
||||||
}
|
}
|
||||||
html.dark {
|
html.dark {
|
||||||
color-scheme: dark;
|
color-scheme: dark;
|
||||||
@@ -143,6 +161,12 @@
|
|||||||
outline-offset: 2px;
|
outline-offset: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Where reading starts after a page change or a closed dialog (components/focus-target.ts):
|
||||||
|
a heading focused from script, not a control, so no ring. */
|
||||||
|
[data-focus-target]:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
/* Tailwind 4 gives buttons the default cursor; keep the pointer of the v3 UI. */
|
/* Tailwind 4 gives buttons the default cursor; keep the pointer of the v3 UI. */
|
||||||
button:not(:disabled),
|
button:not(:disabled),
|
||||||
[role='button']:not(:disabled) {
|
[role='button']:not(:disabled) {
|
||||||
@@ -154,6 +178,8 @@
|
|||||||
::before,
|
::before,
|
||||||
::after {
|
::after {
|
||||||
animation-duration: 0.01ms !important;
|
animation-duration: 0.01ms !important;
|
||||||
|
/* Looping animations (skeleton pulse, spinners) run once instead of flickering. */
|
||||||
|
animation-iteration-count: 1 !important;
|
||||||
transition-duration: 0.01ms !important;
|
transition-duration: 0.01ms !important;
|
||||||
scroll-behavior: auto !important;
|
scroll-behavior: auto !important;
|
||||||
}
|
}
|
||||||
@@ -162,8 +188,10 @@
|
|||||||
/* Themed scrollbars where there is a mouse; touch screens keep their own
|
/* Themed scrollbars where there is a mouse; touch screens keep their own
|
||||||
overlay bars. Chromium and Safari use the ::-webkit-scrollbar rules;
|
overlay bars. Chromium and Safari use the ::-webkit-scrollbar rules;
|
||||||
Firefox has only the standard properties, set for it alone, because in
|
Firefox has only the standard properties, set for it alone, because in
|
||||||
Chromium 121+ scrollbar-color / scrollbar-width switch the webkit rules off. */
|
Chromium 121+ scrollbar-color / scrollbar-width switch the webkit rules off.
|
||||||
@media (hover: hover) and (pointer: fine) {
|
Not in forced-colours mode (Windows contrast themes): the translucent thumb
|
||||||
|
would disappear there, the system's own scrollbars don't. */
|
||||||
|
@media (hover: hover) and (pointer: fine) and (forced-colors: none) {
|
||||||
::-webkit-scrollbar {
|
::-webkit-scrollbar {
|
||||||
width: 12px;
|
width: 12px;
|
||||||
height: 12px;
|
height: 12px;
|
||||||
@@ -194,6 +222,8 @@
|
|||||||
scrollbar-width: thin;
|
scrollbar-width: thin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@media (hover: hover) and (pointer: fine) {
|
||||||
/* The page's scrollbar takes room here: keep that room reserved, so the
|
/* The page's scrollbar takes room here: keep that room reserved, so the
|
||||||
layout does not jump sideways when a page (or a Charts tab) gets taller
|
layout does not jump sideways when a page (or a Charts tab) gets taller
|
||||||
or shorter than the window. While a dialog locks scrolling the gutter is
|
or shorter than the window. While a dialog locks scrolling the gutter is
|
||||||
@@ -213,6 +243,16 @@
|
|||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Axis text and lines in the theme's muted colour: Recharts' own #666 reads at
|
||||||
|
only 3.3:1 on the dark card. CSS beats the SVG attributes Recharts sets. */
|
||||||
|
.recharts-cartesian-axis-tick-value {
|
||||||
|
fill: var(--muted-foreground);
|
||||||
|
}
|
||||||
|
.recharts-cartesian-axis-line,
|
||||||
|
.recharts-cartesian-axis-tick-line {
|
||||||
|
stroke: var(--muted-foreground);
|
||||||
|
}
|
||||||
|
|
||||||
/* Phones: chart text at caption size. Legends otherwise take the 16px body size
|
/* Phones: chart text at caption size. Legends otherwise take the 16px body size
|
||||||
(three rows under a pie) and axes their 10–16px props. Recharts reads both
|
(three rows under a pie) and axes their 10–16px props. Recharts reads both
|
||||||
sizes back from the DOM (legend box, getComputedStyle on a tick), so the
|
sizes back from the DOM (legend box, getComputedStyle on a tick), so the
|
||||||
@@ -267,3 +307,47 @@ html[data-scrollbars='hidden'] *::-webkit-scrollbar {
|
|||||||
html[data-scrollbars='hidden'] {
|
html[data-scrollbars='hidden'] {
|
||||||
scrollbar-gutter: auto;
|
scrollbar-gutter: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Windows contrast themes (forced colours): the system replaces our colours,
|
||||||
|
so a state drawn only with a fill or a shadow disappears. Selected tabs,
|
||||||
|
pressed toggles, the current page and the active search option take the
|
||||||
|
system highlight instead; switches get an outline and a visible thumb; chart
|
||||||
|
text and lines follow the system text colour (SVG keeps author colours). */
|
||||||
|
@media (forced-colors: active) {
|
||||||
|
[role='tab'][data-state='active'],
|
||||||
|
[aria-pressed='true'],
|
||||||
|
a[aria-current='page'],
|
||||||
|
[role='option'][aria-selected='true'] {
|
||||||
|
background-color: Highlight;
|
||||||
|
color: HighlightText;
|
||||||
|
}
|
||||||
|
[role='tab'][data-state='active'] *,
|
||||||
|
[aria-pressed='true'] *,
|
||||||
|
a[aria-current='page'] *,
|
||||||
|
[role='option'][aria-selected='true'] * {
|
||||||
|
color: HighlightText;
|
||||||
|
}
|
||||||
|
button[role='switch'] {
|
||||||
|
border-color: ButtonText;
|
||||||
|
}
|
||||||
|
button[role='switch'] > span {
|
||||||
|
background-color: ButtonText;
|
||||||
|
}
|
||||||
|
button[role='switch'][data-state='checked'] {
|
||||||
|
border-color: Highlight;
|
||||||
|
background-color: Highlight;
|
||||||
|
}
|
||||||
|
button[role='switch'][data-state='checked'] > span {
|
||||||
|
background-color: HighlightText;
|
||||||
|
}
|
||||||
|
.recharts-text {
|
||||||
|
fill: CanvasText;
|
||||||
|
}
|
||||||
|
.recharts-cartesian-axis-line,
|
||||||
|
.recharts-cartesian-axis-tick-line {
|
||||||
|
stroke: CanvasText;
|
||||||
|
}
|
||||||
|
.recharts-cartesian-grid line {
|
||||||
|
stroke: GrayText;
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
-8
@@ -8,7 +8,7 @@ export interface ThirdParty {
|
|||||||
|
|
||||||
export const APP = {
|
export const APP = {
|
||||||
name: 'Free Itch Games',
|
name: 'Free Itch Games',
|
||||||
version: '4.5.0',
|
version: '4.6.0',
|
||||||
repo: 'https://github.com/poli0981/free-games-itchio-list',
|
repo: 'https://github.com/poli0981/free-games-itchio-list',
|
||||||
license: 'code MIT · data CC BY 4.0',
|
license: 'code MIT · data CC BY 4.0',
|
||||||
} as const
|
} as const
|
||||||
@@ -117,7 +117,8 @@ export const LEGAL_LINKS: LegalLink[] = [
|
|||||||
{ name: 'EULA', description: 'License terms of the desktop and Android apps.', url: `${REPO_BLOB}/docs/EULA.md`, group: 'policy', inGate: true, appOnly: true },
|
{ name: 'EULA', description: 'License terms of the desktop and Android apps.', url: `${REPO_BLOB}/docs/EULA.md`, group: 'policy', inGate: true, appOnly: true },
|
||||||
{ name: 'Code of Conduct', description: 'Be kind. Contributor Covenant 2.1, adapted.', url: `${REPO_BLOB}/CODE_OF_CONDUCT.md`, group: 'policy' },
|
{ name: 'Code of Conduct', description: 'Be kind. Contributor Covenant 2.1, adapted.', url: `${REPO_BLOB}/CODE_OF_CONDUCT.md`, group: 'policy' },
|
||||||
{ name: 'Security Policy', description: 'How to report a vulnerability privately.', url: `${REPO_BLOB}/SECURITY.md`, group: 'policy' },
|
{ name: 'Security Policy', description: 'How to report a vulnerability privately.', url: `${REPO_BLOB}/SECURITY.md`, group: 'policy' },
|
||||||
{ name: 'Content removal', description: 'Creators and rights holders: ask for a game to be removed or corrected.', url: `${REPO_BLOB}/.github/ISSUE_TEMPLATE/remove_game.yml`, group: 'policy' },
|
{ name: 'Accessibility', description: 'What works with a keyboard, screen readers and other assistive technology, known gaps, how to report a barrier.', url: `${REPO_BLOB}/ACCESSIBILITY.md`, group: 'policy' },
|
||||||
|
{ name: 'Content removal', description: 'Creators and rights holders: ask for a game to be removed or corrected.', url: 'https://github.com/poli0981/free-games-itchio-list/issues/new?template=remove_game.yml', group: 'policy' },
|
||||||
|
|
||||||
// Meta
|
// Meta
|
||||||
{ name: 'Licenses & notice', description: 'Code: MIT. Data and docs: CC BY 4.0. Not affiliated with itch.io.', url: `${REPO_BLOB}/NOTICE.md`, group: 'meta', inGate: true },
|
{ name: 'Licenses & notice', description: 'Code: MIT. Data and docs: CC BY 4.0. Not affiliated with itch.io.', url: `${REPO_BLOB}/NOTICE.md`, group: 'meta', inGate: true },
|
||||||
@@ -133,6 +134,12 @@ export const LEGAL_GROUP_LABELS: Record<LegalGroup, string> = {
|
|||||||
export const LEGAL_VI_INDEX_URL =
|
export const LEGAL_VI_INDEX_URL =
|
||||||
'https://github.com/poli0981/free-games-itchio-list/tree/main/docs/i18n/vi'
|
'https://github.com/poli0981/free-games-itchio-list/tree/main/docs/i18n/vi'
|
||||||
|
|
||||||
|
/** The accessibility statement in the visitor's language (the English one controls). */
|
||||||
|
export const ACCESSIBILITY_URLS = {
|
||||||
|
en: `${REPO_BLOB}/ACCESSIBILITY.md`,
|
||||||
|
vi: `${REPO_BLOB}/docs/i18n/vi/ACCESSIBILITY.md`,
|
||||||
|
} as const
|
||||||
|
|
||||||
export const THIRD_PARTY: ThirdParty[] = [
|
export const THIRD_PARTY: ThirdParty[] = [
|
||||||
// Core
|
// Core
|
||||||
{ name: 'React', version: '19.3', license: 'MIT', url: 'https://react.dev', category: 'core' },
|
{ name: 'React', version: '19.3', license: 'MIT', url: 'https://react.dev', category: 'core' },
|
||||||
@@ -147,23 +154,23 @@ export const THIRD_PARTY: ThirdParty[] = [
|
|||||||
{ name: 'Geist / Geist Mono (Fontsource)', version: '5.3', license: 'OFL-1.1', url: 'https://vercel.com/font', category: 'ui' },
|
{ name: 'Geist / Geist Mono (Fontsource)', version: '5.3', license: 'OFL-1.1', url: 'https://vercel.com/font', category: 'ui' },
|
||||||
{ name: 'shadcn/ui', version: 'pattern', license: 'MIT', url: 'https://ui.shadcn.com', category: 'ui' },
|
{ name: 'shadcn/ui', version: 'pattern', license: 'MIT', url: 'https://ui.shadcn.com', category: 'ui' },
|
||||||
{ name: 'Radix UI', version: '1.x / 2.x', license: 'MIT', url: 'https://www.radix-ui.com', category: 'ui' },
|
{ name: 'Radix UI', version: '1.x / 2.x', license: 'MIT', url: 'https://www.radix-ui.com', category: 'ui' },
|
||||||
{ name: 'lucide-react', version: '1.61', license: 'ISC', url: 'https://lucide.dev', category: 'ui' },
|
{ name: 'lucide-react', version: '1.69', license: 'ISC', url: 'https://lucide.dev', category: 'ui' },
|
||||||
{ name: 'class-variance-authority', version: '0.7', license: 'Apache-2.0', url: 'https://cva.style', category: 'ui' },
|
{ name: 'class-variance-authority', version: '0.7', license: 'Apache-2.0', url: 'https://cva.style', category: 'ui' },
|
||||||
{ name: 'tailwind-merge', version: '3.7', license: 'MIT', url: 'https://github.com/dcastil/tailwind-merge', category: 'ui' },
|
{ name: 'tailwind-merge', version: '3.7', license: 'MIT', url: 'https://github.com/dcastil/tailwind-merge', category: 'ui' },
|
||||||
{ name: 'clsx', version: '2.1', license: 'MIT', url: 'https://github.com/lukeed/clsx', category: 'ui' },
|
{ name: 'clsx', version: '2.1', license: 'MIT', url: 'https://github.com/lukeed/clsx', category: 'ui' },
|
||||||
{ name: 'Recharts', version: '3.10', license: 'MIT', url: 'https://recharts.org', category: 'ui' },
|
{ name: 'Recharts', version: '3.10', license: 'MIT', url: 'https://recharts.org', category: 'ui' },
|
||||||
|
|
||||||
// Data
|
// Data
|
||||||
{ name: 'TanStack Query', version: '5.104', license: 'MIT', url: 'https://tanstack.com/query', category: 'data' },
|
{ name: 'TanStack Query', version: '5.106', license: 'MIT', url: 'https://tanstack.com/query', category: 'data' },
|
||||||
{ name: 'TanStack Query Persist Client', version: '5.104', license: 'MIT', url: 'https://tanstack.com/query', category: 'data' },
|
{ name: 'TanStack Query Persist Client', version: '5.106', license: 'MIT', url: 'https://tanstack.com/query', category: 'data' },
|
||||||
{ name: 'idb-keyval', version: '6.3', license: 'Apache-2.0', url: 'https://github.com/jakearchibald/idb-keyval', category: 'data' },
|
{ name: 'idb-keyval', version: '6.3', license: 'Apache-2.0', url: 'https://github.com/jakearchibald/idb-keyval', category: 'data' },
|
||||||
{ name: 'fflate', version: '0.8', license: 'MIT', url: 'https://github.com/101arrowz/fflate', category: 'data' },
|
{ name: 'fflate', version: '0.8', license: 'MIT', url: 'https://github.com/101arrowz/fflate', category: 'data' },
|
||||||
|
|
||||||
// Hosting / tooling (Cloudflare)
|
// Hosting / tooling (Cloudflare)
|
||||||
{ name: 'jose', version: '6.2', license: 'MIT', url: 'https://github.com/panva/jose', category: 'dev' },
|
{ name: 'jose', version: '6.2', license: 'MIT', url: 'https://github.com/panva/jose', category: 'dev' },
|
||||||
{ name: 'Wrangler', version: '4.152', license: 'MIT OR Apache-2.0', url: 'https://developers.cloudflare.com/workers/wrangler/', category: 'dev' },
|
{ name: 'Wrangler', version: '4.158', license: 'MIT OR Apache-2.0', url: 'https://developers.cloudflare.com/workers/wrangler/', category: 'dev' },
|
||||||
{ name: 'Vitest', version: '5.0', license: 'MIT', url: 'https://vitest.dev', category: 'dev' },
|
{ name: 'Vitest', version: '5.1', license: 'MIT', url: 'https://vitest.dev', category: 'dev' },
|
||||||
{ name: '@vitest/coverage-v8', version: '5.0', license: 'MIT', url: 'https://vitest.dev/guide/coverage', category: 'dev' },
|
{ name: '@vitest/coverage-v8', version: '5.1', license: 'MIT', url: 'https://vitest.dev/guide/coverage', category: 'dev' },
|
||||||
|
|
||||||
// Desktop / mobile (Tauri)
|
// Desktop / mobile (Tauri)
|
||||||
{ name: 'Tauri', version: '2.x', license: 'Apache-2.0 OR MIT', url: 'https://tauri.app', category: 'desktop' },
|
{ name: 'Tauri', version: '2.x', license: 'Apache-2.0 OR MIT', url: 'https://tauri.app', category: 'desktop' },
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { describe, expect, it } from 'vitest'
|
||||||
|
import { historyRows, tableRows, treemapRows } from './chart-table'
|
||||||
|
|
||||||
|
describe('chart data tables', () => {
|
||||||
|
it('keeps the chart order and adds shares only for a whole', () => {
|
||||||
|
const entries = [
|
||||||
|
{ key: 'Released', count: 30 },
|
||||||
|
{ key: 'Prototype', count: 10 },
|
||||||
|
]
|
||||||
|
expect(tableRows(entries)).toEqual([
|
||||||
|
{ key: 'Released', count: 30, share: null },
|
||||||
|
{ key: 'Prototype', count: 10, share: null },
|
||||||
|
])
|
||||||
|
expect(tableRows(entries, 40)).toEqual([
|
||||||
|
{ key: 'Released', count: 30, share: 0.75 },
|
||||||
|
{ key: 'Prototype', count: 10, share: 0.25 },
|
||||||
|
])
|
||||||
|
// An empty pie has no shares to give.
|
||||||
|
expect(tableRows([{ key: 'None', count: 0 }], 0)).toEqual([{ key: 'None', count: 0, share: null }])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('turns the history and the treemap into rows', () => {
|
||||||
|
expect(historyRows([{ date: '2026-11-08', total: 5800 }, { date: '2026-11-09', total: 5828 }])).toEqual([
|
||||||
|
{ key: '2026-11-08', count: 5800, share: null },
|
||||||
|
{ key: '2026-11-09', count: 5828, share: null },
|
||||||
|
])
|
||||||
|
expect(treemapRows([{ name: 'Puzzle', size: 12 }])).toEqual([{ key: 'Puzzle', count: 12, share: null }])
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import type { CountEntry, TreemapNode } from './analytics'
|
||||||
|
import type { CountHistoryPoint } from '@/types/game'
|
||||||
|
|
||||||
|
/** One row of a chart's data table (components/charts/chart-card.tsx). */
|
||||||
|
export interface TableRow {
|
||||||
|
key: string
|
||||||
|
count: number
|
||||||
|
/** The row's part of the whole, when the chart's parts make one (a pie); else null. */
|
||||||
|
share: number | null
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A chart's data as table rows, in the chart's own order. Pass `total` when
|
||||||
|
* the values add up to a whole (most pies) to get each row's share; leave it
|
||||||
|
* out when one game counts in several rows (platforms, tags).
|
||||||
|
*/
|
||||||
|
export function tableRows(entries: readonly CountEntry[], total?: number): TableRow[] {
|
||||||
|
return entries.map(({ key, count }) => ({ key, count, share: total ? count / total : null }))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The catalog size history (date → games) as rows, oldest first like the line chart. */
|
||||||
|
export function historyRows(history: readonly CountHistoryPoint[]): TableRow[] {
|
||||||
|
return history.map(({ date, total }) => ({ key: date, count: total, share: null }))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Treemap cells (name, size) as rows. */
|
||||||
|
export function treemapRows(nodes: readonly TreemapNode[]): TableRow[] {
|
||||||
|
return nodes.map(({ name, size }) => ({ key: name, count: size, share: null }))
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { describe, expect, it } from 'vitest'
|
||||||
|
import { contrastRatio, parseHex, readableOn, relativeLuminance } from './color'
|
||||||
|
|
||||||
|
describe('colour maths', () => {
|
||||||
|
it('parses #rgb and #rrggbb', () => {
|
||||||
|
expect(parseHex('#fff')).toEqual([255, 255, 255])
|
||||||
|
expect(parseHex('#7C5CFF')).toEqual([124, 92, 255])
|
||||||
|
expect(() => parseHex('#7c5cff38')).toThrow()
|
||||||
|
expect(() => parseHex('purple')).toThrow()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('computes luminance and contrast like WCAG 2.x', () => {
|
||||||
|
expect(relativeLuminance('#000000')).toBe(0)
|
||||||
|
expect(relativeLuminance('#ffffff')).toBe(1)
|
||||||
|
expect(contrastRatio('#000', '#fff')).toBe(21)
|
||||||
|
expect(contrastRatio('#fff', '#000')).toBe(21)
|
||||||
|
expect(contrastRatio('#777777', '#777777')).toBe(1)
|
||||||
|
// The classic borderline grey: #767676 passes 4.5:1 on white, #777777 doesn't.
|
||||||
|
expect(contrastRatio('#767676', '#ffffff')).toBeGreaterThanOrEqual(4.5)
|
||||||
|
expect(contrastRatio('#777777', '#ffffff')).toBeLessThan(4.5)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('picks the more readable label colour', () => {
|
||||||
|
expect(readableOn('#ffffff')).toBe('#0b0b0c')
|
||||||
|
expect(readableOn('#0b0b0c')).toBe('#ffffff')
|
||||||
|
expect(readableOn('#3c83f6')).toBe('#0b0b0c')
|
||||||
|
expect(readableOn('#1e1b4b', '#000000', '#fafafa')).toBe('#fafafa')
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// WCAG 2.x colour maths: the contrast checks in src/contrast.test.ts and the
|
||||||
|
// chart label colours (components/charts/palette.ts).
|
||||||
|
|
||||||
|
/** [r, g, b] (0–255) of a #rgb or #rrggbb colour. */
|
||||||
|
export function parseHex(hex: string): [number, number, number] {
|
||||||
|
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim())
|
||||||
|
if (!m) throw new Error(`not a #rgb / #rrggbb colour: ${hex}`)
|
||||||
|
const digits = m[1].length === 3 ? [...m[1]].map((d) => d + d) : (m[1].match(/../g) ?? [])
|
||||||
|
const [r, g, b] = digits.map((d) => Number.parseInt(d, 16))
|
||||||
|
return [r, g, b]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Relative luminance, 0 (black) to 1 (white). */
|
||||||
|
export function relativeLuminance(hex: string): number {
|
||||||
|
const [r, g, b] = parseHex(hex).map((v) => {
|
||||||
|
const c = v / 255
|
||||||
|
return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4
|
||||||
|
})
|
||||||
|
return 0.2126 * r + 0.7152 * g + 0.0722 * b
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Contrast ratio between two colours, 1 to 21 (the order doesn't matter). */
|
||||||
|
export function contrastRatio(a: string, b: string): number {
|
||||||
|
const [hi, lo] = [relativeLuminance(a), relativeLuminance(b)].sort((x, y) => y - x)
|
||||||
|
return (hi + 0.05) / (lo + 0.05)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whichever of two text colours reads better on `background` (near-black by default, or white). */
|
||||||
|
export function readableOn(background: string, dark = '#0b0b0c', light = '#ffffff'): string {
|
||||||
|
return contrastRatio(dark, background) >= contrastRatio(light, background) ? dark : light
|
||||||
|
}
|
||||||
@@ -80,7 +80,7 @@ export const en = {
|
|||||||
"about.social.title": "Find me elsewhere",
|
"about.social.title": "Find me elsewhere",
|
||||||
"about.thirdParty.core": "Core",
|
"about.thirdParty.core": "Core",
|
||||||
"about.thirdParty.data": "Data layer",
|
"about.thirdParty.data": "Data layer",
|
||||||
"about.thirdParty.desc": "Open-source libraries this app builds on. Click any name for the project's home page; license names link to the SPDX identifier.",
|
"about.thirdParty.desc": "Open-source libraries this app builds on. Click any name for the project's home page.",
|
||||||
"about.thirdParty.desktop": "Desktop (Tauri)",
|
"about.thirdParty.desktop": "Desktop (Tauri)",
|
||||||
"about.thirdParty.dev": "Dev tooling",
|
"about.thirdParty.dev": "Dev tooling",
|
||||||
"about.thirdParty.title": "Third-party software",
|
"about.thirdParty.title": "Third-party software",
|
||||||
@@ -356,6 +356,32 @@ export const en = {
|
|||||||
"deleted.reason.notGame": "Not a game",
|
"deleted.reason.notGame": "Not a game",
|
||||||
"deleted.reason.broken": "Broken or unplayable",
|
"deleted.reason.broken": "Broken or unplayable",
|
||||||
"deleted.reason.malware": "Reported as malware",
|
"deleted.reason.malware": "Reported as malware",
|
||||||
|
"settings.a11y.title": "Accessibility",
|
||||||
|
"settings.a11y.desc": "Keyboard and screen reader options. Saved in this browser only.",
|
||||||
|
"settings.a11y.slash": "Press / to jump to search",
|
||||||
|
"settings.a11y.slashDesc": "Turn it off if you use speech input, or if the key gets in the way of your screen reader or your browser's quick find.",
|
||||||
|
"settings.a11y.statement": "Accessibility statement: what works, known gaps and how to report a barrier",
|
||||||
|
"common.close": "Close",
|
||||||
|
"common.newTab": "(opens in a new tab)",
|
||||||
|
"common.opensBrowser": "(opens in your browser)",
|
||||||
|
"titles.error": "Error {code}",
|
||||||
|
"header.mainNav": "Main",
|
||||||
|
"header.search.count": "{n} suggestions",
|
||||||
|
"header.search.count.one": "{n} suggestion",
|
||||||
|
"header.search.count.none": "No suggestions",
|
||||||
|
"games.search.label": "Search this list",
|
||||||
|
"games.filter.selected": "{n} selected",
|
||||||
|
"deleted.countFiltered": "{shown} of {count} entries",
|
||||||
|
"charts.tabs.label": "Chart groups",
|
||||||
|
"suggest.error.needChallenge": "Please finish the anti-spam check first.",
|
||||||
|
"charts.table.show": "Data table",
|
||||||
|
"charts.table.share": "Share",
|
||||||
|
"charts.table.date": "Date",
|
||||||
|
"charts.table.month": "Month",
|
||||||
|
"charts.table.kind": "Kind",
|
||||||
|
"charts.table.use": "Used for",
|
||||||
|
"charts.a11y.keys": "Use the left and right arrow keys to read each value. The data table below the chart lists them all.",
|
||||||
|
"footer.accessibility": "Accessibility",
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export type MessageKey = keyof typeof en
|
export type MessageKey = keyof typeof en
|
||||||
@@ -34,11 +34,16 @@ export async function switchLanguage(lang: Language): Promise<void> {
|
|||||||
/** Call once at startup: preload VI if it was the persisted preference. */
|
/** Call once at startup: preload VI if it was the persisted preference. */
|
||||||
export function initI18n(): void {
|
export function initI18n(): void {
|
||||||
if (usePrefs.getState().language === 'vi') void ensureVi()
|
if (usePrefs.getState().language === 'vi') void ensureVi()
|
||||||
// <html lang> follows the preference (screen readers, hyphenation, translation prompts).
|
// <html lang> follows the text actually on screen (screen readers pick their voice from it,
|
||||||
document.documentElement.lang = usePrefs.getState().language
|
// also hyphenation and translation prompts): Vietnamese only once its dictionary is in,
|
||||||
usePrefs.subscribe((s) => {
|
// until then the page still shows English.
|
||||||
document.documentElement.lang = s.language
|
const apply = () => {
|
||||||
})
|
const lang = usePrefs.getState().language
|
||||||
|
document.documentElement.lang = lang === 'vi' && !useViDict.getState().dict ? 'en' : lang
|
||||||
|
}
|
||||||
|
apply()
|
||||||
|
usePrefs.subscribe(apply)
|
||||||
|
useViDict.subscribe(apply)
|
||||||
}
|
}
|
||||||
|
|
||||||
function format(template: string, params?: Record<string, string | number>): string {
|
function format(template: string, params?: Record<string, string | number>): string {
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ export const vi: Record<MessageKey, string> = {
|
|||||||
"about.social.title": "Tìm mình ở nơi khác",
|
"about.social.title": "Tìm mình ở nơi khác",
|
||||||
"about.thirdParty.core": "Cốt lõi",
|
"about.thirdParty.core": "Cốt lõi",
|
||||||
"about.thirdParty.data": "Tầng dữ liệu",
|
"about.thirdParty.data": "Tầng dữ liệu",
|
||||||
"about.thirdParty.desc": "Các thư viện mã nguồn mở mà ứng dụng này dựa trên. Nhấp vào tên bất kỳ để mở trang chủ dự án; tên giấy phép liên kết tới mã định danh SPDX.",
|
"about.thirdParty.desc": "Các thư viện mã nguồn mở mà ứng dụng này dựa trên. Nhấp vào tên bất kỳ để mở trang chủ dự án.",
|
||||||
"about.thirdParty.desktop": "Desktop (Tauri)",
|
"about.thirdParty.desktop": "Desktop (Tauri)",
|
||||||
"about.thirdParty.dev": "Công cụ dev",
|
"about.thirdParty.dev": "Công cụ dev",
|
||||||
"about.thirdParty.title": "Phần mềm bên thứ ba",
|
"about.thirdParty.title": "Phần mềm bên thứ ba",
|
||||||
@@ -358,4 +358,30 @@ export const vi: Record<MessageKey, string> = {
|
|||||||
"deleted.reason.notGame": "Không phải game",
|
"deleted.reason.notGame": "Không phải game",
|
||||||
"deleted.reason.broken": "Lỗi, không chơi được",
|
"deleted.reason.broken": "Lỗi, không chơi được",
|
||||||
"deleted.reason.malware": "Bị báo cáo chứa mã độc",
|
"deleted.reason.malware": "Bị báo cáo chứa mã độc",
|
||||||
|
"settings.a11y.title": "Trợ năng",
|
||||||
|
"settings.a11y.desc": "Tùy chọn cho bàn phím và trình đọc màn hình. Chỉ lưu trong trình duyệt này.",
|
||||||
|
"settings.a11y.slash": "Nhấn / để chuyển tới ô tìm kiếm",
|
||||||
|
"settings.a11y.slashDesc": "Hãy tắt nếu bạn nhập liệu bằng giọng nói, hoặc nếu phím này cản trở trình đọc màn hình hay chức năng tìm nhanh của trình duyệt.",
|
||||||
|
"settings.a11y.statement": "Tuyên bố trợ năng: những gì đã hỗ trợ, các hạn chế đã biết và cách báo rào cản",
|
||||||
|
"common.close": "Đóng",
|
||||||
|
"common.newTab": "(mở trong thẻ mới)",
|
||||||
|
"common.opensBrowser": "(mở trong trình duyệt)",
|
||||||
|
"titles.error": "Lỗi {code}",
|
||||||
|
"header.mainNav": "Menu chính",
|
||||||
|
"header.search.count": "{n} gợi ý",
|
||||||
|
"header.search.count.one": "{n} gợi ý",
|
||||||
|
"header.search.count.none": "Không có gợi ý",
|
||||||
|
"games.search.label": "Tìm trong danh sách này",
|
||||||
|
"games.filter.selected": "đã chọn {n}",
|
||||||
|
"deleted.countFiltered": "{shown} / {count} mục",
|
||||||
|
"charts.tabs.label": "Nhóm biểu đồ",
|
||||||
|
"suggest.error.needChallenge": "Vui lòng hoàn tất bước kiểm tra chống spam trước.",
|
||||||
|
"charts.table.show": "Bảng dữ liệu",
|
||||||
|
"charts.table.share": "Tỷ lệ",
|
||||||
|
"charts.table.date": "Ngày",
|
||||||
|
"charts.table.month": "Tháng",
|
||||||
|
"charts.table.kind": "Loại",
|
||||||
|
"charts.table.use": "Dùng cho",
|
||||||
|
"charts.a11y.keys": "Dùng phím mũi tên trái và phải để đọc từng giá trị. Bảng dữ liệu bên dưới biểu đồ liệt kê đầy đủ.",
|
||||||
|
"footer.accessibility": "Trợ năng",
|
||||||
}
|
}
|
||||||
+12
-4
@@ -6,13 +6,21 @@ export function isNsfw(game: Pick<Game, 'nsfw'>): boolean {
|
|||||||
return game.nsfw === 'Yes'
|
return game.nsfw === 'Yes'
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Whether the 18+ confirmation dialog (components/nsfw-dialog.tsx) is open. */
|
/**
|
||||||
export const useNsfwPrompt = create<{ open: boolean }>(() => ({ open: false }))
|
* Whether the 18+ confirmation dialog (components/nsfw-dialog.tsx) is open,
|
||||||
|
* and where focus goes when it closes (null: back to the control that opened it).
|
||||||
|
*/
|
||||||
|
export const useNsfwPrompt = create<{ open: boolean; returnFocus: HTMLElement | null }>(() => ({
|
||||||
|
open: false,
|
||||||
|
returnFocus: null,
|
||||||
|
}))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ask the visitor to confirm they are 18 or older before 18+ games are shown.
|
* Ask the visitor to confirm they are 18 or older before 18+ games are shown.
|
||||||
* An in-app dialog, not window.confirm (the macOS app's WebKit answers "Cancel").
|
* An in-app dialog, not window.confirm (the macOS app's WebKit answers "Cancel").
|
||||||
|
* `returnFocus`: where focus goes afterwards when the opener itself goes away
|
||||||
|
* (a switch inside a popover that closes).
|
||||||
*/
|
*/
|
||||||
export function requestNsfw(): void {
|
export function requestNsfw(returnFocus: HTMLElement | null = null): void {
|
||||||
useNsfwPrompt.setState({ open: true })
|
useNsfwPrompt.setState({ open: true, returnFocus })
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import { describe, expect, it } from 'vitest'
|
||||||
|
import { hashId, routeFocusTarget, type RouteSpot } from './route-focus'
|
||||||
|
|
||||||
|
const at = (pathname: string, search = '', hash = ''): RouteSpot => ({ pathname, search, hash })
|
||||||
|
|
||||||
|
describe('routeFocusTarget', () => {
|
||||||
|
it('leaves focus alone on the first render', () => {
|
||||||
|
expect(routeFocusTarget(null, at('/games'))).toBeNull()
|
||||||
|
expect(routeFocusTarget(null, at('/about', '', '#support'))).toBeNull()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('leaves focus alone when only the query string changes', () => {
|
||||||
|
expect(routeFocusTarget(at('/games'), at('/games', '?q=cat'))).toBeNull()
|
||||||
|
expect(routeFocusTarget(at('/games', '?page=2'), at('/games', '?page=3'))).toBeNull()
|
||||||
|
expect(routeFocusTarget(at('/games', '?genre=Puzzle'), at('/games'))).toBeNull()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('moves focus to the heading when the path changes', () => {
|
||||||
|
expect(routeFocusTarget(at('/games'), at('/games/some-game'))).toEqual({ kind: 'heading' })
|
||||||
|
expect(routeFocusTarget(at('/games/some-game'), at('/games', '?q=cat'))).toEqual({ kind: 'heading' })
|
||||||
|
// A redirect (/deleted → /removed) is a path change too.
|
||||||
|
expect(routeFocusTarget(at('/deleted'), at('/removed'))).toEqual({ kind: 'heading' })
|
||||||
|
})
|
||||||
|
|
||||||
|
it('moves focus to the section a new hash points at', () => {
|
||||||
|
expect(routeFocusTarget(at('/'), at('/about', '', '#support'))).toEqual({ kind: 'hash', id: 'support' })
|
||||||
|
expect(routeFocusTarget(at('/about'), at('/about', '', '#support'))).toEqual({ kind: 'hash', id: 'support' })
|
||||||
|
})
|
||||||
|
|
||||||
|
it('ignores an unchanged hash and an empty one', () => {
|
||||||
|
expect(routeFocusTarget(at('/about', '', '#support'), at('/about', '?x=1', '#support'))).toBeNull()
|
||||||
|
expect(routeFocusTarget(at('/'), at('/about', '', '#'))).toEqual({ kind: 'heading' })
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('hashId', () => {
|
||||||
|
it('strips the # and decodes the id', () => {
|
||||||
|
expect(hashId('#support')).toBe('support')
|
||||||
|
expect(hashId('support')).toBe('support')
|
||||||
|
expect(hashId('#h%C3%B6')).toBe('hö')
|
||||||
|
expect(hashId('')).toBe('')
|
||||||
|
expect(hashId('#')).toBe('')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('keeps a malformed escape as written', () => {
|
||||||
|
expect(hashId('#50%')).toBe('50%')
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/** The parts of a router location that decide where focus goes after a navigation. */
|
||||||
|
export interface RouteSpot {
|
||||||
|
pathname: string
|
||||||
|
search: string
|
||||||
|
hash: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RouteFocusTarget = { kind: 'heading' } | { kind: 'hash'; id: string } | null
|
||||||
|
|
||||||
|
/** The element id a location hash points at ('' when there is none). */
|
||||||
|
export function hashId(hash: string): string {
|
||||||
|
const raw = hash.startsWith('#') ? hash.slice(1) : hash
|
||||||
|
if (!raw) return ''
|
||||||
|
try {
|
||||||
|
return decodeURIComponent(raw)
|
||||||
|
} catch {
|
||||||
|
return raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where keyboard focus should land after an in-app navigation (App.tsx), so a
|
||||||
|
* screen reader announces the new page and Tab continues from its top instead
|
||||||
|
* of from the link that was used (WCAG 2.4.3):
|
||||||
|
*
|
||||||
|
* - `null` on the first render (`prev` is null — the browser starts at the
|
||||||
|
* top of the document anyway) and when only the query string changed (the
|
||||||
|
* Games search, filters and pager keep focus where the visitor is);
|
||||||
|
* - `hash` when the location points at a section (`/about#support`);
|
||||||
|
* - `heading` (the page's h1) whenever the path changed, whatever the
|
||||||
|
* navigation type (a link, back / forward, a redirect).
|
||||||
|
*/
|
||||||
|
export function routeFocusTarget(prev: RouteSpot | null, next: RouteSpot): RouteFocusTarget {
|
||||||
|
if (!prev) return null
|
||||||
|
const id = hashId(next.hash)
|
||||||
|
if (id && (next.hash !== prev.hash || next.pathname !== prev.pathname)) return { kind: 'hash', id }
|
||||||
|
if (next.pathname !== prev.pathname) return { kind: 'heading' }
|
||||||
|
return null
|
||||||
|
}
|
||||||
@@ -8,6 +8,8 @@ interface TurnstileOptions {
|
|||||||
sitekey: string
|
sitekey: string
|
||||||
action?: string
|
action?: string
|
||||||
theme?: 'auto' | 'light' | 'dark'
|
theme?: 'auto' | 'light' | 'dark'
|
||||||
|
/** The widget's language ('en', 'vi', … or 'auto'), so it matches the page around it. */
|
||||||
|
language?: string
|
||||||
callback: (token: string) => void
|
callback: (token: string) => void
|
||||||
'expired-callback'?: () => void
|
'expired-callback'?: () => void
|
||||||
'error-callback'?: () => void
|
'error-callback'?: () => void
|
||||||
|
|||||||
+21
-16
@@ -128,10 +128,7 @@ function SocialGroupSection({ group }: { group: SocialGroup }) {
|
|||||||
const noteKey = GROUP_NOTE[group]
|
const noteKey = GROUP_NOTE[group]
|
||||||
return (
|
return (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<h3
|
<h3 id={group === 'support' ? 'support' : undefined} lang="en" className="text-sm font-semibold text-muted-foreground">
|
||||||
id={group === 'support' ? 'support' : undefined}
|
|
||||||
className="text-sm font-semibold text-muted-foreground scroll-mt-20"
|
|
||||||
>
|
|
||||||
{SOCIAL_GROUP_LABELS[group]}
|
{SOCIAL_GROUP_LABELS[group]}
|
||||||
</h3>
|
</h3>
|
||||||
{noteKey && <p className="text-xs text-muted-foreground">{t(noteKey)}</p>}
|
{noteKey && <p className="text-xs text-muted-foreground">{t(noteKey)}</p>}
|
||||||
@@ -188,7 +185,7 @@ export default function About() {
|
|||||||
<CardContent className="space-y-2 text-sm">
|
<CardContent className="space-y-2 text-sm">
|
||||||
<p>
|
<p>
|
||||||
{t('about.app.descPrefix')}
|
{t('about.app.descPrefix')}
|
||||||
<ExtLink href={APP.repo} className="font-medium hover:underline">
|
<ExtLink href={APP.repo} className="font-medium underline underline-offset-4">
|
||||||
free-games-itchio-list
|
free-games-itchio-list
|
||||||
</ExtLink>
|
</ExtLink>
|
||||||
{t('about.app.descSuffix')}
|
{t('about.app.descSuffix')}
|
||||||
@@ -204,11 +201,13 @@ export default function About() {
|
|||||||
<CardContent className="space-y-2 text-sm">
|
<CardContent className="space-y-2 text-sm">
|
||||||
<div className="flex flex-wrap items-center gap-2">
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
<span className="font-medium">{DEV.name}</span>
|
<span className="font-medium">{DEV.name}</span>
|
||||||
<Badge variant="secondary" className="text-xs">
|
<Badge variant="secondary" lang="en" className="text-xs">
|
||||||
{DEV.role}
|
{DEV.role}
|
||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-muted-foreground">{DEV.blurb}</p>
|
<p lang="en" className="text-muted-foreground">
|
||||||
|
{DEV.blurb}
|
||||||
|
</p>
|
||||||
<ul className="space-y-1.5">
|
<ul className="space-y-1.5">
|
||||||
{DEV_LINKS.map(({ href, label, icon: Icon }) => (
|
{DEV_LINKS.map(({ href, label, icon: Icon }) => (
|
||||||
<li key={href}>
|
<li key={href}>
|
||||||
@@ -244,7 +243,9 @@ export default function About() {
|
|||||||
<Badge variant="secondary" className="font-mono text-xs">{tool.model}</Badge>
|
<Badge variant="secondary" className="font-mono text-xs">{tool.model}</Badge>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<p className="text-muted-foreground">{tool.role}</p>
|
<p lang="en" className="text-muted-foreground">
|
||||||
|
{tool.role}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
@@ -272,7 +273,7 @@ export default function About() {
|
|||||||
<p className="text-xs text-muted-foreground">{t('about.social.desc')}</p>
|
<p className="text-xs text-muted-foreground">{t('about.social.desc')}</p>
|
||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-xs text-muted-foreground">
|
||||||
{t('about.social.allLinks')}{' '}
|
{t('about.social.allLinks')}{' '}
|
||||||
<ExtLink href={DEV.linksUrl} className="font-medium text-foreground hover:underline">
|
<ExtLink href={DEV.linksUrl} className="font-medium text-foreground underline underline-offset-4">
|
||||||
{DEV.linksUrl.replace(/^https:\/\/|\/$/g, '')}
|
{DEV.linksUrl.replace(/^https:\/\/|\/$/g, '')}
|
||||||
</ExtLink>
|
</ExtLink>
|
||||||
</p>
|
</p>
|
||||||
@@ -302,7 +303,7 @@ export default function About() {
|
|||||||
return (
|
return (
|
||||||
<div key={group} className="space-y-2">
|
<div key={group} className="space-y-2">
|
||||||
{i > 0 && <Separator />}
|
{i > 0 && <Separator />}
|
||||||
<h3 className="text-sm font-semibold text-muted-foreground">
|
<h3 lang="en" className="text-sm font-semibold text-muted-foreground">
|
||||||
{LEGAL_GROUP_LABELS[group]}
|
{LEGAL_GROUP_LABELS[group]}
|
||||||
</h3>
|
</h3>
|
||||||
<ul className="grid grid-cols-1 gap-2 md:grid-cols-2">
|
<ul className="grid grid-cols-1 gap-2 md:grid-cols-2">
|
||||||
@@ -312,10 +313,12 @@ export default function About() {
|
|||||||
href={link.url}
|
href={link.url}
|
||||||
className="inline-flex items-center gap-1 font-medium hover:underline"
|
className="inline-flex items-center gap-1 font-medium hover:underline"
|
||||||
>
|
>
|
||||||
{link.name}
|
<span lang="en">{link.name}</span>
|
||||||
<ExternalLinkIcon className="h-3 w-3 opacity-50" />
|
<ExternalLinkIcon className="h-3 w-3 opacity-50" />
|
||||||
</ExtLink>
|
</ExtLink>
|
||||||
<p className="mt-0.5 text-xs text-muted-foreground">{link.description}</p>
|
<p lang="en" className="mt-0.5 text-xs text-muted-foreground">
|
||||||
|
{link.description}
|
||||||
|
</p>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
@@ -323,8 +326,8 @@ export default function About() {
|
|||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
<p className="pt-1 text-xs text-muted-foreground">
|
<p className="pt-1 text-xs text-muted-foreground">
|
||||||
Tiếng Việt:{' '}
|
<span lang="vi">Tiếng Việt</span>:{' '}
|
||||||
<ExtLink href={LEGAL_VI_INDEX_URL} className="font-medium hover:underline">
|
<ExtLink href={LEGAL_VI_INDEX_URL} className="font-medium underline underline-offset-4">
|
||||||
docs/i18n/vi/
|
docs/i18n/vi/
|
||||||
</ExtLink>{' '}
|
</ExtLink>{' '}
|
||||||
{t('about.legal.viNote')}
|
{t('about.legal.viNote')}
|
||||||
@@ -339,11 +342,13 @@ export default function About() {
|
|||||||
<CardContent className="space-y-2 text-sm">
|
<CardContent className="space-y-2 text-sm">
|
||||||
<p>
|
<p>
|
||||||
{t('about.upstream.source')}{' '}
|
{t('about.upstream.source')}{' '}
|
||||||
<ExtLink href={UPSTREAM_DATA.url} className="font-medium hover:underline">
|
<ExtLink href={UPSTREAM_DATA.url} className="font-medium underline underline-offset-4">
|
||||||
{UPSTREAM_DATA.source}
|
{UPSTREAM_DATA.source}
|
||||||
</ExtLink>
|
</ExtLink>
|
||||||
</p>
|
</p>
|
||||||
<p className="text-muted-foreground">{UPSTREAM_DATA.note}</p>
|
<p lang="en" className="text-muted-foreground">
|
||||||
|
{UPSTREAM_DATA.note}
|
||||||
|
</p>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ const PAGE = 'mx-auto max-w-[1440px] px-4 pt-6 pb-12 sm:px-8 md:pt-7'
|
|||||||
// Phones: one full-width row of equal tabs. A wrapping row overflowed the
|
// Phones: one full-width row of equal tabs. A wrapping row overflowed the
|
||||||
// fixed-height bar with the Vietnamese labels; the labels never shrink below
|
// fixed-height bar with the Vietnamese labels; the labels never shrink below
|
||||||
// their text, and on the narrowest screens the bar scrolls instead.
|
// their text, and on the narrowest screens the bar scrolls instead.
|
||||||
const TABS_LIST = 'max-md:flex max-md:h-11 max-md:w-full max-md:overflow-x-auto max-md:scrollbar-hide'
|
const TABS_LIST = 'max-md:flex max-md:h-11 max-md:w-full max-md:overflow-x-auto max-md:py-1.5 max-md:scrollbar-hide'
|
||||||
const TAB = 'max-md:h-full max-md:flex-1 max-md:px-1 max-md:text-[13px]'
|
const TAB = 'max-md:h-full max-md:flex-1 max-md:px-1 max-md:text-[13px]'
|
||||||
|
|
||||||
// A tab shown once stays mounted: switching back must not rebuild its charts and
|
// A tab shown once stays mounted: switching back must not rebuild its charts and
|
||||||
@@ -116,7 +116,7 @@ export default function Charts() {
|
|||||||
</Heading>
|
</Heading>
|
||||||
|
|
||||||
<Tabs value={tab} onValueChange={select}>
|
<Tabs value={tab} onValueChange={select}>
|
||||||
<TabsList className={TABS_LIST}>
|
<TabsList aria-label={t('charts.tabs.label')} className={TABS_LIST}>
|
||||||
{TABS.map(({ id, preload }) => (
|
{TABS.map(({ id, preload }) => (
|
||||||
<TabsTrigger
|
<TabsTrigger
|
||||||
key={id}
|
key={id}
|
||||||
|
|||||||
@@ -35,14 +35,16 @@ export default function Removed() {
|
|||||||
<h1 className="text-[26px] font-semibold tracking-[-0.02em]">{t('titles.deleted')}</h1>
|
<h1 className="text-[26px] font-semibold tracking-[-0.02em]">{t('titles.deleted')}</h1>
|
||||||
<p className="max-w-[680px] text-sm leading-relaxed text-muted-foreground">{t('deleted.intro')}</p>
|
<p className="max-w-[680px] text-sm leading-relaxed text-muted-foreground">{t('deleted.intro')}</p>
|
||||||
{!deleted.isPending && (
|
{!deleted.isPending && (
|
||||||
<p className="font-mono text-xs text-muted-foreground">
|
<p role="status" className="font-mono text-xs text-muted-foreground">
|
||||||
{t(sorted.length === 1 ? 'deleted.count.one' : 'deleted.count', { count: fmt.number(sorted.length) })}
|
{needle
|
||||||
|
? t('deleted.countFiltered', { shown: fmt.number(shown.length), count: fmt.number(sorted.length) })
|
||||||
|
: t(sorted.length === 1 ? 'deleted.count.one' : 'deleted.count', { count: fmt.number(sorted.length) })}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{sorted.length > 10 && (
|
{sorted.length > 10 && (
|
||||||
<label className="flex h-11 items-center gap-2 rounded-[10px] border bg-card px-3 text-muted-foreground focus-within:border-primary md:h-[34px] md:w-80 md:rounded-lg">
|
<label className="flex h-11 items-center gap-2 rounded-[10px] border border-input bg-card px-3 text-muted-foreground focus-within:border-primary focus-within:ring-1 focus-within:ring-primary md:h-[34px] md:w-80 md:rounded-lg">
|
||||||
<Search className="size-4 shrink-0 md:size-[15px]" aria-hidden="true" />
|
<Search className="size-4 shrink-0 md:size-[15px]" aria-hidden="true" />
|
||||||
<input
|
<input
|
||||||
type="search"
|
type="search"
|
||||||
@@ -50,13 +52,14 @@ export default function Removed() {
|
|||||||
onChange={(e) => setFind(e.target.value)}
|
onChange={(e) => setFind(e.target.value)}
|
||||||
placeholder={t('deleted.search')}
|
placeholder={t('deleted.search')}
|
||||||
aria-label={t('deleted.search')}
|
aria-label={t('deleted.search')}
|
||||||
className="min-w-0 flex-1 bg-transparent text-[15px] text-foreground outline-hidden placeholder:text-muted-foreground md:text-[13px]"
|
className="min-w-0 flex-1 bg-transparent text-[15px] text-foreground placeholder:text-muted-foreground focus-visible:outline-hidden md:text-[13px]"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{deleted.isPending ? (
|
{deleted.isPending ? (
|
||||||
<div className="space-y-2">
|
<div role="status" className="space-y-2">
|
||||||
|
<span className="sr-only">{t('common.loading')}</span>
|
||||||
{Array.from({ length: 6 }).map((_, i) => (
|
{Array.from({ length: 6 }).map((_, i) => (
|
||||||
<Skeleton key={i} className="h-14 rounded-lg" />
|
<Skeleton key={i} className="h-14 rounded-lg" />
|
||||||
))}
|
))}
|
||||||
@@ -93,9 +96,12 @@ export default function Removed() {
|
|||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<span className="text-[13px] text-muted-foreground max-md:col-start-1 max-md:row-start-2" title={d.reason}>
|
<span className="text-[13px] text-muted-foreground max-md:col-start-1 max-md:row-start-2" title={d.reason}>
|
||||||
|
{/* The column header row is hidden from screen readers: each value says what it is. */}
|
||||||
|
<span className="sr-only">{t('deleted.col.reason')}: </span>
|
||||||
{key ? t(key) : d.reason}
|
{key ? t(key) : d.reason}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-right font-mono text-xs text-muted-foreground max-md:col-start-2 max-md:row-start-1">
|
<span className="text-right font-mono text-xs text-muted-foreground max-md:col-start-2 max-md:row-start-1">
|
||||||
|
<span className="sr-only">{t('deleted.col.date')}: </span>
|
||||||
{fmt.date(d.deleted_at)}
|
{fmt.date(d.deleted_at)}
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default function ErrorPreview() {
|
|||||||
const { code } = useParams()
|
const { code } = useParams()
|
||||||
const t = useT()
|
const t = useT()
|
||||||
const status = Number(code)
|
const status = Number(code)
|
||||||
useDocumentTitle(`Error ${code ?? ''}`)
|
useDocumentTitle(t('titles.error', { code: code ?? '' }))
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col">
|
<div className="flex h-full flex-col">
|
||||||
<p className="px-6 pt-4 text-center text-xs text-muted-foreground">
|
<p className="px-6 pt-4 text-center text-xs text-muted-foreground">
|
||||||
|
|||||||
@@ -125,7 +125,6 @@ function CopyLink({ url }: { url: string }) {
|
|||||||
function GameDetailView({ game }: { game: Game }) {
|
function GameDetailView({ game }: { game: Game }) {
|
||||||
const t = useT()
|
const t = useT()
|
||||||
const fmt = useFormat()
|
const fmt = useFormat()
|
||||||
useDocumentTitle(game.name)
|
|
||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
// Came from the list: going back returns to the same entry (scroll position,
|
// Came from the list: going back returns to the same entry (scroll position,
|
||||||
@@ -221,7 +220,7 @@ function GameDetailView({ game }: { game: Game }) {
|
|||||||
<div className="flex flex-wrap gap-2.5">
|
<div className="flex flex-wrap gap-2.5">
|
||||||
<ExtLink
|
<ExtLink
|
||||||
href={game.url}
|
href={game.url}
|
||||||
className="flex h-[42px] items-center gap-2 rounded-[9px] bg-primary px-[18px] text-[15px] font-medium text-primary-foreground hover:opacity-90"
|
className="flex h-[42px] items-center gap-2 rounded-[9px] bg-primary px-[18px] text-[15px] font-medium text-primary-foreground hover:bg-primary/90"
|
||||||
>
|
>
|
||||||
{t('detail.openOnItch')}
|
{t('detail.openOnItch')}
|
||||||
<ArrowUpRight className="size-3.5" aria-hidden="true" />
|
<ArrowUpRight className="size-3.5" aria-hidden="true" />
|
||||||
@@ -280,10 +279,22 @@ export default function GameDetail() {
|
|||||||
const { slug } = useParams()
|
const { slug } = useParams()
|
||||||
const decoded = slug ? decodeURIComponent(slug) : undefined
|
const decoded = slug ? decodeURIComponent(slug) : undefined
|
||||||
const { game, data, isLoading, isError, error, refetch } = useGameBySlug(decoded)
|
const { game, data, isLoading, isError, error, refetch } = useGameBySlug(decoded)
|
||||||
|
const showNsfw = usePrefs((s) => s.showNsfw)
|
||||||
|
// One title for every state of the page (the not-found page and the 18+ notice included).
|
||||||
|
useDocumentTitle(
|
||||||
|
isLoading || (isError && !data)
|
||||||
|
? undefined
|
||||||
|
: !game
|
||||||
|
? t('error.gameNotFound.title')
|
||||||
|
: isNsfw(game) && !showNsfw
|
||||||
|
? t('nsfw.gate.title')
|
||||||
|
: game.name,
|
||||||
|
)
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="mx-auto flex max-w-[1120px] flex-col gap-7 px-4 pt-7 sm:px-8">
|
<div role="status" className="mx-auto flex max-w-[1120px] flex-col gap-7 px-4 pt-7 sm:px-8">
|
||||||
|
<span className="sr-only">{t('common.loading')}</span>
|
||||||
<Skeleton className="h-4 w-40" />
|
<Skeleton className="h-4 w-40" />
|
||||||
<div className="grid gap-10 md:grid-cols-[minmax(0,520px)_minmax(0,1fr)]">
|
<div className="grid gap-10 md:grid-cols-[minmax(0,520px)_minmax(0,1fr)]">
|
||||||
<Skeleton className="aspect-[630/500] rounded-[14px]" />
|
<Skeleton className="aspect-[630/500] rounded-[14px]" />
|
||||||
@@ -336,7 +347,7 @@ function NsfwGate({ game }: { game: Game }) {
|
|||||||
<h1 className="text-2xl font-semibold tracking-tight">{t('nsfw.gate.title')}</h1>
|
<h1 className="text-2xl font-semibold tracking-tight">{t('nsfw.gate.title')}</h1>
|
||||||
<p className="text-muted-foreground">{t('nsfw.gate.desc')}</p>
|
<p className="text-muted-foreground">{t('nsfw.gate.desc')}</p>
|
||||||
<div className="flex flex-wrap gap-2">
|
<div className="flex flex-wrap gap-2">
|
||||||
<Button onClick={requestNsfw}>{t('nsfw.gate.show')}</Button>
|
<Button onClick={() => requestNsfw()}>{t('nsfw.gate.show')}</Button>
|
||||||
<Button variant="outline" asChild>
|
<Button variant="outline" asChild>
|
||||||
<Link to="/games">{t('detail.backToGames')}</Link>
|
<Link to="/games">{t('detail.backToGames')}</Link>
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -69,8 +69,10 @@ function optionLabel(key: ListFilter, value: string, t: (key: MessageKey) => str
|
|||||||
}
|
}
|
||||||
|
|
||||||
function ListSkeleton() {
|
function ListSkeleton() {
|
||||||
|
const t = useT()
|
||||||
return (
|
return (
|
||||||
<div className="overflow-hidden rounded-xl border bg-card">
|
<div role="status" className="overflow-hidden rounded-xl border bg-card">
|
||||||
|
<span className="sr-only">{t('common.loading')}</span>
|
||||||
{Array.from({ length: 8 }).map((_, i) => (
|
{Array.from({ length: 8 }).map((_, i) => (
|
||||||
<div key={i} className="flex h-14 items-center gap-3 border-b px-4 last:border-b-0">
|
<div key={i} className="flex h-14 items-center gap-3 border-b px-4 last:border-b-0">
|
||||||
<Skeleton className="h-9 w-12 rounded-md" />
|
<Skeleton className="h-9 w-12 rounded-md" />
|
||||||
@@ -138,6 +140,8 @@ export default function Games() {
|
|||||||
// Counts for a filter ignore that filter's own choices, so picking a second
|
// Counts for a filter ignore that filter's own choices, so picking a second
|
||||||
// genre still shows how many games it would add.
|
// genre still shows how many games it would add.
|
||||||
const listRef = useRef<HTMLDivElement>(null)
|
const listRef = useRef<HTMLDivElement>(null)
|
||||||
|
const searchInput = useRef<HTMLInputElement>(null)
|
||||||
|
const focusSearch = useCallback(() => searchInput.current?.focus(), [])
|
||||||
const focusList = useRef(false)
|
const focusList = useRef(false)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!focusList.current) return
|
if (!focusList.current) return
|
||||||
@@ -178,6 +182,8 @@ export default function Games() {
|
|||||||
setText('')
|
setText('')
|
||||||
setOwnQ('')
|
setOwnQ('')
|
||||||
update({ ...emptyQuery(), sort: query.sort })
|
update({ ...emptyQuery(), sort: query.sort })
|
||||||
|
// The button disappears with the empty state.
|
||||||
|
focusSearch()
|
||||||
}
|
}
|
||||||
|
|
||||||
const pages = Math.max(1, Math.ceil(results.length / PAGE_SIZE))
|
const pages = Math.max(1, Math.ceil(results.length / PAGE_SIZE))
|
||||||
@@ -216,21 +222,22 @@ export default function Games() {
|
|||||||
<ToggleChip label={t('games.filter.browser')} pressed={query.browser} onChange={(browser) => update({ browser })} />
|
<ToggleChip label={t('games.filter.browser')} pressed={query.browser} onChange={(browser) => update({ browser })} />
|
||||||
{MORE_FILTERS.map(filterMenu)}
|
{MORE_FILTERS.map(filterMenu)}
|
||||||
{(games.hiddenNsfw > 0 || showNsfw) && (
|
{(games.hiddenNsfw > 0 || showNsfw) && (
|
||||||
<NsfwChip shown={showNsfw} onShow={requestNsfw} onHide={() => setShowNsfw(false)} />
|
<NsfwChip shown={showNsfw} onShow={() => requestNsfw()} onHide={() => setShowNsfw(false)} />
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
||||||
const search = (
|
const search = (
|
||||||
<label className="flex h-11 items-center gap-2 rounded-[10px] border bg-card px-3 text-muted-foreground focus-within:border-primary md:h-[34px] md:w-80 md:rounded-lg">
|
<label className="flex h-11 items-center gap-2 rounded-[10px] border border-input bg-card px-3 text-muted-foreground focus-within:border-primary focus-within:ring-1 focus-within:ring-primary md:h-[34px] md:w-80 md:rounded-lg">
|
||||||
<Search className="size-4 shrink-0 md:size-[15px]" aria-hidden="true" />
|
<Search className="size-4 shrink-0 md:size-[15px]" aria-hidden="true" />
|
||||||
<input
|
<input
|
||||||
|
ref={searchInput}
|
||||||
type="search"
|
type="search"
|
||||||
value={text}
|
value={text}
|
||||||
onChange={(e) => setText(e.target.value)}
|
onChange={(e) => setText(e.target.value)}
|
||||||
placeholder={t('games.search.placeholder')}
|
placeholder={t('games.search.placeholder')}
|
||||||
aria-label={t('header.search.label')}
|
aria-label={t('games.search.label')}
|
||||||
className="min-w-0 flex-1 bg-transparent text-[15px] text-foreground outline-hidden placeholder:text-muted-foreground md:text-[13px] [&::-webkit-search-cancel-button]:hidden"
|
className="min-w-0 flex-1 bg-transparent text-[15px] text-foreground placeholder:text-muted-foreground focus-visible:outline-hidden md:text-[13px] [&::-webkit-search-cancel-button]:hidden"
|
||||||
/>
|
/>
|
||||||
{text && (
|
{text && (
|
||||||
<button
|
<button
|
||||||
@@ -240,6 +247,7 @@ export default function Games() {
|
|||||||
setText('')
|
setText('')
|
||||||
setOwnQ('')
|
setOwnQ('')
|
||||||
update({ q: '' })
|
update({ q: '' })
|
||||||
|
focusSearch()
|
||||||
}}
|
}}
|
||||||
className="-mr-1 flex size-8 items-center justify-center rounded-md hover:text-foreground md:size-6"
|
className="-mr-1 flex size-8 items-center justify-center rounded-md hover:text-foreground md:size-6"
|
||||||
>
|
>
|
||||||
@@ -255,7 +263,7 @@ export default function Games() {
|
|||||||
<select
|
<select
|
||||||
value={query.sort}
|
value={query.sort}
|
||||||
onChange={(e) => update({ sort: e.target.value as SortKey })}
|
onChange={(e) => update({ sort: e.target.value as SortKey })}
|
||||||
className="h-9 rounded-lg border bg-card px-2 text-[13px] text-foreground md:h-8"
|
className="h-9 rounded-lg border border-input bg-card px-2 text-[13px] text-foreground md:h-8"
|
||||||
>
|
>
|
||||||
{SORT_KEYS.map((key) => (
|
{SORT_KEYS.map((key) => (
|
||||||
<option key={key} value={key}>
|
<option key={key} value={key}>
|
||||||
@@ -292,7 +300,7 @@ export default function Games() {
|
|||||||
} else {
|
} else {
|
||||||
content = (
|
content = (
|
||||||
<>
|
<>
|
||||||
<div ref={listRef} tabIndex={-1} className="outline-hidden">
|
<div ref={listRef} tabIndex={-1} className="outline-none">
|
||||||
{isMobile ? (
|
{isMobile ? (
|
||||||
<GamesList games={rows} back={back} />
|
<GamesList games={rows} back={back} />
|
||||||
) : (
|
) : (
|
||||||
@@ -317,7 +325,8 @@ export default function Games() {
|
|||||||
<>
|
<>
|
||||||
<h1 className="sr-only">{t('titles.games')}</h1>
|
<h1 className="sr-only">{t('titles.games')}</h1>
|
||||||
{search}
|
{search}
|
||||||
<div className="scrollbar-hide -mx-4 flex gap-2 overflow-x-auto px-4">{chips}</div>
|
{/* py-1: room for the chips' focus outline inside the scroller. */}
|
||||||
|
<div className="scrollbar-hide -mx-4 -my-1 flex gap-2 overflow-x-auto px-4 py-1">{chips}</div>
|
||||||
<div className="flex items-center justify-between gap-3">
|
<div className="flex items-center justify-between gap-3">
|
||||||
<p role="status" className="font-mono text-xs text-muted-foreground">
|
<p role="status" className="font-mono text-xs text-muted-foreground">
|
||||||
{t(results.length === 1 ? 'games.countShort.one' : 'games.countShort', {
|
{t(results.length === 1 ? 'games.countShort.one' : 'games.countShort', {
|
||||||
@@ -347,7 +356,7 @@ export default function Games() {
|
|||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<ActiveFilters pills={pills} onClearAll={clearFilters} />
|
<ActiveFilters pills={pills} onClearAll={clearFilters} onEmpty={focusSearch} />
|
||||||
{query.q && descs.failed && (
|
{query.q && descs.failed && (
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
{t('games.search.descFailed')}{' '}
|
{t('games.search.descFailed')}{' '}
|
||||||
|
|||||||
@@ -1,7 +1,15 @@
|
|||||||
import type { ReactNode } from 'react'
|
import type { ReactNode } from 'react'
|
||||||
import { Switch } from '@/components/ui/switch'
|
import { ExtLink } from '@/components/ext-link'
|
||||||
import { DensityChoice, LanguageChoice, ScrollbarsToggle, ThemeChoice } from '@/components/site/preference-controls'
|
import {
|
||||||
|
DensityChoice,
|
||||||
|
LanguageChoice,
|
||||||
|
ScrollbarsToggle,
|
||||||
|
SlashShortcutToggle,
|
||||||
|
SwitchRow,
|
||||||
|
ThemeChoice,
|
||||||
|
} from '@/components/site/preference-controls'
|
||||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle'
|
import { useDocumentTitle } from '@/hooks/useDocumentTitle'
|
||||||
|
import { ACCESSIBILITY_URLS } from '@/lib/about'
|
||||||
import { requestNsfw } from '@/lib/nsfw'
|
import { requestNsfw } from '@/lib/nsfw'
|
||||||
import { useT } from '@/lib/i18n'
|
import { useT } from '@/lib/i18n'
|
||||||
import { usePrefs } from '@/stores/prefs'
|
import { usePrefs } from '@/stores/prefs'
|
||||||
@@ -24,6 +32,7 @@ export default function Settings() {
|
|||||||
useDocumentTitle(t('titles.settings'))
|
useDocumentTitle(t('titles.settings'))
|
||||||
const showNsfw = usePrefs((s) => s.showNsfw)
|
const showNsfw = usePrefs((s) => s.showNsfw)
|
||||||
const setShowNsfw = usePrefs((s) => s.setShowNsfw)
|
const setShowNsfw = usePrefs((s) => s.setShowNsfw)
|
||||||
|
const language = usePrefs((s) => s.language)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx-auto flex max-w-2xl flex-col gap-6 px-4 pt-6 pb-12 sm:px-8 md:pt-7">
|
<div className="mx-auto flex max-w-2xl flex-col gap-6 px-4 pt-6 pb-12 sm:px-8 md:pt-7">
|
||||||
@@ -36,20 +45,23 @@ export default function Settings() {
|
|||||||
<ScrollbarsToggle id="hide-scrollbars" describe />
|
<ScrollbarsToggle id="hide-scrollbars" describe />
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
|
<Section title={t('settings.a11y.title')} description={t('settings.a11y.desc')}>
|
||||||
|
<SlashShortcutToggle id="slash-shortcut" />
|
||||||
|
<p className="text-sm">
|
||||||
|
<ExtLink href={ACCESSIBILITY_URLS[language]} className="font-medium underline underline-offset-4">
|
||||||
|
{t('settings.a11y.statement')}
|
||||||
|
</ExtLink>
|
||||||
|
</p>
|
||||||
|
</Section>
|
||||||
|
|
||||||
<Section title={t('settings.content.title')}>
|
<Section title={t('settings.content.title')}>
|
||||||
<div className="flex items-center justify-between gap-4">
|
<SwitchRow
|
||||||
<div className="space-y-0.5">
|
id="show-nsfw"
|
||||||
<label htmlFor="show-nsfw" className="text-sm font-medium">
|
label={t('settings.content.nsfw')}
|
||||||
{t('settings.content.nsfw')}
|
description={t('settings.content.nsfwDesc')}
|
||||||
</label>
|
checked={showNsfw}
|
||||||
<p className="text-sm text-muted-foreground">{t('settings.content.nsfwDesc')}</p>
|
onCheckedChange={(on) => (on ? requestNsfw() : setShowNsfw(false))}
|
||||||
</div>
|
/>
|
||||||
<Switch
|
|
||||||
id="show-nsfw"
|
|
||||||
checked={showNsfw}
|
|
||||||
onCheckedChange={(on) => (on ? requestNsfw() : setShowNsfw(false))}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</Section>
|
</Section>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
Loaded 100 of 104 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user