atagen

malice

public
Star0
Watch0
705b1e1062c28d089cbd8a8c402d6fbf7b312a29
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;
df3c0f2b3da4atagen2026-10-22 13:07 UTC11
df3c0f2b3da4atagen2026-10-22 13:07 UTC12
  $: segments = parseCode(text);
705b1e1062c2atagen2026-10-23 09:05 UTC13
  $: pieces = segments.map((s) => (s.kind === 'text' ? segmentInline(s.text, mentions) : []));
705b1e1062c2atagen2026-10-23 09:05 UTC14
  $: single = segments.length === 1 && pieces[0].length === 1;
df3c0f2b3da4atagen2026-10-22 13:07 UTC15
</script>
df3c0f2b3da4atagen2026-10-22 13:07 UTC16
705b1e1062c2atagen2026-10-23 09:05 UTC17
{#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} /></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 UTC18
df3c0f2b3da4atagen2026-10-22 13:07 UTC19
<style>
df3c0f2b3da4atagen2026-10-22 13:07 UTC20
  code {
df3c0f2b3da4atagen2026-10-22 13:07 UTC21
    font-family: ui-monospace, 'JetBrains Mono', 'Fira Code', Menlo, monospace;
df3c0f2b3da4atagen2026-10-22 13:07 UTC22
    font-size: 0.9em;
df3c0f2b3da4atagen2026-10-22 13:07 UTC23
  }
df3c0f2b3da4atagen2026-10-22 13:07 UTC24
  .inline {
df3c0f2b3da4atagen2026-10-22 13:07 UTC25
    padding: 1px 5px;
df3c0f2b3da4atagen2026-10-22 13:07 UTC26
    border-radius: 4px;
df3c0f2b3da4atagen2026-10-22 13:07 UTC27
    background: var(--bg-soft);
df3c0f2b3da4atagen2026-10-22 13:07 UTC28
    border: 1px solid var(--border);
df3c0f2b3da4atagen2026-10-22 13:07 UTC29
  }
df3c0f2b3da4atagen2026-10-22 13:07 UTC30
  .block {
df3c0f2b3da4atagen2026-10-22 13:07 UTC31
    margin: 4px 0;
df3c0f2b3da4atagen2026-10-22 13:07 UTC32
    padding: 8px 10px;
df3c0f2b3da4atagen2026-10-22 13:07 UTC33
    border-radius: 6px;
df3c0f2b3da4atagen2026-10-22 13:07 UTC34
    background: var(--bg-soft);
df3c0f2b3da4atagen2026-10-22 13:07 UTC35
    border: 1px solid var(--border);
df3c0f2b3da4atagen2026-10-22 13:07 UTC36
    overflow-x: auto;
df3c0f2b3da4atagen2026-10-22 13:07 UTC37
    white-space: pre;
df3c0f2b3da4atagen2026-10-22 13:07 UTC38
    line-height: 1.4;
df3c0f2b3da4atagen2026-10-22 13:07 UTC39
  }
705b1e1062c2atagen2026-10-23 09:05 UTC40
  .mention {
705b1e1062c2atagen2026-10-23 09:05 UTC41
    padding: 0 4px;
705b1e1062c2atagen2026-10-23 09:05 UTC42
    border-radius: 4px;
705b1e1062c2atagen2026-10-23 09:05 UTC43
    font-weight: 600;
705b1e1062c2atagen2026-10-23 09:05 UTC44
    color: var(--accent);
705b1e1062c2atagen2026-10-23 09:05 UTC45
    background: color-mix(in srgb, var(--accent) 18%, transparent);
705b1e1062c2atagen2026-10-23 09:05 UTC46
  }
705b1e1062c2atagen2026-10-23 09:05 UTC47
  .mention.me {
705b1e1062c2atagen2026-10-23 09:05 UTC48
    color: var(--warn-text);
705b1e1062c2atagen2026-10-23 09:05 UTC49
    background: color-mix(in srgb, var(--warn) 28%, transparent);
705b1e1062c2atagen2026-10-23 09:05 UTC50
  }
705b1e1062c2atagen2026-10-23 09:05 UTC51
  .link { color: var(--accent); overflow-wrap: anywhere; }
705b1e1062c2atagen2026-10-23 09:05 UTC52
  .link:hover { text-decoration: underline; }
df3c0f2b3da4atagen2026-10-22 13:07 UTC53
</style>