feat: add compact library list mode
CI / test (push) Successful in 14s

This commit is contained in:
strsv committed 2026-11-06 08:56:40 +03:00
1 parent c811107776
commit 31a7f11827
8 files changed
+65 -8

No files matched your search

+22
View File
@@ -10,6 +10,7 @@ const STATUS_LABEL = {
const PER_PAGE = 60;
const THEME_KEY = "sb.theme";
const VIEWS_KEY = "sb.views";
const LAYOUT_KEY = "sb.layout";
function defaultFilters() {
return {
@@ -924,6 +925,27 @@ grid.addEventListener("change", (event) => {
if (input) setSelected(Number(input.value), input.checked);
});
function applyLayout(mode) {
const list = mode === "list";
grid.classList.toggle("list-view", list);
const button = $("#layoutToggle");
button.textContent = list ? "сетка" : "список";
button.title = list ? "Сетка карточек" : "Компактный список";
button.setAttribute("aria-pressed", String(list));
}
$("#layoutToggle").addEventListener("click", () => {
const mode = grid.classList.contains("list-view") ? "grid" : "list";
applyLayout(mode);
try { localStorage.setItem(LAYOUT_KEY, mode); } catch (_) {}
});
try {
applyLayout(localStorage.getItem(LAYOUT_KEY) === "list" ? "list" : "grid");
} catch (_) {
applyLayout("grid");
}
$("#selectMode").addEventListener("click", () => {
state.selectionMode = !state.selectionMode;
state.selected.clear();
+2
View File
@@ -193,6 +193,8 @@ try {
<option value="year">по году</option>
<option value="added">по добавлению</option>
</select>
<button id="layoutToggle" class="ghost toolbar-select" type="button"
aria-pressed="false" title="Компактный список">список</button>
<button id="selectMode" class="ghost toolbar-select" type="button">выбрать</button>
<span class="count" id="count"></span>
</div>
+26
View File
@@ -422,6 +422,32 @@ html[data-theme="light"] .select-box {
gap: 18px;
}
.grid.list-view { display: flex; flex-direction: column; gap: 8px; }
.grid.list-view .card {
display: grid;
grid-template-columns: 76px minmax(0, 1fr);
align-items: stretch;
}
.grid.list-view .cover {
aspect-ratio: auto;
min-height: 112px;
height: 100%;
border-right: 1px solid var(--border);
}
.grid.list-view .card-body {
display: block;
padding: 10px 14px;
}
.grid.list-view .card-title { margin-bottom: 4px; }
.grid.list-view .card-meta { margin-bottom: 4px; }
.grid.list-view .card-desc {
-webkit-line-clamp: 1;
min-height: 0;
margin-top: 6px;
}
.grid.list-view .card-status { margin-top: 6px; }
.grid.list-view .select-box { right: 6px; bottom: 6px; width: 24px; height: 24px; }
.card {
display: flex;
flex-direction: column;