feat: add friends sidebar layout
Move the friend list and search into a sticky left sidebar and keep library comparison in the right pane.
This commit is contained in:
1 parent
15f4951623
commit
f73ed63b2b
3 files changed
+76
-32
No files matched your search
+9
-3
@@ -1537,7 +1537,9 @@ function renderFriendCompare(data) {
|
||||
<div class="compare-col"><h3>только у друга (${only.length})</h3>${friendGameList(only, false, friendsState.limit)}</div>
|
||||
</div>`;
|
||||
$("#friendClose").addEventListener("click", () => {
|
||||
box.classList.add("hidden");
|
||||
box.innerHTML = '<div class="empty">выберите друга, чтобы сравнить библиотеки</div>';
|
||||
friendsState.compare = null;
|
||||
document.querySelectorAll(".friend-card.active").forEach((card) => card.classList.remove("active"));
|
||||
setFriendUrl(null);
|
||||
});
|
||||
box.querySelectorAll("button[data-appid]").forEach((button) => {
|
||||
@@ -1619,11 +1621,15 @@ async function openFriendCompare(steamid) {
|
||||
if (cached) {
|
||||
friendsState.compare = cached;
|
||||
renderFriendCompare(cached);
|
||||
box.scrollIntoView({ behavior: "smooth", block: "start" });
|
||||
if (window.matchMedia("(max-width: 980px)").matches) {
|
||||
box.scrollIntoView({ behavior: "smooth", block: "start" });
|
||||
}
|
||||
return;
|
||||
}
|
||||
box.innerHTML = '<div class="muted">загрузка…</div>';
|
||||
box.scrollIntoView({ behavior: "smooth", block: "start" });
|
||||
if (window.matchMedia("(max-width: 980px)").matches) {
|
||||
box.scrollIntoView({ behavior: "smooth", block: "start" });
|
||||
}
|
||||
try {
|
||||
const data = await api(`/api/steam/friends/${encodeURIComponent(steamid)}`);
|
||||
friendsState.cache.set(steamid, data);
|
||||
|
||||
+26
-20
@@ -411,27 +411,33 @@ try {
|
||||
<h1>Друзья</h1>
|
||||
<div class="muted" id="friendsSummary"></div>
|
||||
</div>
|
||||
<div class="friends-toolbar">
|
||||
<input id="friendsSearch" type="search" placeholder="Поиск друга…" autocomplete="off"
|
||||
aria-label="Поиск друга">
|
||||
<select id="friendsStatus" aria-label="Статус друзей">
|
||||
<option value="">все</option>
|
||||
<option value="online">онлайн</option>
|
||||
<option value="offline">офлайн</option>
|
||||
</select>
|
||||
<button id="friendsRefresh" class="ghost" type="button">обновить</button>
|
||||
<span class="count" id="friendsCount"></span>
|
||||
<div class="friends-layout">
|
||||
<aside class="friends-sidebar">
|
||||
<div class="friends-toolbar">
|
||||
<input id="friendsSearch" type="search" placeholder="Поиск друга…" autocomplete="off"
|
||||
aria-label="Поиск друга">
|
||||
<select id="friendsStatus" aria-label="Статус друзей">
|
||||
<option value="">все</option>
|
||||
<option value="online">онлайн</option>
|
||||
<option value="offline">офлайн</option>
|
||||
</select>
|
||||
<button id="friendsRefresh" class="ghost" type="button">обновить</button>
|
||||
<span class="count" id="friendsCount"></span>
|
||||
</div>
|
||||
<details class="friends-manual" id="friendsManual">
|
||||
<summary>сравнить по SteamID64</summary>
|
||||
<div class="friends-manual-row">
|
||||
<input id="friendSteamId" type="text" inputmode="numeric" autocomplete="off"
|
||||
placeholder="7656119..." aria-label="SteamID64 друга">
|
||||
<button id="friendCompareBtn" class="ghost" type="button">сравнить</button>
|
||||
</div>
|
||||
</details>
|
||||
<div id="friendsList" class="friends-list"></div>
|
||||
</aside>
|
||||
<section id="friendCompare" class="friend-compare" aria-live="polite">
|
||||
<div class="empty" id="friendPlaceholder">выберите друга, чтобы сравнить библиотеки</div>
|
||||
</section>
|
||||
</div>
|
||||
<details class="friends-manual" id="friendsManual">
|
||||
<summary>сравнить по SteamID64</summary>
|
||||
<div class="friends-manual-row">
|
||||
<input id="friendSteamId" type="text" inputmode="numeric" autocomplete="off"
|
||||
placeholder="7656119..." aria-label="SteamID64 друга">
|
||||
<button id="friendCompareBtn" class="ghost" type="button">сравнить</button>
|
||||
</div>
|
||||
</details>
|
||||
<div id="friendCompare" class="friend-compare hidden" aria-live="polite"></div>
|
||||
<div id="friendsList" class="friends-list"></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
+41
-9
@@ -947,6 +947,35 @@ html[data-theme="light"] .game-table tbody tr:hover { background: rgba(23, 32, 5
|
||||
.compare-jaccard { margin-bottom: 4px; font-size: 13px; color: var(--text); }
|
||||
|
||||
.friends-page { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
|
||||
.friends-layout {
|
||||
display: grid;
|
||||
grid-template-columns: 300px minmax(0, 1fr);
|
||||
gap: 18px;
|
||||
align-items: start;
|
||||
min-width: 0;
|
||||
}
|
||||
.friends-sidebar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
position: sticky;
|
||||
top: 84px;
|
||||
min-width: 0;
|
||||
}
|
||||
.friends-sidebar .friends-toolbar {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 6px;
|
||||
}
|
||||
.friends-sidebar .friends-toolbar input,
|
||||
.friends-sidebar .friends-toolbar select,
|
||||
.friends-sidebar .friends-toolbar .ghost {
|
||||
flex: 0 0 auto;
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
min-width: 0;
|
||||
}
|
||||
.friends-sidebar .friends-toolbar .count { margin-left: 0; }
|
||||
.friends-toolbar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
@@ -970,10 +999,13 @@ html[data-theme="light"] .game-table tbody tr:hover { background: rgba(23, 32, 5
|
||||
.friends-manual-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 0 10px; }
|
||||
.friends-manual-row input { flex: 1 1 220px; max-width: 320px; }
|
||||
.friends-list {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
|
||||
gap: 10px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
max-height: calc(100vh - 330px);
|
||||
overflow-y: auto;
|
||||
padding-right: 4px;
|
||||
}
|
||||
.friend-card {
|
||||
display: flex;
|
||||
@@ -1413,6 +1445,9 @@ html[data-theme="light"] ::-webkit-scrollbar-thumb { background: #c9c0ad; }
|
||||
.pin { display: none; }
|
||||
.modal-grid { grid-template-columns: 1fr; }
|
||||
.modal-cover { max-height: 260px; }
|
||||
.friends-layout { grid-template-columns: 1fr; }
|
||||
.friends-sidebar { position: static; }
|
||||
.friends-list { max-height: 360px; }
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
@@ -1420,12 +1455,9 @@ html[data-theme="light"] ::-webkit-scrollbar-thumb { background: #c9c0ad; }
|
||||
.theme-toggle { position: absolute; top: 12px; right: 16px; }
|
||||
.tabs { gap: 2px; padding: 3px; max-width: 100%; overflow-x: auto; }
|
||||
.tab { padding: 6px 9px; font-size: 12px; white-space: nowrap; }
|
||||
.friends-list { grid-template-columns: 1fr; }
|
||||
.friends-toolbar { display: flex; }
|
||||
.friends-toolbar input { flex: 1 1 100%; max-width: none; }
|
||||
.friends-toolbar select { flex: 1 1 auto; min-width: 0; }
|
||||
.friends-toolbar .ghost { flex: 0 0 auto; }
|
||||
.friends-toolbar .count { flex: 1 1 100%; margin-left: 0; }
|
||||
.friends-layout { grid-template-columns: 1fr; }
|
||||
.friends-sidebar { position: static; }
|
||||
.friends-list { max-height: 360px; }
|
||||
.friends-manual-row input { max-width: none; }
|
||||
.stats { width: 100%; justify-content: flex-start; }
|
||||
main { padding: 18px 16px 60px; }
|
||||
|
||||
Reference in new issue
Block a user