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
+55
-11
No files matched your search
+7
-1
@@ -1537,7 +1537,9 @@ function renderFriendCompare(data) {
|
|||||||
<div class="compare-col"><h3>только у друга (${only.length})</h3>${friendGameList(only, false, friendsState.limit)}</div>
|
<div class="compare-col"><h3>только у друга (${only.length})</h3>${friendGameList(only, false, friendsState.limit)}</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
$("#friendClose").addEventListener("click", () => {
|
$("#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);
|
setFriendUrl(null);
|
||||||
});
|
});
|
||||||
box.querySelectorAll("button[data-appid]").forEach((button) => {
|
box.querySelectorAll("button[data-appid]").forEach((button) => {
|
||||||
@@ -1619,11 +1621,15 @@ async function openFriendCompare(steamid) {
|
|||||||
if (cached) {
|
if (cached) {
|
||||||
friendsState.compare = cached;
|
friendsState.compare = cached;
|
||||||
renderFriendCompare(cached);
|
renderFriendCompare(cached);
|
||||||
|
if (window.matchMedia("(max-width: 980px)").matches) {
|
||||||
box.scrollIntoView({ behavior: "smooth", block: "start" });
|
box.scrollIntoView({ behavior: "smooth", block: "start" });
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
box.innerHTML = '<div class="muted">загрузка…</div>';
|
box.innerHTML = '<div class="muted">загрузка…</div>';
|
||||||
|
if (window.matchMedia("(max-width: 980px)").matches) {
|
||||||
box.scrollIntoView({ behavior: "smooth", block: "start" });
|
box.scrollIntoView({ behavior: "smooth", block: "start" });
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const data = await api(`/api/steam/friends/${encodeURIComponent(steamid)}`);
|
const data = await api(`/api/steam/friends/${encodeURIComponent(steamid)}`);
|
||||||
friendsState.cache.set(steamid, data);
|
friendsState.cache.set(steamid, data);
|
||||||
|
|||||||
@@ -411,6 +411,8 @@ try {
|
|||||||
<h1>Друзья</h1>
|
<h1>Друзья</h1>
|
||||||
<div class="muted" id="friendsSummary"></div>
|
<div class="muted" id="friendsSummary"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="friends-layout">
|
||||||
|
<aside class="friends-sidebar">
|
||||||
<div class="friends-toolbar">
|
<div class="friends-toolbar">
|
||||||
<input id="friendsSearch" type="search" placeholder="Поиск друга…" autocomplete="off"
|
<input id="friendsSearch" type="search" placeholder="Поиск друга…" autocomplete="off"
|
||||||
aria-label="Поиск друга">
|
aria-label="Поиск друга">
|
||||||
@@ -430,8 +432,12 @@ try {
|
|||||||
<button id="friendCompareBtn" class="ghost" type="button">сравнить</button>
|
<button id="friendCompareBtn" class="ghost" type="button">сравнить</button>
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
<div id="friendCompare" class="friend-compare hidden" aria-live="polite"></div>
|
|
||||||
<div id="friendsList" class="friends-list"></div>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</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); }
|
.compare-jaccard { margin-bottom: 4px; font-size: 13px; color: var(--text); }
|
||||||
|
|
||||||
.friends-page { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
|
.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 {
|
.friends-toolbar {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
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 { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 0 10px; }
|
||||||
.friends-manual-row input { flex: 1 1 220px; max-width: 320px; }
|
.friends-manual-row input { flex: 1 1 220px; max-width: 320px; }
|
||||||
.friends-list {
|
.friends-list {
|
||||||
display: grid;
|
display: flex;
|
||||||
grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
|
flex-direction: column;
|
||||||
gap: 10px;
|
gap: 8px;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
max-height: calc(100vh - 330px);
|
||||||
|
overflow-y: auto;
|
||||||
|
padding-right: 4px;
|
||||||
}
|
}
|
||||||
.friend-card {
|
.friend-card {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -1413,6 +1445,9 @@ html[data-theme="light"] ::-webkit-scrollbar-thumb { background: #c9c0ad; }
|
|||||||
.pin { display: none; }
|
.pin { display: none; }
|
||||||
.modal-grid { grid-template-columns: 1fr; }
|
.modal-grid { grid-template-columns: 1fr; }
|
||||||
.modal-cover { max-height: 260px; }
|
.modal-cover { max-height: 260px; }
|
||||||
|
.friends-layout { grid-template-columns: 1fr; }
|
||||||
|
.friends-sidebar { position: static; }
|
||||||
|
.friends-list { max-height: 360px; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 720px) {
|
@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; }
|
.theme-toggle { position: absolute; top: 12px; right: 16px; }
|
||||||
.tabs { gap: 2px; padding: 3px; max-width: 100%; overflow-x: auto; }
|
.tabs { gap: 2px; padding: 3px; max-width: 100%; overflow-x: auto; }
|
||||||
.tab { padding: 6px 9px; font-size: 12px; white-space: nowrap; }
|
.tab { padding: 6px 9px; font-size: 12px; white-space: nowrap; }
|
||||||
.friends-list { grid-template-columns: 1fr; }
|
.friends-layout { grid-template-columns: 1fr; }
|
||||||
.friends-toolbar { display: flex; }
|
.friends-sidebar { position: static; }
|
||||||
.friends-toolbar input { flex: 1 1 100%; max-width: none; }
|
.friends-list { max-height: 360px; }
|
||||||
.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-manual-row input { max-width: none; }
|
.friends-manual-row input { max-width: none; }
|
||||||
.stats { width: 100%; justify-content: flex-start; }
|
.stats { width: 100%; justify-content: flex-start; }
|
||||||
main { padding: 18px 16px 60px; }
|
main { padding: 18px 16px 60px; }
|
||||||
|
|||||||
Reference in new issue
Block a user