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
+14 -6
View File
@@ -36,6 +36,7 @@ export function openChannelEditor({
allowEmptyText = false,
allowAttachments = true,
rawText = false,
openAttachOnStart = false,
onSubmit,
isActive = () => true,
} = {}) {
@@ -180,16 +181,23 @@ export function openChannelEditor({
author.append(authorText);
if (chain.length) author.classList.add('is-chained');
body.append(author);
body.append(textarea, attachmentsBox, error, clearButton);
const footer = document.createElement('footer');
footer.className = 'channel-editor__footer';
const attachButton = document.createElement('button');
attachButton.type = 'button';
attachButton.className = 'secondary-btn channel-editor__attach';
attachButton.innerHTML = `${iconHtml('clip')}<span class="sr-only">Прикрепить</span>`;
attachButton.title = 'Прикрепить файл';
attachButton.className = 'icon-btn channel-editor__attach';
attachButton.innerHTML = `${iconHtml('image')}<span class="sr-only">Прикрепить фото, видео или файл</span>`;
attachButton.title = 'Фото, видео или файл';
attachButton.hidden = !allowAttachments;
// Как в Threads: текст пишется прямо под именем, без рамки; под ним – вложения и иконка «прикрепить».
const compose = document.createElement('div');
compose.className = 'channel-editor__compose';
const tools = document.createElement('div');
tools.className = 'channel-editor__tools';
tools.append(attachButton, clearButton);
compose.append(textarea, attachmentsBox, tools, error);
body.append(compose);
const counter = document.createElement('span');
counter.className = 'channel-editor__counter';
const submitButton = document.createElement('button');
@@ -197,7 +205,6 @@ export function openChannelEditor({
submitButton.className = 'primary-btn channel-editor__submit';
submitButton.textContent = submitLabel;
submitButton.title = 'Отправить · Ctrl+Enter / ⌘+Enter';
footer.append(attachButton);
if (extraControl instanceof Node) {
footer.classList.add('has-extra');
footer.append(extraControl);
@@ -216,7 +223,7 @@ export function openChannelEditor({
const sync = () => {
textarea.style.height = 'auto';
textarea.style.height = `${Math.max(160, textarea.scrollHeight)}px`;
textarea.style.height = `${Math.max(48, textarea.scrollHeight)}px`;
const length = textarea.value.length;
counter.textContent = `${length} / 2000`;
counter.classList.toggle('is-near-limit', length >= 1800);
@@ -409,6 +416,7 @@ export function openChannelEditor({
sync();
if (chain.length) body.scrollTop = author.offsetTop - body.offsetTop - 120;
textarea.focus({ preventScroll: chain.length > 0 });
if (openAttachOnStart && allowAttachments) attachButton.click();
textarea.setSelectionRange(textarea.value.length, textarea.value.length);
});
return { close };