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 };
+2
View File
@@ -44,6 +44,8 @@ const paths = {
refresh: '<path d="M20 12a8 8 0 1 1-2.3-5.6"/><path d="M20 4v4.4h-4.4"/>',
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"/>',
expand: '<path d="M14 4h6v6M10 20H4v-6M20 4l-6.5 6.5M4 20l6.5-6.5"/>',
clip: '<path d="m20.5 11.5-8.2 8.2a5 5 0 0 1-7.1-7.1l8.5-8.5a3.3 3.3 0 0 1 4.7 4.7l-8.5 8.5a1.7 1.7 0 0 1-2.4-2.4l7.8-7.8"/>',
};