atagen

malice

public
Star0
Watch0

Commit 18fbdbb2c103

tarball

atagen <boss@atagen.co>2026-10-26 00:39 UTC

2 files changed+6-6
web: colour mentions by user and highlight only own pings
Modified file: web/src/lib/MessageText.svelte+4 additions−5 deletions
@@ -2,6 +2,7 @@
22 import EmojiText from './EmojiText.svelte';
33 import RichNodes from './RichNodes.svelte';
44 import { parseCode } from './code';
5+ import { senderHue } from './format';
56 import { segmentInline } from './inline';
67 import type { Mention } from './mentions';
78 import { parseRich } from './rich';
@@ -19,7 +20,7 @@
1920 $: single = segments.length === 1 && pieces[0].length === 1;
2021 </script>
2122
22-{#if rich}<div class="rich"><RichNodes nodes={rich} {mentions} {self} {nameOf} /></div>{:else}{#each segments as s, i}{#if s.kind === 'inline'}<code class="inline">{s.text}</code>{:else if s.kind === 'block'}<pre class="block"><code>{s.text}</code></pre>{:else}{#each pieces[i] as p}{#if p.kind === 'mention'}<span class="mention" class:me={p.user_id === self} title={p.user_id}><EmojiText text={p.text === p.user_id ? (nameOf(p.user_id) ?? p.text) : p.text} /></span>{:else if p.kind === 'link'}<a class="link" href={p.href} target="_blank" rel="noopener noreferrer"><EmojiText text={p.text} /></a>{:else}<EmojiText text={p.text} jumbo={jumbo && single} />{/if}{/each}{/if}{/each}{/if}
23+{#if rich}<div class="rich"><RichNodes nodes={rich} {mentions} {self} {nameOf} /></div>{:else}{#each segments as s, i}{#if s.kind === 'inline'}<code class="inline">{s.text}</code>{:else if s.kind === 'block'}<pre class="block"><code>{s.text}</code></pre>{:else}{#each pieces[i] as p}{#if p.kind === 'mention'}<span class="mention" class:me={p.user_id === self} style:--hue={senderHue(p.user_id)} title={p.user_id}><EmojiText text={p.text === p.user_id ? (nameOf(p.user_id) ?? p.text) : p.text} /></span>{:else if p.kind === 'link'}<a class="link" href={p.href} target="_blank" rel="noopener noreferrer"><EmojiText text={p.text} /></a>{:else}<EmojiText text={p.text} jumbo={jumbo && single} />{/if}{/each}{/if}{/each}{/if}
2324
2425 <style>
2526 code, .rich :global(code) {
@@ -43,14 +44,12 @@
4344 line-height: 1.4;
4445 }
4546 .mention, .rich :global(.mention) {
46- padding: 0 4px;
4747 border-radius: var(--r-sm);
4848 font-weight: 600;
49- color: var(--accent);
50- background: color-mix(in srgb, var(--accent) 18%, transparent);
49+ color: hsl(var(--hue) 70% var(--name-lightness));
5150 }
5251 .mention.me, .rich :global(.mention.me) {
53- color: var(--warn-text);
52+ padding: 0 4px;
5453 background: color-mix(in srgb, var(--warn) 28%, transparent);
5554 }
5655 .link, .rich :global(.link) { color: var(--accent); overflow-wrap: anywhere; }
Modified file: web/src/lib/RichNodes.svelte+2 additions−1 deletions
@@ -2,6 +2,7 @@
22 import EmojiText from './EmojiText.svelte';
33 import RichNodes from './RichNodes.svelte';
44 import { mediaUrl } from './api';
5+ import { senderHue } from './format';
56 import { segmentInline } from './inline';
67 import type { Mention } from './mentions';
78 import type { RichNode } from './rich';
@@ -14,4 +15,4 @@
1415 export let verbatim = false;
1516 </script>
1617
17-{#each nodes as n}{#if n.kind === 'text'}{#if verbatim}{n.text}{:else if plain}<EmojiText text={n.text} />{:else}{#each segmentInline(n.text, mentions) as p}{#if p.kind === 'mention'}<span class="mention" class:me={p.user_id === self} title={p.user_id}><EmojiText text={p.text === p.user_id ? (nameOf(p.user_id) ?? p.text) : p.text} /></span>{:else if p.kind === 'link'}<a class="link" href={p.href} target="_blank" rel="noopener noreferrer"><EmojiText text={p.text} /></a>{:else}<EmojiText text={p.text} />{/if}{/each}{/if}{:else if n.kind === 'mention'}<span class="mention" class:me={n.user_id === self} title={n.user_id}><RichNodes nodes={n.children} plain {verbatim} /></span>{:else if n.kind === 'spoiler'}<span class="spoiler" role="button" tabindex="0"><RichNodes nodes={n.children} {mentions} {self} {nameOf} {plain} {verbatim} /></span>{:else if n.kind === 'emote'}<img class="emote" src={mediaUrl(n.mxc, 64) ?? ''} alt={n.alt} title={n.alt} />{:else if n.tag === 'br'}<br />{:else if n.tag === 'hr'}<hr />{:else if n.tag === 'a'}<a class="link" href={n.attrs['href']} target="_blank" rel="noopener noreferrer"><RichNodes nodes={n.children} plain {verbatim} /></a>{:else}<svelte:element this={n.tag} {...n.attrs}><RichNodes nodes={n.children} {mentions} {self} {nameOf} plain={plain || n.tag === 'code' || n.tag === 'pre'} verbatim={verbatim || n.tag === 'code' || n.tag === 'pre'} /></svelte:element>{/if}{/each}
18+{#each nodes as n}{#if n.kind === 'text'}{#if verbatim}{n.text}{:else if plain}<EmojiText text={n.text} />{:else}{#each segmentInline(n.text, mentions) as p}{#if p.kind === 'mention'}<span class="mention" class:me={p.user_id === self} style:--hue={senderHue(p.user_id)} title={p.user_id}><EmojiText text={p.text === p.user_id ? (nameOf(p.user_id) ?? p.text) : p.text} /></span>{:else if p.kind === 'link'}<a class="link" href={p.href} target="_blank" rel="noopener noreferrer"><EmojiText text={p.text} /></a>{:else}<EmojiText text={p.text} />{/if}{/each}{/if}{:else if n.kind === 'mention'}<span class="mention" class:me={n.user_id === self} style:--hue={senderHue(n.user_id)} title={n.user_id}><RichNodes nodes={n.children} plain {verbatim} /></span>{:else if n.kind === 'spoiler'}<span class="spoiler" role="button" tabindex="0"><RichNodes nodes={n.children} {mentions} {self} {nameOf} {plain} {verbatim} /></span>{:else if n.kind === 'emote'}<img class="emote" src={mediaUrl(n.mxc, 64) ?? ''} alt={n.alt} title={n.alt} />{:else if n.tag === 'br'}<br />{:else if n.tag === 'hr'}<hr />{:else if n.tag === 'a'}<a class="link" href={n.attrs['href']} target="_blank" rel="noopener noreferrer"><RichNodes nodes={n.children} plain {verbatim} /></a>{:else}<svelte:element this={n.tag} {...n.attrs}><RichNodes nodes={n.children} {mentions} {self} {nameOf} plain={plain || n.tag === 'code' || n.tag === 'pre'} verbatim={verbatim || n.tag === 'code' || n.tag === 'pre'} /></svelte:element>{/if}{/each}