From fbae6e22edf48c0fa95da7db90912c2a65d11956 Mon Sep 17 00:00:00 2001 From: Brandon Oxendine Date: Tue, 28 Apr 2026 16:03:54 +0200 Subject: [PATCH] Restyle reactions and highlight own reactions --- public/colors.css | 5 ++ src/components/Comment.svelte | 4 +- src/components/Diff.svelte | 1 + src/components/Discussion.svelte | 1 + src/components/Reactions.svelte | 98 ++++++++++++++++++++++++-------- src/components/Review.svelte | 1 + src/components/Revision.svelte | 1 + src/views/repo/Issue.svelte | 1 + 8 files changed, 86 insertions(+), 26 deletions(-) diff --git a/public/colors.css b/public/colors.css index 9400314cf..e9dd7e434 100644 --- a/public/colors.css +++ b/public/colors.css @@ -67,6 +67,8 @@ --color-surface-brand-primary: var(--color-brand-bg); --color-surface-brand-secondary: var(--color-brand-hover); + --color-surface-brand-subtle: var(--color-accent-blue-100); + --color-surface-brand-mid: var(--color-accent-blue-200); --color-border-brand: var(--color-brand-hover); --color-text-brand: var(--color-brand-text-light); } @@ -124,6 +126,9 @@ --color-code-error: var(--color-semantic-red-400); --color-code-functions: var(--color-accent-emerald-400); + --color-surface-brand-subtle: var(--color-accent-blue-900); + --color-surface-brand-mid: var(--color-accent-blue-800); + --color-text-brand: var(--color-brand-text-dark); } diff --git a/src/components/Comment.svelte b/src/components/Comment.svelte index 0c4cd8c36..689ba29b0 100644 --- a/src/components/Comment.svelte +++ b/src/components/Comment.svelte @@ -23,6 +23,7 @@ beforeTimestamp?: Snippet; id?: string; rid: string; + currentUserNid?: string; author: Author; body?: string; reactions?: Reaction[]; @@ -46,6 +47,7 @@ beforeTimestamp, id, rid, + currentUserNid, author, body = $bindable(), reactions, @@ -243,7 +245,7 @@ } }} /> {/if} - + {/if} diff --git a/src/components/Diff.svelte b/src/components/Diff.svelte index 4c93bd00c..47224791e 100644 --- a/src/components/Diff.svelte +++ b/src/components/Diff.svelte @@ -433,6 +433,7 @@ Promise; } - const { reactions, handleReaction }: Props = $props(); + const { reactions, currentUserNid, handleReaction }: Props = $props(); function authorsToTooltip(authors: Author[]) { return authors.map(a => a.alias ?? a.did).join("\n"); } + + function isMine(authors: Author[]) { + if (!currentUserNid) return false; + return authors.some(a => publicKeyFromDid(a.did) === currentUserNid); + } + + function formatAuthor(a: Author) { + const pk = publicKeyFromDid(a.did); + if (currentUserNid && pk === currentUserNid) { + return "You"; + } + return a.alias ?? truncateId(pk); + } + + function formatAuthors(authors: Author[]) { + if (authors.length > 3) return `${authors.length}`; + return authors.map(formatAuthor).join(", "); + }
{#each reactions as { emoji, authors }} -
- {#if handleReaction} - -
{ - if (handleReaction) { - await handleReaction(authors, emoji); - } - }}> - {@html emojiToTwemoji(emoji, ["21a9"])} - {authors.length} -
- {:else} -
- {@html emojiToTwemoji(emoji, ["21a9"])} - {authors.length} -
- {/if} + +
handleReaction(authors, emoji) + : undefined}> + {@html emojiToTwemoji(emoji, ["21a9"])} + {formatAuthors(authors)}
{/each}
diff --git a/src/components/Review.svelte b/src/components/Review.svelte index 23bad5b93..232251945 100644 --- a/src/components/Review.svelte +++ b/src/components/Review.svelte @@ -412,6 +412,7 @@ 1 ? revision.description.at(-1) diff --git a/src/views/repo/Issue.svelte b/src/views/repo/Issue.svelte index f4c4fee17..442ef5247 100644 --- a/src/views/repo/Issue.svelte +++ b/src/views/repo/Issue.svelte @@ -402,6 +402,7 @@
1 ? issue.body.edits.at(-1)