feat: add keyboard shortcuts and accessibility improvements
CI / test (push) Successful in 14s

This commit is contained in:
strsv committed 2026-11-06 09:00:43 +03:00
1 parent 31a7f11827
commit f25d218756
8 files changed
+77 -27

No files matched your search

+33 -2
View File
@@ -250,7 +250,7 @@ function cardHtml(g, mode = "library") {
const matched = mode === "reco" && g.matched && g.matched.length
? `<p class="matched">${g.matched.map(esc).join(" · ")}</p>` : "";
return `
<article class="card" data-appid="${g.appid}" tabindex="0">
<article class="card" data-appid="${g.appid}" tabindex="0" role="button" aria-label="Открыть ${esc(g.name)}">
<div class="cover">
<img data-appid="${g.appid}" loading="lazy" src="${coverUrl(g.appid)}" alt="">
<div class="fallback">${esc(initials(g.name))}</div>
@@ -1120,9 +1120,40 @@ $("#refreshFull").addEventListener("click", () => {
});
document.addEventListener("keydown", (e) => {
if (e.key === "/" && !/input|textarea|select/i.test(document.activeElement.tagName)) {
const typing = /input|textarea|select/i.test(document.activeElement.tagName)
|| document.activeElement.isContentEditable;
if (e.key === "Escape") {
if ($("#modal").open) return;
const openDetails = document.querySelector("details.multi-select[open]");
if (openDetails) {
openDetails.open = false;
return;
}
if (state.selectionMode) {
$("#selectMode").click();
return;
}
if (filtersState.open && !filtersState.pinned) closeFilters();
return;
}
if (e.key === "/" && !typing) {
e.preventDefault();
$("#search").focus();
return;
}
if (typing || $("#modal").open || e.ctrlKey || e.metaKey || e.altKey) return;
if (e.key === "g") {
e.preventDefault();
$("#layoutToggle").click();
} else if (e.key === "f") {
e.preventDefault();
toggleFilters();
} else if (e.key === "t") {
e.preventDefault();
themeToggle.click();
} else if (e.key === "?") {
e.preventDefault();
toast("Клавиши: / поиск · f фильтры · g вид · t тема · Esc закрыть");
}
});
+17 -15
View File
@@ -29,8 +29,9 @@ try {
<button class="tab" data-view="recommend">Рекомендации</button>
</nav>
<div class="stats" id="stats"></div>
<button id="themeToggle" class="icon-btn theme-toggle" type="button"
title="Светлая тема" aria-label="Переключить тему" aria-pressed="false">
<button id="themeToggle" class="icon-btn theme-toggle" type="button"
title="Светлая тема" aria-label="Переключить тему" aria-pressed="false"
aria-keyshortcuts="t">
<svg class="icon-sun" viewBox="0 0 24 24" width="16" height="16" fill="none"
stroke="currentColor" stroke-width="1.8" stroke-linecap="round">
<circle cx="12" cy="12" r="4"/>
@@ -46,7 +47,7 @@ try {
<div id="filtersBackdrop" class="filters-backdrop" hidden></div>
<main>
<section id="libraryView" class="layout">
<aside class="filters" id="filtersPanel">
<aside class="filters" id="filtersPanel" aria-label="Фильтры">
<div class="saved-views">
<select id="savedView" aria-label="Сохранённые виды">
<option value="">сохранённые виды</option>
@@ -107,22 +108,22 @@ try {
<div class="field">
<span>Часы</span>
<div class="range-row">
<input id="fHoursMin" type="number" min="0" step="1" placeholder="от" data-filter="minHours">
<input id="fHoursMax" type="number" min="0" step="1" placeholder="до" data-filter="maxHours">
<input id="fHoursMin" type="number" min="0" step="1" placeholder="от" data-filter="minHours" aria-label="Минимум часов">
<input id="fHoursMax" type="number" min="0" step="1" placeholder="до" data-filter="maxHours" aria-label="Максимум часов">
</div>
</div>
<div class="field">
<span>Год</span>
<div class="range-row">
<input id="fYearMin" type="number" min="1970" max="2100" step="1" placeholder="от" data-filter="minYear">
<input id="fYearMax" type="number" min="1970" max="2100" step="1" placeholder="до" data-filter="maxYear">
<input id="fYearMin" type="number" min="1970" max="2100" step="1" placeholder="от" data-filter="minYear" aria-label="Минимальный год">
<input id="fYearMax" type="number" min="1970" max="2100" step="1" placeholder="до" data-filter="maxYear" aria-label="Максимальный год">
</div>
</div>
<div class="field">
<span>Отзывы, %</span>
<div class="range-row">
<input id="fReviewMin" type="number" min="0" max="100" step="1" placeholder="от" data-filter="minReview">
<input id="fReviewMax" type="number" min="0" max="100" step="1" placeholder="до" data-filter="maxReview">
<input id="fReviewMin" type="number" min="0" max="100" step="1" placeholder="от" data-filter="minReview" aria-label="Минимум процента отзывов">
<input id="fReviewMax" type="number" min="0" max="100" step="1" placeholder="до" data-filter="maxReview" aria-label="Максимум процента отзывов">
</div>
</div>
@@ -175,8 +176,8 @@ try {
<div class="content">
<div class="toolbar">
<button id="filtersToggle" class="icon-btn" type="button" title="Скрыть фильтры"
aria-controls="filtersPanel" aria-expanded="true">
<button id="filtersToggle" class="icon-btn" type="button" title="Скрыть фильтры"
aria-controls="filtersPanel" aria-expanded="true" aria-keyshortcuts="f">
<svg viewBox="0 0 24 24" width="18" height="18" fill="none"
stroke="currentColor" stroke-width="1.8" stroke-linecap="round">
<path d="M4 7h16M4 12h16M4 17h16"/>
@@ -185,7 +186,8 @@ try {
<circle cx="8" cy="17" r="2.2" fill="var(--bg)"/>
</svg>
</button>
<input id="search" type="search" placeholder="Поиск: название, описание, тег…" autocomplete="off">
<input id="search" type="search" placeholder="Поиск: название, описание, тег…" autocomplete="off"
aria-keyshortcuts="/">
<select id="sort">
<option value="name">по названию</option>
<option value="hours">по времени</option>
@@ -194,12 +196,12 @@ try {
<option value="added">по добавлению</option>
</select>
<button id="layoutToggle" class="ghost toolbar-select" type="button"
aria-pressed="false" title="Компактный список">список</button>
aria-pressed="false" title="Компактный список" aria-keyshortcuts="g">список</button>
<button id="selectMode" class="ghost toolbar-select" type="button">выбрать</button>
<span class="count" id="count"></span>
<span class="count" id="count" aria-live="polite"></span>
</div>
<div class="bulk-bar" id="bulkBar" hidden>
<b id="bulkCount">0 выбрано</b>
<b id="bulkCount" aria-live="polite">0 выбрано</b>
<select id="bulkStatus" aria-label="Статус для выбранных">
<option value="">статус…</option>
<option value="backlog">в бэклоге</option>
+8
View File
@@ -250,6 +250,14 @@ textarea { resize: vertical; min-height: 54px; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.check:hover { color: var(--text); }
.card:focus-visible,
button:focus-visible,
summary:focus-visible,
.chip:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
.multi-select { margin: 0; }
.multi-toggle {
list-style: none;