UI: четыре кнопки как в Threads, строка ответа и редактор по их образцу

Под записями и ответами – лайк, ответы, репост, поделиться. Репост в блокчейне
ещё дорабатывается: кнопка на месте и пока сообщает «Репосты скоро появятся»
(переключатель REPOSTS_ENABLED в channels-ux.js).
Строка ответа внизу обсуждения: аватар, «Ответьте …», «фото/файл» (редактор
сразу с выбором файла) и «развернуть».
Редактор: текст пишется прямо под именем, без рамки; под текстом – иконка
вложения и «Очистить черновик»; внизу – счётчик и кнопка отправки.
This commit is contained in:
q
2026-10-11 23:05:43 +03:00
parent 7ac9e5a806
commit e6937cb49c
9 changed files with 123 additions and 43 deletions
+56 -13
View File
@@ -13,6 +13,8 @@ import {
formatPostStamp,
formatShortAge,
formatRelativeTime,
notifyRepostSoon,
REPOSTS_ENABLED,
longPressFeel,
shareOrCopyLink,
showToast,
@@ -932,7 +934,20 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
else handlers.onOpenThread(target);
});
// Тот же вид и порядок кнопок, что в ленте канала.
if (threadsLayout) actions.append(likeButton, discussionButton, shareButton);
const repostButton = document.createElement('button');
repostButton.type = 'button';
repostButton.className = 'ui-button channel-action-item channel-action-repost';
repostButton.innerHTML = `
<span class="channel-action-icon" aria-hidden="true">${iconHtml('repost')}</span>
<span class="channel-action-label">Репост</span>
`;
setActionTitle(repostButton, 'Репост');
repostButton.addEventListener('click', (event) => {
event.stopPropagation();
if (!REPOSTS_ENABLED) { notifyRepostSoon(); return; }
void handlers.onRepost?.(target);
});
if (threadsLayout) actions.append(likeButton, discussionButton, repostButton, shareButton);
else actions.append(likeButton, shareButton, discussionButton);
menuItems.unshift({ label: 'Ответить', iconHtml: iconHtml('reply'), action: () => replyButton.click() });
// Те же действия, что у ответов в обсуждении.
@@ -1189,8 +1204,15 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
share.setAttribute('aria-label', 'Поделиться комментарием');
share.addEventListener('click', () => handlers.shareComment(node));
// Ряд действий как у записи канала: лайк, ответы, поделиться.
actions.append(like, reply, share);
const repost = document.createElement('button');
repost.type = 'button';
repost.className = 'channel-action-item thread-comment__repost';
repost.innerHTML = iconHtml('repost');
repost.setAttribute('aria-label', 'Репост');
repost.addEventListener('click', () => (REPOSTS_ENABLED ? handlers.onRepost?.(target) : notifyRepostSoon()));
// Ряд действий как у записи канала: лайк, ответы, репост, поделиться.
actions.append(like, reply, repost, share);
main.append(actions);
item.append(who, main);
// Как в Threads: нажатие на ответ открывает его обсуждение (кнопки, ссылки и вложения работают сами по себе).
@@ -1993,7 +2015,7 @@ export function render({ navigate, route, chrome }) {
}
return item;
};
replyEditorOpener = (node) => {
replyEditorOpener = (node, { attach = false } = {}) => {
if (!node || disposed) return;
const path = [];
for (let cur = node; cur && cur !== focus; cur = parentByKey.get(nodeKey(cur))) path.unshift(cur);
@@ -2005,6 +2027,7 @@ export function render({ navigate, route, chrome }) {
placeholder: `Ответить ${node.authorLogin || ''}…`,
context: { chain },
key: `thread-reply:${nodeKey(node)}`,
openAttachOnStart: attach,
isActive: () => !disposed,
onSubmit: ({ text }) => handlers.onReply(buildTargetFromNode(node), text),
});
@@ -2016,17 +2039,37 @@ export function render({ navigate, route, chrome }) {
if (focus) {
const bar = document.createElement('div');
bar.className = 'channel-composer thread-composer';
const open = document.createElement('button');
open.type = 'button';
const open = document.createElement('div');
if (state.session.isAuthorized) {
open.className = 'channel-compose-bar';
open.innerHTML = `<span class="channel-compose-bar__text"></span><span class="channel-compose-bar__icon" aria-hidden="true">${iconHtml('send')}</span>`;
open.querySelector('.channel-compose-bar__text').textContent = `Ответить ${focus.authorLogin || ''}…`;
open.addEventListener('click', () => replyEditorOpener(focus));
// Строка ответа как в Threads: аватар, «Ответьте …», прикрепить, развернуть – всё ведёт в общий редактор.
open.className = 'thread-reply-bar';
const me = renderUserAvatar({ login: state.session.login, size: 'xs', className: 'thread-reply-bar__avatar' });
const field = document.createElement('button');
field.type = 'button';
field.className = 'thread-reply-bar__field';
field.textContent = `Ответьте ${focus.authorLogin || ''}…`;
field.addEventListener('click', () => replyEditorOpener(focus));
const attach = document.createElement('button');
attach.type = 'button';
attach.className = 'thread-reply-bar__icon';
attach.innerHTML = iconHtml('image');
attach.setAttribute('aria-label', 'Ответ с фото, видео или файлом');
attach.addEventListener('click', () => replyEditorOpener(focus, { attach: true }));
const expand = document.createElement('button');
expand.type = 'button';
expand.className = 'thread-reply-bar__icon';
expand.innerHTML = iconHtml('expand');
expand.setAttribute('aria-label', 'Открыть редактор ответа');
expand.addEventListener('click', () => replyEditorOpener(focus));
open.append(me, field, attach, expand);
} else {
open.className = 'primary-btn channel-main-action';
open.textContent = 'Войти, чтобы ответить';
open.addEventListener('click', () => { state.authReturnHash = window.location.pathname || '/channels'; navigate('login-view'); });
const loginBtn = document.createElement('button');
loginBtn.type = 'button';
open.append(loginBtn);
open.className = 'thread-reply-guest';
loginBtn.className = 'primary-btn channel-main-action';
loginBtn.textContent = 'Войти, чтобы ответить';
loginBtn.addEventListener('click', () => { state.authReturnHash = window.location.pathname || '/channels'; navigate('login-view'); });
}
bar.append(open);
chrome?.setComposer(bar);