feat: new branding and collapsible filter sidebar
This commit is contained in:
1 parent
d1aee28115
commit
e433ca3842
10 files changed
+335
-44
No files matched your search
@@ -26,6 +26,118 @@ const grid = $("#grid");
|
||||
const recoGrid = $("#recoGrid");
|
||||
let descTimer = null;
|
||||
|
||||
const FILTERS_KEY = "sb.filters";
|
||||
const mobileMq = window.matchMedia("(max-width: 980px)");
|
||||
|
||||
function readFiltersState() {
|
||||
let saved = {};
|
||||
try { saved = JSON.parse(localStorage.getItem(FILTERS_KEY) || "{}"); } catch (_) {}
|
||||
const mobile = mobileMq.matches;
|
||||
return {
|
||||
pinned: mobile ? false : saved.pinned !== false,
|
||||
open: mobile ? false : saved.open !== false,
|
||||
};
|
||||
}
|
||||
|
||||
let filtersState = readFiltersState();
|
||||
|
||||
function saveFiltersState() {
|
||||
try {
|
||||
localStorage.setItem(FILTERS_KEY, JSON.stringify({
|
||||
pinned: filtersState.pinned,
|
||||
open: filtersState.open,
|
||||
}));
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
function applyFiltersState() {
|
||||
const layout = document.querySelector(".layout");
|
||||
const panel = $("#filtersPanel");
|
||||
const backdrop = $("#filtersBackdrop");
|
||||
const toggle = $("#filtersToggle");
|
||||
const pin = $("#filtersPin");
|
||||
const mobile = mobileMq.matches;
|
||||
if (mobile) filtersState.pinned = false;
|
||||
const pinned = filtersState.pinned;
|
||||
const open = filtersState.open;
|
||||
|
||||
layout.classList.toggle("filters-unpinned", !pinned);
|
||||
layout.classList.toggle("filters-collapsed", pinned && !open);
|
||||
panel.classList.toggle("open", !pinned && open);
|
||||
panel.classList.toggle("pinned", pinned);
|
||||
backdrop.hidden = !(!pinned && open);
|
||||
document.body.classList.toggle("drawer-open", !pinned && open);
|
||||
|
||||
pin.classList.toggle("active", pinned);
|
||||
pin.setAttribute("aria-pressed", String(pinned));
|
||||
pin.title = pinned ? "Открепить фильтры" : "Закрепить фильтры";
|
||||
|
||||
toggle.classList.toggle("active", open);
|
||||
toggle.setAttribute("aria-expanded", String(open));
|
||||
toggle.title = open ? "Скрыть фильтры" : "Показать фильтры";
|
||||
}
|
||||
|
||||
function toggleFilters() {
|
||||
filtersState.open = !filtersState.open;
|
||||
saveFiltersState();
|
||||
applyFiltersState();
|
||||
}
|
||||
|
||||
function closeFilters() {
|
||||
filtersState.open = false;
|
||||
saveFiltersState();
|
||||
applyFiltersState();
|
||||
}
|
||||
|
||||
$("#filtersToggle").addEventListener("click", toggleFilters);
|
||||
$("#filtersClose").addEventListener("click", closeFilters);
|
||||
$("#filtersBackdrop").addEventListener("click", closeFilters);
|
||||
$("#filtersPin").addEventListener("click", () => {
|
||||
if (mobileMq.matches) return;
|
||||
filtersState.pinned = !filtersState.pinned;
|
||||
filtersState.open = true;
|
||||
saveFiltersState();
|
||||
applyFiltersState();
|
||||
});
|
||||
|
||||
mobileMq.addEventListener("change", () => {
|
||||
if (mobileMq.matches) {
|
||||
filtersState.pinned = false;
|
||||
filtersState.open = false;
|
||||
} else {
|
||||
filtersState = readFiltersState();
|
||||
}
|
||||
applyFiltersState();
|
||||
});
|
||||
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (e.key === "Escape" && filtersState.open && !document.querySelector("dialog[open]")) {
|
||||
closeFilters();
|
||||
}
|
||||
});
|
||||
|
||||
applyFiltersState();
|
||||
|
||||
const MAINTENANCE_KEY = "sb.maintenance";
|
||||
let maintenanceOpen = false;
|
||||
try { maintenanceOpen = localStorage.getItem(MAINTENANCE_KEY) === "1"; } catch (_) {}
|
||||
|
||||
const maintenance = $("#maintenance");
|
||||
const maintenanceToggle = $("#maintenanceToggle");
|
||||
const maintenanceBody = $("#maintenanceBody");
|
||||
|
||||
function applyMaintenance(open) {
|
||||
maintenanceOpen = open;
|
||||
maintenance.classList.toggle("open", open);
|
||||
maintenanceToggle.setAttribute("aria-expanded", String(open));
|
||||
maintenanceBody.inert = !open;
|
||||
maintenanceBody.setAttribute("aria-hidden", String(!open));
|
||||
try { localStorage.setItem(MAINTENANCE_KEY, open ? "1" : "0"); } catch (_) {}
|
||||
}
|
||||
|
||||
maintenanceToggle.addEventListener("click", () => applyMaintenance(!maintenanceOpen));
|
||||
applyMaintenance(maintenanceOpen);
|
||||
|
||||
function esc(value) {
|
||||
return String(value ?? "")
|
||||
.replaceAll("&", "&")
|
||||
@@ -506,6 +618,7 @@ function debounce(fn, ms) {
|
||||
|
||||
function switchView(view) {
|
||||
state.view = view;
|
||||
if (view !== "library") closeFilters();
|
||||
document.querySelectorAll(".tab").forEach((t) => t.classList.toggle("active", t.dataset.view === view));
|
||||
$("#libraryView").classList.toggle("hidden", view !== "library");
|
||||
$("#recommendView").classList.toggle("hidden", view !== "recommend");
|
||||
|
||||
+10
-5
@@ -1,11 +1,16 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<defs>
|
||||
<linearGradient id="g" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0" stop-color="#f3b45c"/>
|
||||
<linearGradient id="f-bg" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0" stop-color="#ffd08a"/>
|
||||
<stop offset=".52" stop-color="#f3b45c"/>
|
||||
<stop offset="1" stop-color="#5eead4"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="f-play" x1="0" y1="0" x2="1" y2="0">
|
||||
<stop offset="0" stop-color="#ffffff"/>
|
||||
<stop offset="1" stop-color="#c8fff5"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="64" height="64" rx="16" fill="url(#g)"/>
|
||||
<text x="32" y="41" text-anchor="middle" font-family="Segoe UI, Arial, sans-serif"
|
||||
font-size="24" font-weight="800" fill="#090c12">SB</text>
|
||||
<rect width="64" height="64" rx="16" fill="url(#f-bg)"/>
|
||||
<rect x="16" y="16" width="32" height="34" rx="8" fill="#0a0d13"/>
|
||||
<path d="M29 24.5 L41 33 L29 41.5 Z" fill="url(#f-play)"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 464 B After Width: | Height: | Size: 672 B |
+60
-19
@@ -10,7 +10,7 @@
|
||||
<body>
|
||||
<header class="topbar">
|
||||
<div class="brand">
|
||||
<span class="logo">SB</span>
|
||||
<img class="logo" src="/static/logo.svg" alt="" width="34" height="34">
|
||||
<span>SteamBase</span>
|
||||
</div>
|
||||
<nav class="tabs">
|
||||
@@ -20,12 +20,24 @@
|
||||
<div class="stats" id="stats"></div>
|
||||
</header>
|
||||
|
||||
<div id="filtersBackdrop" class="filters-backdrop" hidden></div>
|
||||
<main>
|
||||
<section id="libraryView" class="layout">
|
||||
<aside class="filters">
|
||||
<aside class="filters" id="filtersPanel">
|
||||
<div class="filter-head">
|
||||
<h2>Фильтры</h2>
|
||||
<button id="resetFilters" class="link">сбросить</button>
|
||||
<div class="filter-actions">
|
||||
<button id="filtersPin" class="icon-btn pin active" type="button"
|
||||
title="Открепить фильтры" aria-pressed="true">
|
||||
<svg viewBox="0 0 24 24" width="15" height="15" fill="none"
|
||||
stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M8 3h8l-1 6 3 3v2H6v-2l3-3-1-6Z"/>
|
||||
<path d="M12 14v7"/>
|
||||
</svg>
|
||||
</button>
|
||||
<button id="filtersClose" class="icon-btn drawer-close" type="button" title="Закрыть фильтры">×</button>
|
||||
<button id="resetFilters" class="link">сбросить</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label class="field">
|
||||
@@ -55,31 +67,60 @@
|
||||
<label class="check"><input type="checkbox" id="fUnplayed"> не запускались</label>
|
||||
<label class="check"><input type="checkbox" id="fFavorite"> избранные</label>
|
||||
|
||||
<div class="details-progress">
|
||||
<div class="dp-head">Описания <span id="dpCount"></span></div>
|
||||
<div class="bar"><i id="dpBar"></i></div>
|
||||
<div class="dp-note" id="dpNote"></div>
|
||||
<button id="prefetch" class="link">догрузить / повторить</button>
|
||||
<div class="maintenance" id="maintenance">
|
||||
<button class="maintenance-toggle" id="maintenanceToggle" type="button"
|
||||
aria-expanded="false" aria-controls="maintenanceBody">
|
||||
<span class="maintenance-title">
|
||||
<svg viewBox="0 0 24 24" width="15" height="15" fill="none"
|
||||
stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M14.7 6.3a4 4 0 0 0-5.4 5.4L4 17v3h3l5.3-5.3a4 4 0 0 0 5.4-5.4l-2.2 2.2-2-2 2.2-2.2Z"/>
|
||||
</svg>
|
||||
Сервис и перевод
|
||||
</span>
|
||||
<svg class="chev" viewBox="0 0 24 24" width="16" height="16" fill="none"
|
||||
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M6 9l6 6 6-6"/>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<div class="dp-head translate-head">Перевод <span id="trCount"></span></div>
|
||||
<div class="bar"><i id="trBar"></i></div>
|
||||
<div class="dp-note" id="trNote"></div>
|
||||
<button id="translate" class="link">перевести кратко</button>
|
||||
<button id="translateAbout" class="link">полные описания</button>
|
||||
<div class="maintenance-body" id="maintenanceBody" inert aria-hidden="true">
|
||||
<div class="maintenance-inner details-progress">
|
||||
<div class="dp-head">Описания <span id="dpCount"></span></div>
|
||||
<div class="bar"><i id="dpBar"></i></div>
|
||||
<div class="dp-note" id="dpNote"></div>
|
||||
<button id="prefetch" class="link">догрузить / повторить</button>
|
||||
|
||||
<div class="refresh-block">
|
||||
<div class="dp-head">База игр</div>
|
||||
<div class="refresh-actions">
|
||||
<button id="refreshInc" class="ghost">инкрементально</button>
|
||||
<button id="refreshFull" class="ghost">полностью</button>
|
||||
<div class="dp-head translate-head">Перевод <span id="trCount"></span></div>
|
||||
<div class="bar"><i id="trBar"></i></div>
|
||||
<div class="dp-note" id="trNote"></div>
|
||||
<button id="translate" class="link">перевести кратко</button>
|
||||
<button id="translateAbout" class="link">полные описания</button>
|
||||
|
||||
<div class="refresh-block">
|
||||
<div class="dp-head">База игр</div>
|
||||
<div class="refresh-actions">
|
||||
<button id="refreshInc" class="ghost">инкрементально</button>
|
||||
<button id="refreshFull" class="ghost">полностью</button>
|
||||
</div>
|
||||
<div class="dp-note" id="jobStatus"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dp-note" id="jobStatus"></div>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<div class="content">
|
||||
<div class="toolbar">
|
||||
<button id="filtersToggle" class="icon-btn" type="button" title="Скрыть фильтры"
|
||||
aria-controls="filtersPanel" aria-expanded="true">
|
||||
<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"/>
|
||||
<circle cx="9" cy="7" r="2.2" fill="var(--bg)"/>
|
||||
<circle cx="15" cy="12" r="2.2" fill="var(--bg)"/>
|
||||
<circle cx="8" cy="17" r="2.2" fill="var(--bg)"/>
|
||||
</svg>
|
||||
</button>
|
||||
<input id="search" type="search" placeholder="Поиск по названию…" autocomplete="off">
|
||||
<select id="sort">
|
||||
<option value="name">по названию</option>
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-label="SteamBase">
|
||||
<defs>
|
||||
<linearGradient id="sb-bg" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0" stop-color="#ffd08a"/>
|
||||
<stop offset=".52" stop-color="#f3b45c"/>
|
||||
<stop offset="1" stop-color="#5eead4"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="sb-play" x1="0" y1="0" x2="1" y2="0">
|
||||
<stop offset="0" stop-color="#ffffff"/>
|
||||
<stop offset="1" stop-color="#c8fff5"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="64" height="64" rx="18" fill="url(#sb-bg)"/>
|
||||
<g transform="rotate(-9 32 33)">
|
||||
<rect x="17" y="16" width="33" height="29" rx="7" fill="#0a0d13" opacity=".18"/>
|
||||
</g>
|
||||
<g transform="rotate(-4 32 34)">
|
||||
<rect x="15" y="21" width="35" height="30" rx="7" fill="#0a0d13" opacity=".38"/>
|
||||
</g>
|
||||
<rect x="14" y="25" width="36" height="31" rx="8" fill="#0a0d13"/>
|
||||
<rect x="20" y="33" width="12" height="3" rx="1.5" fill="#5eead4" opacity=".9"/>
|
||||
<rect x="20" y="39" width="9" height="3" rx="1.5" fill="#f3b45c" opacity=".9"/>
|
||||
<path d="M36.5 33.5 L47 39.5 L36.5 45.5 Z" fill="url(#sb-play)"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
+121
-18
@@ -61,15 +61,11 @@ button { cursor: pointer; }
|
||||
}
|
||||
|
||||
.logo {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 9px;
|
||||
font-size: 12px;
|
||||
font-weight: 800;
|
||||
color: #0a0d13;
|
||||
background: linear-gradient(135deg, var(--accent), var(--accent-2));
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
flex: 0 0 34px;
|
||||
display: block;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 6px 18px rgba(243, 180, 92, .22);
|
||||
}
|
||||
|
||||
@@ -145,11 +141,79 @@ main { padding: 24px 28px 70px; }
|
||||
background: linear-gradient(180deg, rgba(255, 255, 255, .028), rgba(255, 255, 255, .008));
|
||||
}
|
||||
|
||||
.filter-head { display: flex; align-items: center; justify-content: space-between; }
|
||||
.layout.filters-collapsed { grid-template-columns: minmax(0, 1fr); }
|
||||
.layout.filters-collapsed .filters { display: none; }
|
||||
|
||||
.layout.filters-unpinned { grid-template-columns: minmax(0, 1fr); }
|
||||
.layout.filters-unpinned .filters {
|
||||
position: fixed;
|
||||
top: 86px;
|
||||
left: 18px;
|
||||
width: 268px;
|
||||
max-height: calc(100vh - 110px);
|
||||
z-index: 40;
|
||||
background: #0f1520;
|
||||
box-shadow: var(--shadow);
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transform: translateX(calc(-100% - 30px));
|
||||
transition: transform .22s ease, opacity .22s ease;
|
||||
will-change: transform;
|
||||
}
|
||||
.layout.filters-unpinned .filters.open {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
.filter-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
|
||||
.filter-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
|
||||
.filter-actions { display: flex; align-items: center; gap: 8px; }
|
||||
.link { background: none; border: 0; padding: 0; color: var(--accent); font-size: 12px; }
|
||||
.link:hover { text-decoration: underline; }
|
||||
|
||||
.icon-btn {
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
flex: 0 0 42px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border-radius: 11px;
|
||||
border: 1px solid var(--border);
|
||||
background: rgba(255, 255, 255, .03);
|
||||
color: var(--muted);
|
||||
transition: color .15s, border-color .15s, background .15s;
|
||||
}
|
||||
.icon-btn:hover {
|
||||
color: var(--text);
|
||||
border-color: var(--border-strong);
|
||||
background: rgba(255, 255, 255, .06);
|
||||
}
|
||||
.icon-btn.active {
|
||||
color: var(--accent);
|
||||
border-color: rgba(243, 180, 92, .45);
|
||||
background: rgba(243, 180, 92, .09);
|
||||
}
|
||||
.filter-actions .icon-btn {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
flex-basis: 28px;
|
||||
border-radius: 8px;
|
||||
font-size: 17px;
|
||||
line-height: 1;
|
||||
}
|
||||
.drawer-close { display: none; }
|
||||
.layout.filters-unpinned .drawer-close { display: grid; }
|
||||
|
||||
.filters-backdrop {
|
||||
position: fixed;
|
||||
inset: 62px 0 0 0;
|
||||
z-index: 35;
|
||||
background: rgba(4, 6, 10, .55);
|
||||
backdrop-filter: blur(2px);
|
||||
}
|
||||
body.drawer-open { overflow: hidden; }
|
||||
|
||||
.field { display: flex; flex-direction: column; gap: 6px; }
|
||||
.field span { font-size: 12px; color: var(--muted); }
|
||||
|
||||
@@ -180,10 +244,44 @@ textarea { resize: vertical; min-height: 54px; }
|
||||
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
|
||||
.check:hover { color: var(--text); }
|
||||
|
||||
.details-progress {
|
||||
margin-top: 6px;
|
||||
padding-top: 14px;
|
||||
.maintenance {
|
||||
margin-top: 10px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.maintenance-toggle {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
padding: 6px 2px;
|
||||
border: 0;
|
||||
background: none;
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
text-align: left;
|
||||
}
|
||||
.maintenance-toggle:hover { color: var(--text); }
|
||||
.maintenance-title { display: flex; align-items: center; gap: 8px; }
|
||||
.maintenance-title svg { color: var(--accent); }
|
||||
.maintenance-toggle .chev { transition: transform .25s ease; }
|
||||
.maintenance.open .maintenance-toggle .chev { transform: rotate(180deg); }
|
||||
|
||||
.maintenance-body {
|
||||
display: grid;
|
||||
grid-template-rows: 0fr;
|
||||
transition: grid-template-rows .28s ease;
|
||||
}
|
||||
.maintenance-body > .maintenance-inner {
|
||||
overflow: hidden;
|
||||
min-height: 0;
|
||||
}
|
||||
.maintenance.open .maintenance-body { grid-template-rows: 1fr; }
|
||||
.maintenance-inner > :first-child { margin-top: 12px; }
|
||||
|
||||
.details-progress {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
@@ -600,11 +698,16 @@ textarea { resize: vertical; min-height: 54px; }
|
||||
::-webkit-scrollbar-track { background: transparent; }
|
||||
|
||||
@media (max-width: 980px) {
|
||||
.layout { grid-template-columns: 1fr; }
|
||||
.filters { position: static; flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
|
||||
.filter-head { width: 100%; }
|
||||
.field { flex: 1 1 160px; }
|
||||
.details-progress { flex: 1 1 100%; }
|
||||
.layout { grid-template-columns: minmax(0, 1fr); }
|
||||
.filters-backdrop { inset: 0; }
|
||||
.layout.filters-unpinned .filters {
|
||||
top: 76px;
|
||||
left: 12px;
|
||||
width: min(300px, calc(100vw - 24px));
|
||||
max-height: calc(100vh - 96px);
|
||||
flex-direction: column;
|
||||
}
|
||||
.pin { display: none; }
|
||||
.modal-grid { grid-template-columns: 1fr; }
|
||||
.modal-cover { max-height: 260px; }
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user