aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-12-01 12:04:25 -0700
committerAdam Soltys <[email protected]>2026-12-01 12:04:25 -0700
commit882045fac8a47d4e7a8592c3c287a0570a7eedf0 (patch)
tree9126c6527890127de4ecab440974178250ecaa2b /src
parentb4c47b8a23e189bcd20fc833b3530dff5f7a20e8 (diff)
downloadcoinosv3-882045fac8a47d4e7a8592c3c287a0570a7eedf0.tar.gz
coinosv3-882045fac8a47d4e7a8592c3c287a0570a7eedf0.zip
A really long note is collapsed in a feed, with Show more under it. "hey @adam ... could you collapse REALLY long notes, with a 'more...' link to expand if the user wants to read them. I follow @ZeroHedge News ... and their notes are huge!" (npub1muckyme in the coinos community, 2026-11-30, relayed by Adam 2026-12-01). A note longer than about 16 lines at the screen's width (estimated from its text) shows its first ten lines in a feed or on a profile, fading out, then Show more, which opens it in place without opening the thread; the thread shows it whole, as before. Short notes, articles and the note a thread is about are untouched. New feed-long-note-test (collapsed to ~10 lines with Show more, short note alone, Show more expands in place, thread whole) passes; feed-mention-tap, features-smoke, feed-stability, post-markdown and feed-repost pass.HEADmaster
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VMan6WoqaQDYdpWkatPCar
Diffstat (limited to 'src')
-rw-r--r--src/features/messages.js34
-rw-r--r--src/style.css5
2 files changed, 36 insertions, 3 deletions
diff --git a/src/features/messages.js b/src/features/messages.js
index 2351e2b..952350f 100644
--- a/src/features/messages.js
+++ b/src/features/messages.js
@@ -12946,6 +12946,36 @@ export function messagesFeature(ctx) {
// context: a reply shows the post it answers above itself (the
// Conversations feed, a profile's Replies tab) — a quote card, which opens
// that post; the reply's own tap opens the thread at the reply.
+ // A really long note (ZeroHedge's run to dozens of lines) shows its first
+ // ten lines in a feed, fading out, with Show more under it; its thread, and
+ // a tap on Show more, give the whole thing. "Could you collapse REALLY long
+ // notes, with a 'more...' link to expand" (npub1muckyme, 2026-11-30).
+ // Long = more than 16 lines at this screen's width, by estimate, so a
+ // collapsed note always hides a good part of itself, never a line or two.
+ const NOTE_CLAMP_OVER = 16;
+ const noteExpanded = new Set();
+ function noteLines(text) {
+ const w = Math.min((typeof window !== 'undefined' && window.innerWidth) || 400, 680);
+ const perLine = Math.max(24, Math.floor((w - 90) / 9.5)); // 18px text
+ let n = 0;
+ for (const para of String(text || '').split('\n')) n += Math.max(1, Math.ceil(para.length / perLine));
+ return n;
+ }
+ function noteTextBlock(ev, open, focus) {
+ const clampable = open && !focus;
+ const text = ev.kind === ARTICLE ? '' : momentStripped(ev, shownTranslation(ev)?.text ?? noteText(ev));
+ const clamp = clampable && ev.kind !== ARTICLE && !noteExpanded.has(ev.id) && noteLines(text) > NOTE_CLAMP_OVER;
+ const body = h('div', { class: 'note-text' + (clamp ? ' note-clamped' : ''), style: 'white-space:pre-wrap;overflow-wrap:anywhere' },
+ momentLink(ev),
+ ...(ev.kind === ARTICLE ? (open ? [articleCard(ev)] : articleBody(ev)) : noteBody(text, 0, noteEmojiTags(ev))));
+ if (!clamp) return body;
+ return h('div', { class: 'note-clamp-wrap' }, body,
+ h('button', {
+ class: 'note-more', type: 'button',
+ onClick: (e) => { e.stopPropagation(); noteExpanded.add(ev.id); render(); },
+ }, t('showMore')));
+ }
+
function noteRow(pk, ev, name, { open = true, focus = false, joined = false, context = false } = {}) {
if (ev.kind === REPOST) {
const inner = repostInner(ev);
@@ -13052,9 +13082,7 @@ export function messagesFeature(ctx) {
zapText(ev) ? h('div', {}, ...noteBody(zapText(ev))) : null)
: foreign
? h('div', { class: 'note-text small muted', style: 'white-space:pre-wrap;overflow-wrap:anywhere' }, (ev.kind === 64 ? '\u265f ' : '') + altText)
- : h('div', { class: 'note-text', style: 'white-space:pre-wrap;overflow-wrap:anywhere' },
- momentLink(ev),
- ...(ev.kind === ARTICLE ? (open ? [articleCard(ev)] : articleBody(ev)) : noteBody(momentStripped(ev, shownTranslation(ev)?.text ?? noteText(ev)), 0, noteEmojiTags(ev)))),
+ : noteTextBlock(ev, open, focus),
foreign || pending ? null : translateLine(ev),
ev.kind === POLL ? pollBox(ev) : null,
pending ? null : noteActions(pk, ev, { canZap }),
diff --git a/src/style.css b/src/style.css
index 311cfbb..4a86697 100644
--- a/src/style.css
+++ b/src/style.css
@@ -755,6 +755,11 @@ html:has(#app .chat-card), body:has(#app .chat-card) { overflow: hidden; }
.note-content > * { grid-column: 1 / -1; min-width: 0; }
.note-content > .note-header { grid-column: 2; grid-row: 1; }
.note-content > .note-text { font-size: 18px; line-height: 1.5; }
+/* a really long note in a feed: ten lines, fading out, then Show more */
+.note-content > .note-clamp-wrap > .note-text { font-size: 18px; line-height: 1.5; }
+.note-text.note-clamped { max-height: 15em; overflow: hidden;
+ -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent); mask-image: linear-gradient(to bottom, #000 72%, transparent); }
+.note-more { background: none; border: 0; padding: 4px 0 2px; color: var(--accent, #f7931a); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
.note-acts { margin-top: 8px; gap: 4px; width: 100%; }
.note-acts > .note-act { flex: 1 1 0; min-width: 0; justify-content: center; padding-inline: 2px; }
/* server comparison table (Settings → Advanced → Ark server) */