Связи: фильтры тем же переключателем, что в чатах

Ряд чипов, который надо было листать вбок, заменён общим переключателем (как «Все /
Близкие / Друзья / Контакты / Новые» в чатах): «Все / Близкие / Друзья / Контакты / Ещё ▾».
В «Ещё» – реже нужное: «Добавили вас», «Сияющие», «С заметкой» с числами и «Друзья
друзей» (вкл/выкл). Выбранный из меню фильтр показывается на месте «Ещё» («Сияющие ▾»),
включённые друзья друзей – точкой на «Ещё». Пустые группы скрываются, стрелки ←/→
переключают фильтр. Помещается и на 360 px.

Неиспользуемые теперь стили чипов (число в чипе, чип-переключатель, «вылет» ряда за поля)
удалены; значок «sparkle» для сияющих.
This commit is contained in:
q
2026-10-13 08:50:04 +03:00
parent 42797b1a43
commit 6294646922
6 changed files with 152 additions and 88 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
client.version=1.19.24
client.version=1.19.25
server.version=1.15.0
+1 -1
View File
@@ -39,7 +39,7 @@
}());
</script>
<script>
window.__SHINE_BUILD_HASH__ = '20261013130000';
window.__SHINE_BUILD_HASH__ = '20261013133000';
window.__SHINE_CLIENT_VERSION__ = '1.2.10';
</script>
<script>
+1
View File
@@ -47,6 +47,7 @@ const paths = {
settings: '<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1.1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1Z"/>',
'user-plus': '<circle cx="10" cy="8" r="3.5"/><path d="M3.5 20a6.5 6.5 0 0 1 13 0M19 8v6M16 11h6"/>',
refresh: '<path d="M20 12a8 8 0 1 1-2.3-5.6"/><path d="M20 4v4.4h-4.4"/>',
sparkle: '<path d="M11 4c.6 4.4 2.6 6.4 7 7-4.4.6-6.4 2.6-7 7-.6-4.4-2.6-6.4-7-7 4.4-.6 6.4-2.6 7-7Z"/><path d="M19 2.5v3M17.5 4h3"/>',
eye: '<path d="M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12Z"/><circle cx="12" cy="12" r="3"/>',
eyeOff: '<path d="M10.2 5.7A9.6 9.6 0 0 1 12 5.5c6 0 9.5 6.5 9.5 6.5a16.4 16.4 0 0 1-2.6 3.4M6.4 7A16.2 16.2 0 0 0 2.5 12S6 18.5 12 18.5a9 9 0 0 0 4.9-1.4"/><path d="M9.9 9.9a3 3 0 0 0 4.2 4.2M3.5 3.5l17 17"/>',
repost: '<path d="M17 2.5 20.5 6 17 9.5"/><path d="M3.5 11.5V9a3 3 0 0 1 3-3h14"/><path d="M7 21.5 3.5 18 7 14.5"/><path d="M20.5 12.5V15a3 3 0 0 1-3 3h-14"/>',
+111 -56
View File
@@ -243,7 +243,7 @@ function directionLabel(node) {
// Переживает уход с экрана: возврат по «Связям» из профиля показывает ту же карту.
const persisted = { centerLogin: '', expanded: [], filter: 'all', friendsOfFriends: false, view: null, listScroll: 0 };
// Фильтр – один выбранный чип. Тип связи и «добавили вас» – только про прямые связи центра,
// Фильтр – один выбранный. Тип связи и «добавили вас» – только про прямые связи центра,
// «сияющие» и «с заметкой» – про всех на карте.
const FILTERS = [
{ id: 'all', label: 'Все', pred: null },
@@ -393,7 +393,7 @@ export function render({ navigate, route, chrome } = {}) {
return (node) => (filter.direct ? Number(node.tier) <= 1 : true) && filter.pred(node);
}
// Поля, занятые панелями поверх карты: чипы сверху, нижнее меню и карточка снизу.
// Поля, занятые панелями поверх карты: фильтры сверху, нижнее меню и карточка снизу.
function toolbarOverlap() {
const toolbar = document.getElementById('toolbar-slot');
if (!toolbar) return 0;
@@ -404,7 +404,7 @@ export function render({ navigate, route, chrome } = {}) {
function insets() {
const s = stage.getBoundingClientRect();
const f = chipsBar.getBoundingClientRect();
const f = filterBar.getBoundingClientRect();
const top = f.height ? f.bottom - s.top + 8 : 8;
const bottom = toolbarOverlap() + (card.hidden ? 56 : card.offsetHeight + 12) + 8;
return { top, bottom };
@@ -417,7 +417,7 @@ export function render({ navigate, route, chrome } = {}) {
zoomBar.style.bottom = `${overlap + 12 + (card.hidden ? 0 : card.offsetHeight + 10)}px`;
list.style.paddingBottom = `${overlap + 76}px`;
const stageTop = stage.getBoundingClientRect().top;
const chipsRect = chipsBar.getBoundingClientRect();
const chipsRect = filterBar.getBoundingClientRect();
list.style.paddingTop = `${Math.max(0, chipsRect.bottom - stageTop + 4)}px`;
searchPanel.style.top = `${Math.max(0, chipsRect.top - stageTop)}px`;
searchPanel.style.bottom = `${overlap}px`;
@@ -437,12 +437,12 @@ export function render({ navigate, route, chrome } = {}) {
if (disposed) return;
map = composeMap(centerLogin, graphs, expanded, notes);
if (!map) return;
// Чипы должны быть на месте до вписывания карты: от них зависит свободная часть экрана.
// Фильтры должны быть на месте до вписывания карты: от них зависит свободная часть экрана.
screen.classList.toggle('is-blank', map.nodes.length <= 1);
engine.setGraph(map, { manual: getManualLayout(normKey(centerLogin)), mode: layoutMode, relayout, fit });
engine.setFilter(filterPredicate());
renderA11y();
syncChips();
syncFilters();
syncHeader();
syncStateMessage();
if (selectedId && !map.byId.has(selectedId)) selectNode('');
@@ -624,7 +624,7 @@ export function render({ navigate, route, chrome } = {}) {
const friends = (map?.nodes || []).filter((node) => node.tier === 1 && node.id !== map.focusId && FRIEND_TYPES.has(node.relationType));
if (!friends.length) {
friendsOfFriends = false;
syncChips();
syncFilters();
showToast(isSelfCenter() ? 'Пока нет друзей – раскрывать нечего' : 'У этого человека пока нет друзей на карте', { kind: 'info', timeoutMs: 2200 });
return;
}
@@ -640,7 +640,7 @@ export function render({ navigate, route, chrome } = {}) {
function toggleFriendsOfFriends() {
friendsOfFriends = !friendsOfFriends;
syncChips();
syncFilters();
if (friendsOfFriends) {
void expandFriends();
} else {
@@ -980,36 +980,88 @@ export function render({ navigate, route, chrome } = {}) {
list.scrollTop = 0;
}
// --- фильтры: один выбранный чип, у каждого – сколько людей ---
const chipsBar = document.createElement('div');
chipsBar.className = 'net-chips';
chipsBar.addEventListener('pointerdown', (event) => event.stopPropagation());
const chipRow = document.createElement('div');
chipRow.className = 'chip-row chip-row--bleed net-chips__row';
chipRow.setAttribute('role', 'radiogroup');
chipRow.setAttribute('aria-label', 'Кого показывать');
chipsBar.append(chipRow);
const chips = new Map();
for (const filter of FILTERS) {
const chip = document.createElement('button');
chip.type = 'button';
chip.className = 'chip';
chip.setAttribute('role', 'radio');
const label = document.createElement('span');
label.textContent = filter.label;
const count = document.createElement('span');
count.className = 'chip__count';
chip.append(label, count);
chip.addEventListener('click', () => setFilter(filter.id));
chips.set(filter.id, { chip, count });
chipRow.append(chip);
// --- фильтры: «Все / Близкие / Друзья / Контакты» – тем же переключателем, что в чатах;
// реже нужное («Добавили вас», «Сияющие», «С заметкой», «Друзья друзей») – в «Ещё».
const PRIMARY_FILTERS = ['all', 'close', 'friends', 'contacts'];
const EXTRA_FILTERS = [
{ id: 'incoming', short: 'Добавили', icon: 'user-plus' },
{ id: 'shining', short: 'Сияющие', icon: 'sparkle' },
{ id: 'notes', short: 'С заметкой', icon: 'edit' },
];
const filterBar = document.createElement('div');
filterBar.className = 'net-filters';
filterBar.addEventListener('pointerdown', (event) => event.stopPropagation());
const filterTabs = document.createElement('div');
filterTabs.className = 'tabs tabs--auto tabs--dense net-filters__tabs';
filterTabs.setAttribute('role', 'radiogroup');
filterTabs.setAttribute('aria-label', 'Кого показывать');
filterBar.append(filterTabs);
const filterButtons = new Map();
for (const id of PRIMARY_FILTERS) {
const button = document.createElement('button');
button.type = 'button';
button.className = 'tab-btn';
button.dataset.filter = id;
button.setAttribute('role', 'radio');
button.textContent = FILTER_BY_ID.get(id).label;
button.addEventListener('click', () => setFilter(id));
filterButtons.set(id, button);
filterTabs.append(button);
}
const fofChip = document.createElement('button');
fofChip.type = 'button';
fofChip.className = 'chip chip--toggle net-chips__fof';
fofChip.innerHTML = `${iconHtml('network')}<span>Друзья друзей</span>`;
fofChip.addEventListener('click', toggleFriendsOfFriends);
chipRow.append(fofChip);
const moreFilter = document.createElement('button');
moreFilter.type = 'button';
moreFilter.className = 'tab-btn net-filters__more';
filterTabs.append(moreFilter);
filterTabs.addEventListener('keydown', (event) => {
if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') return;
const visible = PRIMARY_FILTERS.filter((id) => !filterButtons.get(id).hidden);
const index = Math.max(0, visible.indexOf(filterId));
const next = visible[(index + (event.key === 'ArrowRight' ? 1 : -1) + visible.length) % visible.length];
setFilter(next);
filterButtons.get(next)?.focus();
event.preventDefault();
});
function filterCounts() {
const direct = (map?.nodes || []).filter((node) => node.tier === 1 && node.id !== map.focusId);
const everyone = (map?.nodes || []).filter((node) => node.id !== map?.focusId);
const counts = new Map();
for (const filter of FILTERS) {
const pool = filter.direct ? direct : everyone;
counts.set(filter.id, filter.pred ? pool.filter(filter.pred).length : direct.length);
}
return counts;
}
const moreMenu = createDropdownMenu({
anchorEl: moreFilter,
minWidth: 236,
placement: 'bottom-end',
items: () => {
const counts = filterCounts();
const items = EXTRA_FILTERS
.filter(({ id }) => !(FILTER_BY_ID.get(id).selfOnly && !isSelfCenter()))
.map(({ id, icon }) => {
const selected = filterId === id;
const n = counts.get(id) || 0;
return {
label: `${FILTER_BY_ID.get(id).label} · ${n}`,
selected,
disabled: !n && !selected,
iconHtml: iconHtml(selected ? 'check' : icon),
action: () => setFilter(selected ? 'all' : id),
};
});
items.push({ divider: true }, {
label: 'Друзья друзей',
hint: friendsOfFriends ? 'Показаны – нажмите, чтобы скрыть' : 'Кто дружит с вашими друзьями',
selected: friendsOfFriends,
iconHtml: iconHtml(friendsOfFriends ? 'check' : 'network'),
action: toggleFriendsOfFriends,
});
return items;
},
});
function setFilter(id) {
filterId = FILTER_BY_ID.has(id) ? id : 'all';
@@ -1017,7 +1069,7 @@ export function render({ navigate, route, chrome } = {}) {
engine.fit();
const selected = selectedId ? map?.byId.get(selectedId) : null;
if (selected && selectedId !== map.focusId && filterPredicate() && !filterPredicate()(selected)) selectNode('');
syncChips();
syncFilters();
syncStateMessage();
if (viewMode === 'list') {
renderList();
@@ -1026,22 +1078,24 @@ export function render({ navigate, route, chrome } = {}) {
persist();
}
function syncChips() {
const direct = (map?.nodes || []).filter((node) => node.tier === 1 && node.id !== map.focusId);
const everyone = (map?.nodes || []).filter((node) => node.id !== map?.focusId);
for (const filter of FILTERS) {
const { chip, count } = chips.get(filter.id);
const pool = filter.direct ? direct : everyone;
const n = filter.pred ? pool.filter(filter.pred).length : direct.length;
const selected = filter.id === filterId;
// Пустые фильтры не показываем (кроме выбранного), «добавили вас» – только на своей карте.
chip.hidden = (filter.selfOnly && !isSelfCenter()) || (!selected && filter.id !== 'all' && n === 0);
count.textContent = map ? String(n) : '';
chip.setAttribute('aria-checked', selected ? 'true' : 'false');
chip.classList.toggle('is-active', selected);
function syncFilters() {
const counts = filterCounts();
for (const id of PRIMARY_FILTERS) {
const button = filterButtons.get(id);
const selected = id === filterId;
// Пустую группу не показываем (кроме выбранной и «Все»).
button.hidden = !selected && id !== 'all' && Boolean(map) && !counts.get(id);
button.setAttribute('aria-checked', selected ? 'true' : 'false');
}
fofChip.setAttribute('aria-pressed', friendsOfFriends ? 'true' : 'false');
fofChip.classList.toggle('is-active', friendsOfFriends);
const extra = EXTRA_FILTERS.find(({ id }) => id === filterId);
moreFilter.classList.toggle('active', Boolean(extra));
// Точка на «Ещё» – включено что-то из меню (друзья друзей), а на самой кнопке этого не видно.
moreFilter.classList.toggle('has-dot', !extra && friendsOfFriends);
moreFilter.innerHTML = `<span class="net-filters__more-label"></span>${iconHtml('chevron-down')}`;
moreFilter.querySelector('.net-filters__more-label').textContent = extra ? extra.short : 'Ещё';
moreFilter.setAttribute('aria-label', extra
? `${FILTER_BY_ID.get(extra.id).label}. Другие фильтры`
: `Другие фильтры${friendsOfFriends ? ', друзья друзей показаны' : ''}`);
}
// --- масштаб ---
@@ -1415,7 +1469,7 @@ export function render({ navigate, route, chrome } = {}) {
document.addEventListener('keydown', onKeydown);
const overlayObserver = typeof ResizeObserver === 'function' ? new ResizeObserver(() => placeOverlays()) : null;
overlayObserver?.observe(stage);
overlayObserver?.observe(chipsBar);
overlayObserver?.observe(filterBar);
screen.cleanup = () => {
if (disposed) return;
@@ -1427,6 +1481,7 @@ export function render({ navigate, route, chrome } = {}) {
engine.destroy();
overlayObserver?.disconnect();
rowMenu.destroy();
moreMenu.destroy();
window.cancelAnimationFrame(listFrame);
window.clearTimeout(remoteTimer);
window.removeEventListener(PEOPLE_NOTES_EVENT, onNotesChanged);
@@ -1443,9 +1498,9 @@ export function render({ navigate, route, chrome } = {}) {
syncModePill();
board.hidden = viewMode !== 'map';
zoomBar.hidden = viewMode !== 'map';
syncChips();
syncFilters();
syncHeader({ force: true });
stage.append(board, list, chipsBar, overlay, busyPill, zoomBar, modePill, card, searchPanel, rowMenuAnchor, a11yList);
stage.append(board, list, filterBar, overlay, busyPill, zoomBar, modePill, card, searchPanel, rowMenuAnchor, a11yList);
screen.append(stage);
persist();
-20
View File
@@ -52,27 +52,7 @@
.chip:focus-visible,
.fg-filter-chip:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.chip-row--bleed {
margin-inline: calc(-1 * var(--page-gutter));
padding-inline: var(--page-gutter);
scroll-padding-inline: var(--page-gutter);
-webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
}
/* Число людей/элементов в чипе («Друзья 58»): тише подписи. */
.chip__count {
color: var(--text-secondary);
font-weight: var(--weight-medium);
font-variant-numeric: tabular-nums;
}
.chip__count:empty { display: none; }
.chip.is-active .chip__count { color: var(--text-primary); }
.chip[hidden] { display: none; }
/* Чип-переключатель (вкл/выкл, а не выбор одного из ряда): со значком и пунктирной рамкой. */
.chip--toggle { border-style: dashed; }
.chip--toggle[aria-pressed='true'] { border-style: solid; color: var(--accent); }
.chip--toggle svg { flex: 0 0 auto; }
/* Значок в чипе – по размеру текста, что бы ни задала страница. */
.chip svg { flex: 0 0 auto; width: 16px; height: 16px; }
+38 -10
View File
@@ -35,30 +35,58 @@
display: none;
}
/* Чипы фильтров – под шапкой, поверх карты и над списком. */
.net-chips {
/* Фильтры – тот же переключатель, что в чатах, под шапкой, поверх карты и над списком. */
.net-filters {
position: absolute;
top: var(--topbar-height, 64px);
left: 0;
right: 0;
z-index: 11;
padding: calc(var(--app-primary-tabs-top-gap, 14px) - 4px) var(--page-gutter) 0;
padding: var(--app-primary-tabs-top-gap, 14px) var(--page-gutter) 0;
pointer-events: none;
}
.net-chips__row {
.net-filters__tabs {
pointer-events: auto;
}
/* В списке строки уезжают под чипы – подложка до самой шапки. */
.network-screen[data-view='list'] .net-chips {
padding-bottom: var(--space-1);
/* В списке строки уезжают под фильтры – подложка до самой шапки. */
.network-screen[data-view='list'] .net-filters {
padding-bottom: var(--space-2);
background: var(--background);
pointer-events: auto;
}
.net-chips__fof {
margin-left: var(--space-1);
/* «Ещё ▾»: выбранный фильтр из меню показывается здесь же; точка – включены друзья друзей. */
.net-filters__more {
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 2px;
}
.net-filters__more-label {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
}
.net-filters__more svg {
flex: 0 0 auto;
width: 14px;
height: 14px;
}
.net-filters__more.has-dot::after {
content: '';
position: absolute;
top: 6px;
right: 6px;
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--accent);
}
/* Список: свой скролл (страница «Связей» не прокручивается), отступы сверху и снизу
@@ -101,7 +129,7 @@
top: 56%;
}
.network-screen.is-blank .net-chips,
.network-screen.is-blank .net-filters,
.network-screen.is-blank .net-zoom,
.network-screen.is-blank .net-mode-pill {
display: none;