chadtmiller.com/hud
A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts
place.hud.hudkit 0.3.1 Latest 5 packages
0
0
<script lang="ts">
import type { Opener } from './open';
import RichRuns from './RichRuns.svelte';
import type { Run } from './richtext';
// Text as it was written, line breaks kept, cut to `lines` lines (four
// unless said) with a "more" that shows the rest, when there is more
// (`open`, bindable, to keep it shown when drawn again).
// With `runs`, it is those runs, cut already (the server's tree's), its
// links opened through `onopenlink`, its mentions through `onopenactor`.
let {
text = '',
runs,
mono = false,
lines = 4,
open = $bindable(false),
onopenlink,
onopenactor
}: {
text?: string;
runs?: Run[];
mono?: boolean;
lines?: number;
open?: boolean;
onopenlink?: (url: string) => void;
onopenactor?: (actor: string) => Opener;
} = $props();
let element: HTMLElement | undefined = $state();
let overflows = $state(false);
$effect(() => {
if (!element || open) return;
const node = element;
const measure = () => (overflows = node.scrollHeight > node.clientHeight + 1);
measure();
const observer = new ResizeObserver(measure);
observer.observe(node);
return () => observer.disconnect();
});
</script>
<span class="text" class:clamp={!open} class:mono style:--lines={lines} bind:this={element}
>{#if runs}<RichRuns {runs} {onopenlink} {onopenactor} />{:else}{text}{/if}</span
>
{#if overflows && !open}
<button type="button" class="more" onclick={() => (open = true)}>more</button>
{/if}
<style>
.text {
display: block;
white-space: pre-wrap;
overflow-wrap: anywhere;
}
.clamp {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: var(--lines);
line-clamp: var(--lines);
overflow: hidden;
}
.mono {
font-family: var(--font-mono);
font-size: 0.92em;
}
.more {
padding: 0;
border: 0;
background: none;
color: var(--color-text-info);
font: inherit;
font-size: var(--font-text-sm-size);
cursor: pointer;
}
.more:hover {
text-decoration: underline;
}
</style>