Исправить мелкие баги дизайна UI

This commit is contained in:
AidarKC
2026-11-09 09:57:47 +03:00
parent 4068465ee6
commit 34f7faf0a8
7 changed files with 128 additions and 118 deletions
+22 -46
View File
@@ -16,9 +16,8 @@ import {
} from '../services/channels-ux.js';
import { formatChannelAddress, makeShineChannelRoute, makeShineChannelShortRoute } from '../services/shine-routes.js';
import { renderAvatar } from '../components/avatar-image.js';
import { createOverflowDots } from '../components/overflow-dots.js';
import { createDropdownMenu } from '../components/dropdown-menu.js';
import { createTopBar } from '../components/topbar.js';
import { createTopBarFilterTitle } from '../components/topbar-filter-title.js';
import { parseDmTechBlocks } from '../services/dm-tech-blocks.js';
import { rememberChannelPosition, readChannelPosition, restoreChannelPosition } from '../services/channel-view-state.js';
import { pageDataAge } from '../services/page-data-cache.js';
@@ -295,12 +294,12 @@ function buildChannelsViewRoute(mode) {
return 'channels';
}
function channelsViewTitle(mode) {
if (mode === CHANNELS_VIEW_OWNED) return 'Мои каналы';
if (mode === CHANNELS_VIEW_FOLLOWING) return 'Подписки';
if (mode === CHANNELS_VIEW_DELETED) return 'Удалённые каналы';
return 'Каналы';
}
const CHANNEL_FILTERS = [
[CHANNELS_VIEW_ALL, 'Все'],
[CHANNELS_VIEW_FOLLOWING, 'Подписки'],
[CHANNELS_VIEW_OWNED, 'Мои'],
[CHANNELS_VIEW_DELETED, 'Мои удалённые'],
];
function isFollowedUserVisible(targetLogin) {
const expected = normalizeComparableLogin(targetLogin);
@@ -1072,29 +1071,34 @@ export function render({ navigate, route, chrome }) {
const contentEl = document.createElement('div');
contentEl.className = 'channels-list-content';
const filterTitle = createTopBarFilterTitle({
section: 'Каналы',
choices: CHANNEL_FILTERS,
value: listState.viewMode,
minWidth: 240,
onSelect: (mode) => {
if (mode !== listState.viewMode) navigate(buildChannelsViewRoute(mode));
},
});
const topBarEl = createTopBar({
title: channelsViewTitle(listState.viewMode),
className: 'topbar--root',
center: filterTitle.element,
className: 'topbar--root topbar--section-filter',
actions: [
{
iconNode: createOverflowDots(),
icon: 'moreVertical',
title: 'Меню каналов',
ariaLabel: 'Открыть меню каналов',
className: 'channels-menu-btn',
menu: {
minWidth: 240,
minWidth: 210,
items: () => [
{ label: 'Создать канал', iconHtml: channelMenuIcon('add'), action: () => navigate('add-channel-view') },
{ divider: true },
{ label: 'Показать все каналы', iconHtml: channelMenuIcon('all'), selected: listState.viewMode === CHANNELS_VIEW_ALL, action: () => navigate(buildChannelsViewRoute(CHANNELS_VIEW_ALL)) },
{ label: 'Показать подписки', iconHtml: channelMenuIcon('following'), selected: listState.viewMode === CHANNELS_VIEW_FOLLOWING, action: () => navigate(buildChannelsViewRoute(CHANNELS_VIEW_FOLLOWING)) },
{ label: 'Показать мои', iconHtml: channelMenuIcon('mine'), selected: listState.viewMode === CHANNELS_VIEW_OWNED, action: () => navigate(buildChannelsViewRoute(CHANNELS_VIEW_OWNED)) },
{ label: 'Показать мои удалённые каналы', iconHtml: iconHtml('trash'), selected: listState.viewMode === CHANNELS_VIEW_DELETED, action: () => navigate(buildChannelsViewRoute(CHANNELS_VIEW_DELETED)) },
],
},
},
],
});
topBarEl.addCleanup(() => filterTitle.destroy());
const controls = document.createElement('div');
controls.className = 'channels-list-controls';
@@ -1113,35 +1117,7 @@ export function render({ navigate, route, chrome }) {
serverSearchButton.addEventListener('click', () => navigate('search-view'));
searchWrap.append(searchInput, serverSearchButton);
const tabs = document.createElement('div');
tabs.className = 'tabs tabs--three';
tabs.setAttribute('role', 'tablist');
tabs.setAttribute('aria-label', 'Фильтр каналов');
tabs.addEventListener('keydown', (event) => {
const buttons = [...tabs.querySelectorAll('button')];
const index = buttons.indexOf(document.activeElement);
if (index < 0 || !['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) return;
event.preventDefault();
const next = event.key === 'Home' ? 0 : event.key === 'End' ? buttons.length - 1 : (index + (event.key === 'ArrowRight' ? 1 : -1) + buttons.length) % buttons.length;
buttons[next].focus();
});
[
[CHANNELS_VIEW_ALL, 'Все'],
[CHANNELS_VIEW_FOLLOWING, 'Подписки'],
[CHANNELS_VIEW_OWNED, 'Мои'],
].forEach(([mode, label]) => {
const button = document.createElement('button');
button.type = 'button';
button.className = 'tab-btn';
button.textContent = label;
button.setAttribute('role', 'tab');
const selected = listState.viewMode === mode;
button.classList.toggle('active', selected);
button.setAttribute('aria-selected', String(selected));
button.addEventListener('click', () => navigate(buildChannelsViewRoute(mode)));
tabs.append(button);
});
controls.append(searchWrap, tabs);
controls.append(searchWrap);
const reloadFeed = async () => loadFeedAndRender({ screen, listState, contentEl, navigate });