From dde3902573802cc49c5ca401419328035ab448da Mon Sep 17 00:00:00 2001 From: Silberengel Date: Thu, 5 Feb 2026 12:23:21 +0100 Subject: [PATCH] fix reaction counts on /discussions increase paragraph spacing correct styling --- src/app.css | 60 +++ .../components/content/EmbeddedEvent.svelte | 2 +- .../content/MarkdownRenderer.svelte | 18 + src/lib/components/content/VoteCount.svelte | 127 +++++ src/lib/components/layout/Header.svelte | 2 +- src/lib/modules/comments/Comment.svelte | 51 +- .../DiscussionCard.svelte} | 150 +++--- .../DiscussionList.svelte} | 191 ++++---- .../modules/discussions/DiscussionView.svelte | 143 ++++++ .../discussions/DiscussionVoteButtons.svelte | 450 ++++++++++++++++++ .../EventView.svelte} | 165 +++---- src/lib/modules/feed/FeedPage.svelte | 137 ++---- src/lib/modules/feed/FeedPost.svelte | 114 ++--- .../reactions/FeedReactionButtons.svelte | 210 ++------ .../modules/reactions/ReactionButtons.svelte | 257 ---------- src/lib/types/kind-lookup.ts | 4 +- src/routes/+page.svelte | 84 +--- src/routes/cache/+page.svelte | 33 +- src/routes/discussions/+page.svelte | 85 ++++ src/routes/event/[id]/+page.svelte | 23 +- 20 files changed, 1350 insertions(+), 956 deletions(-) create mode 100644 src/lib/components/content/VoteCount.svelte rename src/lib/modules/{threads/ThreadCard.svelte => discussions/DiscussionCard.svelte} (68%) rename src/lib/modules/{threads/ThreadList.svelte => discussions/DiscussionList.svelte} (77%) create mode 100644 src/lib/modules/discussions/DiscussionView.svelte create mode 100644 src/lib/modules/discussions/DiscussionVoteButtons.svelte rename src/lib/modules/{threads/ThreadView.svelte => events/EventView.svelte} (77%) delete mode 100644 src/lib/modules/reactions/ReactionButtons.svelte create mode 100644 src/routes/discussions/+page.svelte diff --git a/src/app.css b/src/app.css index 5207a78..b18deab 100644 --- a/src/app.css +++ b/src/app.css @@ -70,6 +70,66 @@ body { font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Droid Sans Mono', 'Source Code Pro', monospace; } +/* Responsive font sizing based on screen size */ +@media (max-width: 640px) { + :root { + --text-size: clamp(14px, 4vw, 16px); + } +} + +@media (min-width: 641px) and (max-width: 1024px) { + :root { + --text-size: clamp(15px, 1.5vw, 18px); + } +} + +@media (min-width: 1025px) { + :root { + --text-size: clamp(16px, 1.2vw, 20px); + } +} + +/* Paragraph spacing - increased for better readability */ +p { + margin-bottom: 1.25em; + margin-top: 0; +} + +/* Markdown content paragraph spacing */ +:global(.markdown-content) p { + margin-bottom: 1.25em; + margin-top: 0; +} + +/* Consistent heading sizes relative to base font size */ +h1 { + font-size: clamp(1.5rem, 4vw, 2rem); + line-height: 1.2; + margin-bottom: 1rem; + margin-top: 0; +} + +h2 { + font-size: clamp(1.25rem, 3vw, 1.5rem); + line-height: 1.3; + margin-bottom: 0.875rem; + margin-top: 0; +} + +h3 { + font-size: clamp(1.125rem, 2.5vw, 1.25rem); + line-height: 1.4; + margin-bottom: 0.75rem; + margin-top: 0; +} + +h4, h5, h6 { + font-size: clamp(1rem, 2vw, 1.125rem); + line-height: 1.4; + margin-bottom: 0.625rem; + margin-top: 0; +} + /* Apply monospace font to all elements globally */ * { font-family: inherit; diff --git a/src/lib/components/content/EmbeddedEvent.svelte b/src/lib/components/content/EmbeddedEvent.svelte index f932226..ff8152d 100644 --- a/src/lib/components/content/EmbeddedEvent.svelte +++ b/src/lib/components/content/EmbeddedEvent.svelte @@ -199,7 +199,7 @@ if (!event) return; // Dispatch custom event on window to open in side-panel - // Parent components (like FeedPage, ThreadList) listen for this event on window + // Parent components (like FeedPage, DiscussionList) listen for this event on window const openEvent = new CustomEvent('openEventInDrawer', { detail: { event }, bubbles: true, diff --git a/src/lib/components/content/MarkdownRenderer.svelte b/src/lib/components/content/MarkdownRenderer.svelte index 9146f7c..bbe42d0 100644 --- a/src/lib/components/content/MarkdownRenderer.svelte +++ b/src/lib/components/content/MarkdownRenderer.svelte @@ -846,6 +846,24 @@ overflow-wrap: break-word; } + /* Increased paragraph spacing for better readability */ + :global(.markdown-content p) { + margin-bottom: 1.25em; + margin-top: 0; + } + + /* Ensure consistent spacing between paragraphs and other elements */ + :global(.markdown-content p + p) { + margin-top: 0; + } + + :global(.markdown-content p + ul), + :global(.markdown-content p + ol), + :global(.markdown-content p + blockquote), + :global(.markdown-content p + pre) { + margin-top: 1em; + } + :global(.markdown-content img) { max-width: 100%; height: auto; diff --git a/src/lib/components/content/VoteCount.svelte b/src/lib/components/content/VoteCount.svelte new file mode 100644 index 0000000..2e9a1ad --- /dev/null +++ b/src/lib/components/content/VoteCount.svelte @@ -0,0 +1,127 @@ + + + + {#if !votesCalculated} + + ⬆️ 0 + ⬇️ 0 + Calculating votes + + {:else} + + + + + {/if} + + + diff --git a/src/lib/components/layout/Header.svelte b/src/lib/components/layout/Header.svelte index 4cb96ff..305015b 100644 --- a/src/lib/components/layout/Header.svelte +++ b/src/lib/components/layout/Header.svelte @@ -37,7 +37,7 @@
aitherboard - /Discussions + /Discussions /Feed {#if isLoggedIn} /Write diff --git a/src/lib/modules/comments/Comment.svelte b/src/lib/modules/comments/Comment.svelte index 2b6a2c5..347cd09 100644 --- a/src/lib/modules/comments/Comment.svelte +++ b/src/lib/modules/comments/Comment.svelte @@ -3,21 +3,28 @@ import MarkdownRenderer from '../../components/content/MarkdownRenderer.svelte'; import ReplyContext from '../../components/content/ReplyContext.svelte'; import FeedReactionButtons from '../reactions/FeedReactionButtons.svelte'; + import DiscussionVoteButtons from '../discussions/DiscussionVoteButtons.svelte'; import EventMenu from '../../components/EventMenu.svelte'; + import { nostrClient } from '../../services/nostr/nostr-client.js'; + import { relayManager } from '../../services/nostr/relay-manager.js'; + import { onMount } from 'svelte'; import type { NostrEvent } from '../../types/nostr.js'; - import { getKindInfo } from '../../types/kind-lookup.js'; + import { getKindInfo, KIND } from '../../types/kind-lookup.js'; interface Props { comment: NostrEvent; parentEvent?: NostrEvent; onReply?: (comment: NostrEvent) => void; rootEventKind?: number; // The kind of the root event (e.g., 11 for threads) + reactions?: NostrEvent[]; // Optional pre-loaded reactions (for performance) } - let { comment, parentEvent, onReply, rootEventKind }: Props = $props(); + let { comment, parentEvent, onReply, rootEventKind, reactions: providedReactions }: Props = $props(); let expanded = $state(false); let contentElement: HTMLElement | null = $state(null); let needsExpansion = $state(false); + + // DiscussionVoteButtons handles all vote counting internally function getRelativeTime(): string { const now = Math.floor(Date.now() / 1000); @@ -94,17 +101,6 @@
- -
- - - -
{#if needsExpansion} @@ -115,6 +111,22 @@ {expanded ? 'Show less' : 'Show more'} {/if} + + +
+ {#if rootEventKind === KIND.DISCUSSION_THREAD} + + + {:else} + + {/if} + +
{getKindInfo(comment.kind).number} @@ -144,12 +156,25 @@ .comment-actions { padding-right: 6rem; /* Reserve space for kind badge */ + padding-top: 0.5rem; + border-top: 1px solid var(--fog-border, #e5e7eb); + margin-top: 0.5rem; + /* Ensure footer is always visible, even when content is collapsed */ + position: relative; + z-index: 1; + overflow: visible; + } + + :global(.dark) .comment-actions { + border-top-color: var(--fog-dark-border, #374151); } .card-content { max-height: 500px; overflow: hidden; transition: max-height 0.3s ease; + /* Ensure footer below is not affected by overflow */ + position: relative; } .card-content.expanded { diff --git a/src/lib/modules/threads/ThreadCard.svelte b/src/lib/modules/discussions/DiscussionCard.svelte similarity index 68% rename from src/lib/modules/threads/ThreadCard.svelte rename to src/lib/modules/discussions/DiscussionCard.svelte index f8ca8c5..ab05eb8 100644 --- a/src/lib/modules/threads/ThreadCard.svelte +++ b/src/lib/modules/discussions/DiscussionCard.svelte @@ -1,6 +1,6 @@ + +{#if loading} +

Loading thread...

+{:else if rootEvent} +
+ +
+ +
+ + +
+ +
+
+{:else} +

Thread not found

+{/if} + + diff --git a/src/lib/modules/discussions/DiscussionVoteButtons.svelte b/src/lib/modules/discussions/DiscussionVoteButtons.svelte new file mode 100644 index 0000000..31301f7 --- /dev/null +++ b/src/lib/modules/discussions/DiscussionVoteButtons.svelte @@ -0,0 +1,450 @@ + + +
+ + +
+ + diff --git a/src/lib/modules/threads/ThreadView.svelte b/src/lib/modules/events/EventView.svelte similarity index 77% rename from src/lib/modules/threads/ThreadView.svelte rename to src/lib/modules/events/EventView.svelte index ef27dd8..22d1b21 100644 --- a/src/lib/modules/threads/ThreadView.svelte +++ b/src/lib/modules/events/EventView.svelte @@ -1,12 +1,19 @@ {#if loading} -

Loading thread...

+

Loading event...

+{:else if error} +

Error: {error}

{:else if rootEvent} -
+
{#if rootEvent.kind === 30040} {@const titleTag = rootEvent.tags.find(t => t[0] === 'title')} @@ -194,12 +157,12 @@ {/if} {/if} - -
- -
- - {#if isEventIndex} + + {#if isMetadataOnly} + + {:else if isEventIndex}
{#if loadingIndex} @@ -306,35 +269,29 @@ {/if}
{:else} - -
- + +
+
{/if}
{:else} -

Thread not found

+

Event not found

{/if} diff --git a/src/lib/modules/reactions/ReactionButtons.svelte b/src/lib/modules/reactions/ReactionButtons.svelte deleted file mode 100644 index 69079bd..0000000 --- a/src/lib/modules/reactions/ReactionButtons.svelte +++ /dev/null @@ -1,257 +0,0 @@ - - -{#if isLoggedIn} -
- {#if event.kind === KIND.DISCUSSION_THREAD || event.kind === KIND.COMMENT} - - - - {:else} - - - - {/if} -
-{/if} - - diff --git a/src/lib/types/kind-lookup.ts b/src/lib/types/kind-lookup.ts index 13565ea..843d952 100644 --- a/src/lib/types/kind-lookup.ts +++ b/src/lib/types/kind-lookup.ts @@ -111,8 +111,8 @@ export const KIND_LOOKUP: Record = { [KIND.HIGHLIGHTED_ARTICLE]: { number: KIND.HIGHLIGHTED_ARTICLE, description: 'Highlighted Article', showInFeed: true, isSecondaryKind: false }, // Threads and comments - [KIND.DISCUSSION_THREAD]: { number: KIND.DISCUSSION_THREAD, description: 'Discussion Thread', showInFeed: true, isSecondaryKind: false }, - [KIND.COMMENT]: { number: KIND.COMMENT, description: 'Comment', showInFeed: true, isSecondaryKind: true }, + [KIND.DISCUSSION_THREAD]: { number: KIND.DISCUSSION_THREAD, description: 'Discussion Thread', showInFeed: false, isSecondaryKind: false }, // Only shown on /discussions page + [KIND.COMMENT]: { number: KIND.COMMENT, description: 'Comment', showInFeed: true, isSecondaryKind: true }, // Only shown on /discussions page // Media [KIND.PICTURE_NOTE]: { number: KIND.PICTURE_NOTE, description: 'Picture Note', showInFeed: true, isSecondaryKind: false }, diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index c0dffd5..bca9592 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,85 +1,11 @@ -
- -
-
-
-

/Discussions

-

Decentralized discussion board on Nostr. Brought to you by Silberengel.

-
- - ✍️ - -
- -
- -
- - -
- - + diff --git a/src/routes/cache/+page.svelte b/src/routes/cache/+page.svelte index 11eb738..c460b44 100644 --- a/src/routes/cache/+page.svelte +++ b/src/routes/cache/+page.svelte @@ -670,7 +670,7 @@ } .page-title { - font-size: 2rem; + font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 700; margin-bottom: 2rem; color: var(--fog-text, #1f2937); @@ -681,7 +681,7 @@ } .section-title { - font-size: 1.5rem; + font-size: clamp(1.25rem, 3vw, 1.5rem); font-weight: 600; margin-bottom: 1rem; color: var(--fog-text, #1f2937); @@ -692,7 +692,7 @@ } .subsection-title { - font-size: 1.25rem; + font-size: clamp(1.125rem, 2.5vw, 1.25rem); font-weight: 600; margin-bottom: 0.75rem; margin-top: 1.5rem; @@ -742,7 +742,7 @@ } .stat-label { - font-size: 0.875rem; + font-size: 0.875em; color: var(--fog-text-light, #6b7280); margin-bottom: 0.5rem; } @@ -752,7 +752,7 @@ } .stat-value { - font-size: 1.5rem; + font-size: clamp(1.125rem, 2.5vw, 1.5rem); font-weight: 600; color: var(--fog-text, #1f2937); } @@ -819,7 +819,7 @@ border: none; border-radius: 0.25rem; cursor: pointer; - font-size: 0.875rem; + font-size: 0.875em; } .clear-kind-button:hover { @@ -839,7 +839,7 @@ } .filter-label { - font-size: 0.875rem; + font-size: 0.875em; font-weight: 500; color: var(--fog-text, #1f2937); } @@ -855,7 +855,7 @@ border-radius: 0.375rem; background: var(--fog-post, #ffffff); color: var(--fog-text, #1f2937); - font-size: 0.875rem; + font-size: 0.875em; } :global(.dark) .filter-select, @@ -878,7 +878,7 @@ border: none; border-radius: 0.375rem; cursor: pointer; - font-size: 0.875rem; + font-size: 0.875em; font-weight: 500; } @@ -938,7 +938,7 @@ .event-id-code { font-family: monospace; - font-size: 0.875rem; + font-size: 0.875em; background: var(--fog-highlight, #f3f4f6); padding: 0.25rem 0.5rem; border-radius: 0.25rem; @@ -957,7 +957,7 @@ display: flex; flex-wrap: wrap; gap: 1rem; - font-size: 0.875rem; + font-size: 0.875em; color: var(--fog-text-light, #6b7280); word-wrap: break-word; overflow-wrap: break-word; @@ -969,7 +969,7 @@ .event-meta code { font-family: monospace; - font-size: 0.8125rem; + font-size: 0.8125em; word-break: break-all; overflow-wrap: break-word; max-width: 100%; @@ -997,7 +997,7 @@ .event-json { font-family: monospace; - font-size: 0.8125rem; + font-size: 0.8125em; background: var(--fog-highlight, #f3f4f6); border: 1px solid var(--fog-border, #e5e7eb); border-radius: 0.375rem; @@ -1030,10 +1030,11 @@ .event-content-preview { margin: 0 0 0.5rem 0; color: var(--fog-text-light, #6b7280); - font-size: 0.875rem; + font-size: 0.875em; word-wrap: break-word; overflow-wrap: break-word; max-width: 100%; + line-height: 1.6; } :global(.dark) .event-content-preview { @@ -1047,7 +1048,7 @@ border-radius: 0.375rem; color: var(--fog-text, #1f2937); cursor: pointer; - font-size: 0.875rem; + font-size: 0.875em; text-decoration: none; display: inline-block; white-space: nowrap; @@ -1101,7 +1102,7 @@ border: none; border-radius: 0.375rem; cursor: pointer; - font-size: 0.875rem; + font-size: 0.875em; font-weight: 500; } diff --git a/src/routes/discussions/+page.svelte b/src/routes/discussions/+page.svelte new file mode 100644 index 0000000..68b3f24 --- /dev/null +++ b/src/routes/discussions/+page.svelte @@ -0,0 +1,85 @@ + + +
+ +
+
+
+

/Discussions

+

Decentralized discussion board on Nostr.

+
+ + ✍️ + +
+ +
+ +
+ + +
+ + diff --git a/src/routes/event/[id]/+page.svelte b/src/routes/event/[id]/+page.svelte index deb128a..d15ec1a 100644 --- a/src/routes/event/[id]/+page.svelte +++ b/src/routes/event/[id]/+page.svelte @@ -1,13 +1,16 @@