From 72f1502e837be85a9c44f53c906dad44f61288ed Mon Sep 17 00:00:00 2001 From: James Xylight Date: Thu, 31 Jul 2025 22:29:34 -0700 Subject: [PATCH 1/7] rename: Comments.svelte -> CommentTree.svelte --- src/lib/components/lemmy/comment/CommentListVirtualizer.svelte | 2 +- .../lemmy/comment/{Comments.svelte => CommentTree.svelte} | 2 +- src/routes/post/[instance]/[id=integer]/CommentProvider.svelte | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename src/lib/components/lemmy/comment/{Comments.svelte => CommentTree.svelte} (98%) diff --git a/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte b/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte index 6e9843d5..7c68db29 100644 --- a/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte +++ b/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte @@ -2,7 +2,7 @@ import VirtualList from '$lib/components/render/VirtualList.svelte' import type { Post } from 'lemmy-js-client' import type { CommentNodeI } from './comments.svelte' - import Comments from './Comments.svelte' + import Comments from './CommentList.svelte' import { onMount } from 'svelte' interface Props { diff --git a/src/lib/components/lemmy/comment/Comments.svelte b/src/lib/components/lemmy/comment/CommentTree.svelte similarity index 98% rename from src/lib/components/lemmy/comment/Comments.svelte rename to src/lib/components/lemmy/comment/CommentTree.svelte index aa8ae865..8828ee1a 100644 --- a/src/lib/components/lemmy/comment/Comments.svelte +++ b/src/lib/components/lemmy/comment/CommentTree.svelte @@ -9,7 +9,7 @@ import { Button, toast } from 'mono-svelte' import { ArrowDownCircle, Icon } from 'svelte-hero-icons' import Comment from './Comment.svelte' - import Comments from './Comments.svelte' + import Comments from './CommentList.svelte' import { buildCommentsTree, type CommentNodeI } from './comments.svelte' interface Props { diff --git a/src/routes/post/[instance]/[id=integer]/CommentProvider.svelte b/src/routes/post/[instance]/[id=integer]/CommentProvider.svelte index 0dec7af4..96ded05c 100644 --- a/src/routes/post/[instance]/[id=integer]/CommentProvider.svelte +++ b/src/routes/post/[instance]/[id=integer]/CommentProvider.svelte @@ -4,7 +4,7 @@ import { profile } from '$lib/auth.svelte' import CommentForm from '$lib/components/lemmy/comment/CommentForm.svelte' import CommentListVirtualizer from '$lib/components/lemmy/comment/CommentListVirtualizer.svelte' - import Comments from '$lib/components/lemmy/comment/Comments.svelte' + import Comments from '$lib/components/lemmy/comment/CommentList.svelte' import { buildCommentsTree } from '$lib/components/lemmy/comment/comments.svelte' import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte' import { t } from '$lib/i18n/translations' From bcfea91c6315883e9dca6c3ad3b39c0413b8a656 Mon Sep 17 00:00:00 2001 From: James Xylight Date: Thu, 31 Jul 2025 22:34:24 -0700 Subject: [PATCH 2/7] design: increase spacing by screen size for comment trees --- .../lemmy/comment/CommentListVirtualizer.svelte | 2 +- src/lib/components/lemmy/comment/CommentTree.svelte | 12 +++++++----- .../[instance]/[id=integer]/CommentProvider.svelte | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte b/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte index 7c68db29..7db54d06 100644 --- a/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte +++ b/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte @@ -2,7 +2,7 @@ import VirtualList from '$lib/components/render/VirtualList.svelte' import type { Post } from 'lemmy-js-client' import type { CommentNodeI } from './comments.svelte' - import Comments from './CommentList.svelte' + import Comments from './CommentTree.svelte' import { onMount } from 'svelte' interface Props { diff --git a/src/lib/components/lemmy/comment/CommentTree.svelte b/src/lib/components/lemmy/comment/CommentTree.svelte index 8828ee1a..aa3540ea 100644 --- a/src/lib/components/lemmy/comment/CommentTree.svelte +++ b/src/lib/components/lemmy/comment/CommentTree.svelte @@ -9,7 +9,7 @@ import { Button, toast } from 'mono-svelte' import { ArrowDownCircle, Icon } from 'svelte-hero-icons' import Comment from './Comment.svelte' - import Comments from './CommentList.svelte' + import Comments from './CommentTree.svelte' import { buildCommentsTree, type CommentNodeI } from './comments.svelte' interface Props { @@ -93,10 +93,12 @@ bind:node={nodes[index]} postId={post.id} op={post.creator_id == node.comment_view.creator.id} - contentClass="{node.children.length > 0 || - node.comment_view.counts.child_count > 0 - ? 'border-l' - : ''} ml-2.5 border-slate-200 dark:border-zinc-800 pl-2.5" + contentClass={[ + (node.children.length > 0 || + node.comment_view.counts.child_count > 0) && + 'border-l', + 'ml-2.5 border-slate-200 dark:border-zinc-800 pl-3 sm:pl-4 lg:pl-5', + ]} bind:open={nodes[index].expanded} > {#if node.children?.length > 0} diff --git a/src/routes/post/[instance]/[id=integer]/CommentProvider.svelte b/src/routes/post/[instance]/[id=integer]/CommentProvider.svelte index 96ded05c..416dc047 100644 --- a/src/routes/post/[instance]/[id=integer]/CommentProvider.svelte +++ b/src/routes/post/[instance]/[id=integer]/CommentProvider.svelte @@ -4,7 +4,7 @@ import { profile } from '$lib/auth.svelte' import CommentForm from '$lib/components/lemmy/comment/CommentForm.svelte' import CommentListVirtualizer from '$lib/components/lemmy/comment/CommentListVirtualizer.svelte' - import Comments from '$lib/components/lemmy/comment/CommentList.svelte' + import Comments from '$lib/components/lemmy/comment/CommentTree.svelte' import { buildCommentsTree } from '$lib/components/lemmy/comment/comments.svelte' import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte' import { t } from '$lib/i18n/translations' From 7ef9da9852b2b1ca4925ca85ad7db11d86daf0b6 Mon Sep 17 00:00:00 2001 From: James Xylight Date: Thu, 31 Jul 2025 22:38:46 -0700 Subject: [PATCH 3/7] design: make bolder and distinguish thread lines in comment trees --- src/lib/components/lemmy/comment/Comment.svelte | 3 +-- .../components/lemmy/comment/CommentTree.svelte | 17 +++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib/components/lemmy/comment/Comment.svelte b/src/lib/components/lemmy/comment/Comment.svelte index 01225339..6beb1834 100644 --- a/src/lib/components/lemmy/comment/Comment.svelte +++ b/src/lib/components/lemmy/comment/Comment.svelte @@ -116,8 +116,7 @@ {#if meta} + + diff --git a/src/lib/components/lemmy/post/PostVote.svelte b/src/lib/components/lemmy/post/PostVote.svelte index 632b34e8..e26bb507 100644 --- a/src/lib/components/lemmy/post/PostVote.svelte +++ b/src/lib/components/lemmy/post/PostVote.svelte @@ -22,6 +22,7 @@ import { site } from '$lib/lemmy.svelte.js' import { vote as voteItem } from '$lib/lemmy/contentview.js' import { errorMessage } from '$lib/lemmy/error' + import { settings } from '$lib/settings.svelte' import type { Post } from 'lemmy-js-client' import { buttonColor, toast } from 'mono-svelte' import { ChevronDown, ChevronUp, Icon } from 'svelte-hero-icons' @@ -67,16 +68,21 @@ {#if children}{@render children({ vote, score })}{:else} + {@const voteRatio = Math.floor( + ((upvotes ?? 0) / ((upvotes ?? 0) + (downvotes ?? 0))) * 100, + )}
{/if} + + diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json index c1d3558d..dea0246f 100644 --- a/src/lib/i18n/en.json +++ b/src/lib/i18n/en.json @@ -850,6 +850,10 @@ "titleOpensUrl": { "title": "Title opens URL", "description": "Makes clicking the title open the post's attached URL, rather than the comments." + }, + "voteRatioBar": { + "title": "Vote ratio bar", + "description": "When the controversiality of a post reaches greater than 15%, a bar will be displayed in the vote buttons to help visualize sentiment." } }, "embeds": { diff --git a/src/lib/settings.svelte.ts b/src/lib/settings.svelte.ts index 1a109e77..98df5f40 100644 --- a/src/lib/settings.svelte.ts +++ b/src/lib/settings.svelte.ts @@ -104,6 +104,7 @@ interface Settings { messages: { fullMarkdown: boolean } + voteRatioBar: boolean } export const defaultSettings: Settings = { @@ -184,6 +185,7 @@ export const defaultSettings: Settings = { messages: { fullMarkdown: toBool(env.PUBLIC_FULL_MARKDOWN) ?? false, }, + voteRatioBar: true, } function createSettingsState(initial: Settings): Settings { diff --git a/src/routes/settings/+page.svelte b/src/routes/settings/+page.svelte index 7579c224..39201000 100644 --- a/src/routes/settings/+page.svelte +++ b/src/routes/settings/+page.svelte @@ -29,6 +29,7 @@ ArrowRight, ArrowsPointingOut, ArrowsRightLeft, + ArrowsUpDown, ArrowTopRightOnSquare, ArrowTrendingDown, ArrowUpTray, @@ -402,6 +403,12 @@ title={$t('settings.app.absoluteDates.title')} description={$t('settings.app.absoluteDates.description')} /> + Date: Thu, 31 Jul 2025 23:05:59 -0700 Subject: [PATCH 5/7] feat: add vote ratio bar --- src/lib/components/lemmy/comment/CommentVote.svelte | 9 +++++++-- src/lib/components/lemmy/post/PostVote.svelte | 13 +++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/lib/components/lemmy/comment/CommentVote.svelte b/src/lib/components/lemmy/comment/CommentVote.svelte index 194fa3b6..685470a2 100644 --- a/src/lib/components/lemmy/comment/CommentVote.svelte +++ b/src/lib/components/lemmy/comment/CommentVote.svelte @@ -101,14 +101,19 @@ From 1e2701d20b33f6e859619c21b5a5a079c8430abc Mon Sep 17 00:00:00 2001 From: James Xylight Date: Fri, 1 Aug 2025 11:53:28 -0700 Subject: [PATCH 6/7] design: alternate background colors for even/odd comments --- src/lib/components/lemmy/comment/Comment.svelte | 7 +++---- .../lemmy/comment/CommentListVirtualizer.svelte | 9 +++++++-- src/lib/components/render/VirtualList.svelte | 2 +- src/lib/mono/materials/Material.svelte | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/lib/components/lemmy/comment/Comment.svelte b/src/lib/components/lemmy/comment/Comment.svelte index 6beb1834..096ddb15 100644 --- a/src/lib/components/lemmy/comment/Comment.svelte +++ b/src/lib/components/lemmy/comment/Comment.svelte @@ -177,8 +177,9 @@ > {/if} -
- {@render children?.()} -
+ {@render children?.()} diff --git a/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte b/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte index 7db54d06..676951dd 100644 --- a/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte +++ b/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte @@ -41,14 +41,19 @@
{#if offsetEl} {#snippet item(index)} -
+
[nodes[index]], v => (nodes[index] = v[0])} {post} diff --git a/src/lib/components/render/VirtualList.svelte b/src/lib/components/render/VirtualList.svelte index 09fadb7a..160e1918 100644 --- a/src/lib/components/render/VirtualList.svelte +++ b/src/lib/components/render/VirtualList.svelte @@ -230,7 +230,7 @@ {#each visibleItems as item (item.index)}
{@render itemSnippet(item.index)} diff --git a/src/lib/mono/materials/Material.svelte b/src/lib/mono/materials/Material.svelte index 1933102e..35d666ac 100644 --- a/src/lib/mono/materials/Material.svelte +++ b/src/lib/mono/materials/Material.svelte @@ -41,7 +41,7 @@ transparent: 'border border-slate-200 dark:border-zinc-900 border-b-slate-300 dark:border-t-zinc-800', uniform: - 'bg-white dark:bg-zinc-950 border border-slate-100 dark:border-zinc-900', + 'bg-white dark:bg-zinc-950 border border-slate-200 dark:border-zinc-900', none: '', } From 7fca5f212bd1b2510b6eec5a67fccda897d28578 Mon Sep 17 00:00:00 2001 From: James Xylight Date: Fri, 1 Aug 2025 11:57:58 -0700 Subject: [PATCH 7/7] design: remove borders for CommonList.svelte --- src/lib/components/ui/layout/CommonList.svelte | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/lib/components/ui/layout/CommonList.svelte b/src/lib/components/ui/layout/CommonList.svelte index dbd7c409..80f5a734 100644 --- a/src/lib/components/ui/layout/CommonList.svelte +++ b/src/lib/components/ui/layout/CommonList.svelte @@ -46,20 +46,15 @@ background-color: var(--color-white); container-type: inline-size; - border-left: 1px solid var(--color-slate-100); - border-right: 1px solid var(--color-slate-100); + border-radius: var(--radius-md) var(--radius-md); &:first-child { border-top-left-radius: var(--radius-2xl); border-top-right-radius: var(--radius-2xl); - - border-top: 1px solid var(--color-slate-100); } &:last-child { border-bottom-left-radius: var(--radius-2xl); border-bottom-right-radius: var(--radius-2xl); - - border-bottom: 1px solid var(--color-slate-100); } &:hover { @@ -77,16 +72,6 @@ :global(.dark) ul > :global(li) { background-color: var(--color-zinc-950); - border-left: 1px solid var(--color-zinc-900); - border-right: 1px solid var(--color-zinc-900); - - &:first-child { - border-top: 1px solid var(--color-zinc-900); - } - &:last-child { - border-bottom: 1px solid var(--color-zinc-900); - } - &:hover { background-color: var(--color-zinc-900); }