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
+1 -1
View File
@@ -1,2 +1,2 @@
client.version=1.18.3
client.version=1.18.4
server.version=1.14.0
+1 -1
View File
@@ -39,7 +39,7 @@
}());
</script>
<script>
window.__SHINE_BUILD_HASH__ = '20261011224500';
window.__SHINE_BUILD_HASH__ = '20261011233000';
window.__SHINE_CLIENT_VERSION__ = '1.2.10';
</script>
<script>
+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"/>',
};
+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);
+17 -1
View File
@@ -22,6 +22,8 @@ import {
formatRelativeTime,
formatShortAge,
longPressFeel,
notifyRepostSoon,
REPOSTS_ENABLED,
shareOrCopyLink,
showToast,
softHaptic,
@@ -2165,7 +2167,21 @@ function renderPostCard(post, {
// Порядок как в макете V4: лайк → поделиться → обсуждение; дата и «⋯» — справа.
// В раскладке Threads: лайк → обсуждение → поделиться, дата и «⋯» в шапке.
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 onRepost?.(post.messageRef);
});
// Четыре кнопки как в Threads: лайк, ответы, репост, поделиться.
if (threadsLayout) actions.append(likeButton, discussionButton, repostButton, shareButton);
else actions.append(likeButton, shareButton, discussionButton);
if (selector?.publicOrdinalUrlsAllowed && post.messageRef?.blockNumber != null) {
const streamRoute = makeShineChannelStreamRoute({
+7
View File
@@ -292,3 +292,10 @@ export async function longPressFeel(el, delayMs = 130) {
await new Promise((resolve) => setTimeout(resolve, Math.max(60, Number(delayMs) || 130)));
if (node) node.classList.remove('is-long-press');
}
// Репост в блокчейне ещё дорабатывается (обещан скоро) – кнопка уже на месте, как четвёртая в ряду действий.
// Когда появится, здесь вызывать настоящий обработчик.
export const REPOSTS_ENABLED = false;
export function notifyRepostSoon() {
showToast('Репосты скоро появятся');
}
+15 -21
View File
@@ -168,31 +168,19 @@
min-height: calc(68px + env(safe-area-inset-bottom));
padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
display: grid;
grid-template-columns: auto minmax(0, 1fr) auto;
grid-template-columns: minmax(0, 1fr) auto;
align-items: center;
gap: 10px;
border-top: 1px solid var(--border-subtle);
background: var(--background);
}
.channel-editor__attach,
.channel-editor__submit {
min-height: 44px;
padding: 0 14px;
border-radius: 12px;
padding: 0 18px;
border-radius: 22px;
}
.channel-editor__attach {
width: 44px;
padding: 0;
display: inline-grid;
place-items: center;
color: var(--accent);
border: 1px solid var(--border-control);
background: var(--surface);
}
.channel-editor__attach svg { width: 22px; height: 22px; stroke-width: 1.9; }
.channel-editor__submit {
color: var(--on-accent);
background: var(--accent);
@@ -204,7 +192,7 @@
background: var(--surface-selected);
}
.channel-editor__footer.has-extra { grid-template-columns: auto auto minmax(0, 1fr) auto; }
.channel-editor__footer.has-extra { grid-template-columns: auto minmax(0, 1fr) auto; }
.channel-editor__type { display: block; min-width: 0; }
.channel-editor__type-select { min-height: 44px; width: auto; max-width: 9.5rem; padding-left: 12px; border-radius: 12px; font-size: .875rem; }
@@ -228,11 +216,7 @@
}
@media (max-width: 400px) {
.channel-editor__footer.has-extra { grid-template-columns: auto minmax(0, 1fr) auto; row-gap: 8px; }
.channel-editor__footer.has-extra .channel-editor__type { grid-row: 1; grid-column: 1 / 3; }
.channel-editor__footer.has-extra .channel-editor__counter { grid-row: 1; grid-column: 3; }
.channel-editor__footer.has-extra .channel-editor__attach { grid-row: 2; grid-column: 1; }
.channel-editor__footer.has-extra .channel-editor__submit { grid-row: 2; grid-column: 3; }
.channel-editor__footer.has-extra .channel-editor__counter { display: none; }
}
@media (prefers-reduced-motion: reduce) {
@@ -242,3 +226,13 @@
.channel-editor__author-text small { color: var(--text-secondary); font-size: .75rem; }
.channel-editor__draft { justify-self: end; color: var(--text-secondary); font-size: .75rem; }
.channel-editor__close svg { width: 24px; height: 24px; }
/* Поле ввода как в Threads: без рамки, под именем автора, с отступом под аватар; вложения и «прикрепить» – ниже текста. */
.channel-editor__compose { display: grid; gap: 8px; margin: -8px 0 0 52px; }
.channel-editor__compose .channel-editor__input { min-height: 48px; padding: 0; border: 0; border-radius: 0; background: transparent; }
.channel-editor__compose .channel-editor__input:focus-visible { border: 0; }
.channel-editor__tools { display: flex; align-items: center; gap: 4px; margin-left: -10px; }
.channel-editor__tools .channel-editor__attach { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--text-secondary); }
.channel-editor__tools .channel-editor__attach:hover { color: var(--text-primary); }
.channel-editor__tools .channel-editor__clear { margin-left: auto; }
.channel-editor__tools .channel-editor__attach svg { width: 22px; height: 22px; }
@@ -54,3 +54,13 @@ button.thread-quote:hover { background: var(--surface); }
/* Отдельная публикация в обсуждении использует карточку и действия из ленты. */
.thread-block--focus > .channel-message-card { margin-bottom: 8px; }
/* Строка ответа внизу обсуждения (как в Threads): аватар, поле-кнопка, «прикрепить», «развернуть». */
.thread-reply-bar { display: flex; align-items: center; gap: 4px; width: 100%; min-height: 48px; padding: 0 6px 0 8px; border: 1px solid var(--border-control); border-radius: 24px; background: var(--surface); }
.thread-reply-bar .avatar.thread-reply-bar__avatar { width: 30px; height: 30px; min-width: 30px; min-height: 30px; font-size: 12px; }
.thread-reply-bar__field { flex: 1; min-width: 0; min-height: 44px; padding: 0 6px; border: 0; background: transparent; color: var(--text-secondary); font: inherit; font-size: 1rem; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: text; }
.thread-reply-bar__icon { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text-secondary); cursor: pointer; }
.thread-reply-bar__icon:hover { color: var(--text-primary); background: var(--surface-selected); }
.thread-reply-bar__icon svg { width: 22px; height: 22px; }
.thread-reply-bar__field:focus-visible, .thread-reply-bar__icon:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.thread-reply-guest { width: 100%; display: grid; }