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" generics="T">
import type { Snippet } from 'svelte';
// A thread's replies as a tree (the tree's `Tree`): each item drawn by `entry` (a ThreadItem, given what
// draws under it, if anything), and under it the items `below` gives
// for its level, indented beside a thread line, and theirs; with `face`,
// the line runs down the column the faces of the posts they answer are drawn in.
let {
items,
below,
entry,
face = false
}: {
items: readonly T[];
below: (item: T, level: number) => readonly T[] | null;
entry: Snippet<[T, Snippet | undefined]>;
face?: boolean;
} = $props();
</script>
{#snippet branch(list: readonly T[], level: number)}
<ul class="tree" class:nested={level > 1} class:face>
{#each list as item, i (i)}
{@const under = below(item, level)}
{#if under && under.length > 0}
{#snippet nested()}{@render branch(under, level + 1)}{/snippet}
{@render entry(item, nested)}
{:else}
{@render entry(item, undefined)}
{/if}
{/each}
</ul>
{/snippet}
{@render branch(items, 1)}
<style>
.tree {
display: flex;
flex-direction: column;
gap: var(--hud-space-2);
min-width: 0;
margin: 0;
padding: 0;
list-style: none;
}
/* Replies: indented, beside a line that runs down from the post they
answer. */
.nested {
margin-left: var(--hud-space-4);
padding-left: var(--hud-space-2);
border-left: 2px solid var(--color-border-secondary);
}
/* Down the middle of its face column (the template's, 2.625rem). */
.nested.face {
margin-left: calc(1.3125rem - 1px);
}
</style>