atagen

malice

public
Star0
Watch0
787cdbbf0721a1b004712020969dadaa42f35e32
2
ssh://brewery@pls.lobotomise.me:33/atagen/malice.git

Blame: web/src/lib/MessageText.svelte

df3c0f2b3da4atagen2026-10-22 13:07 UTC1
<script lang="ts">
df3c0f2b3da4atagen2026-10-22 13:07 UTC2
  import EmojiText from './EmojiText.svelte';
705b1e1062c2atagen2026-10-23 09:05 UTC3
  import { parseCode } from './code';
705b1e1062c2atagen2026-10-23 09:05 UTC4
  import { segmentInline } from './inline';
705b1e1062c2atagen2026-10-23 09:05 UTC5
  import type { Mention } from './mentions';
df3c0f2b3da4atagen2026-10-22 13:07 UTC6
df3c0f2b3da4atagen2026-10-22 13:07 UTC7
  export let text: string;
df3c0f2b3da4atagen2026-10-22 13:07 UTC8
  export let jumbo = false;
705b1e1062c2atagen2026-10-23 09:05 UTC9
  export let mentions: Mention[] = [];
705b1e1062c2atagen2026-10-23 09:05 UTC10
  export let self: string | null = null;
787cdbbf0721atagen2026-10-24 06:50 UTC11
  export let nameOf: (userId: string) => string | null = () => null;
df3c0f2b3da4atagen2026-10-22 13:07 UTC12
df3c0f2b3da4atagen2026-10-22 13:07 UTC13
  $: segments = parseCode(text);
705b1e1062c2atagen2026-10-23 09:05 UTC14
  $: pieces = segments.map((s) => (s.kind === 'text' ? segmentInline(s.text, mentions) : []));
705b1e1062c2atagen2026-10-23 09:05 UTC15
  $: single = segments.length === 1 && pieces[0].length === 1;
df3c0f2b3da4atagen2026-10-22 13:07 UTC16
</script>
df3c0f2b3da4atagen2026-10-22 13:07 UTC17
787cdbbf0721atagen2026-10-24 06:50 UTC18
{#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">{p.text}</a>{:else}<EmojiText text={p.text} jumbo={jumbo && single} />{/if}{/each}{/if}{/each}
df3c0f2b3da4atagen2026-10-22 13:07 UTC19
df3c0f2b3da4atagen2026-10-22 13:07 UTC20
<style>
df3c0f2b3da4atagen2026-10-22 13:07 UTC21
  code {
df3c0f2b3da4atagen2026-10-22 13:07 UTC22
    font-family: ui-monospace, 'JetBrains Mono', 'Fira Code', Menlo, monospace;
df3c0f2b3da4atagen2026-10-22 13:07 UTC23
    font-size: 0.9em;
df3c0f2b3da4atagen2026-10-22 13:07 UTC24
  }
df3c0f2b3da4atagen2026-10-22 13:07 UTC25
  .inline {
df3c0f2b3da4atagen2026-10-22 13:07 UTC26
    padding: 1px 5px;
df3c0f2b3da4atagen2026-10-22 13:07 UTC27
    border-radius: 4px;
df3c0f2b3da4atagen2026-10-22 13:07 UTC28
    background: var(--bg-soft);
df3c0f2b3da4atagen2026-10-22 13:07 UTC29
    border: 1px solid var(--border);
df3c0f2b3da4atagen2026-10-22 13:07 UTC30
  }
df3c0f2b3da4atagen2026-10-22 13:07 UTC31
  .block {
df3c0f2b3da4atagen2026-10-22 13:07 UTC32
    margin: 4px 0;
df3c0f2b3da4atagen2026-10-22 13:07 UTC33
    padding: 8px 10px;
df3c0f2b3da4atagen2026-10-22 13:07 UTC34
    border-radius: 6px;
df3c0f2b3da4atagen2026-10-22 13:07 UTC35
    background: var(--bg-soft);
df3c0f2b3da4atagen2026-10-22 13:07 UTC36
    border: 1px solid var(--border);
df3c0f2b3da4atagen2026-10-22 13:07 UTC37
    overflow-x: auto;
df3c0f2b3da4atagen2026-10-22 13:07 UTC38
    white-space: pre;
df3c0f2b3da4atagen2026-10-22 13:07 UTC39
    line-height: 1.4;
df3c0f2b3da4atagen2026-10-22 13:07 UTC40
  }
705b1e1062c2atagen2026-10-23 09:05 UTC41
  .mention {
705b1e1062c2atagen2026-10-23 09:05 UTC42
    padding: 0 4px;
705b1e1062c2atagen2026-10-23 09:05 UTC43
    border-radius: 4px;
705b1e1062c2atagen2026-10-23 09:05 UTC44
    font-weight: 600;
705b1e1062c2atagen2026-10-23 09:05 UTC45
    color: var(--accent);
705b1e1062c2atagen2026-10-23 09:05 UTC46
    background: color-mix(in srgb, var(--accent) 18%, transparent);
705b1e1062c2atagen2026-10-23 09:05 UTC47
  }
705b1e1062c2atagen2026-10-23 09:05 UTC48
  .mention.me {
705b1e1062c2atagen2026-10-23 09:05 UTC49
    color: var(--warn-text);
705b1e1062c2atagen2026-10-23 09:05 UTC50
    background: color-mix(in srgb, var(--warn) 28%, transparent);
705b1e1062c2atagen2026-10-23 09:05 UTC51
  }
705b1e1062c2atagen2026-10-23 09:05 UTC52
  .link { color: var(--accent); overflow-wrap: anywhere; }
705b1e1062c2atagen2026-10-23 09:05 UTC53
  .link:hover { text-decoration: underline; }
df3c0f2b3da4atagen2026-10-22 13:07 UTC54
</style>