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" module>
import type { Opener } from '../open';
/** What a click opens (a link, where it has an address); null for nothing. */
export type Open = Opener | null;
/** Why a feed item is in its feed: reposted by someone (opening them, when the app can), or pinned. */
export type FeedReason = { kind: 'repost'; name: string; open: Open } | { kind: 'pin' };
/** The posts a reply replies to, above it: its thread's root when that is
* not its parent, whether posts between them are left out (and what
* "View full thread" opens), whom the parent replied to, and the parent. */
export type FeedThread<T> = { top: T | null; gap: { open: Open } | null; repliedTo: string | null; parent: T };
</script>
<script lang="ts" generics="T">
import type { Snippet } from 'svelte';
import Glyph from '../Glyph.svelte';
import type { IconName } from '../icons';
import { opens, tagOf } from '../open';
// What a Bluesky feed item's post comes with, read by the
// server, as the Bluesky app draws it (its FeedViewPostsSlice and
// PostFeedItem): over the post, why it is in the feed (`reason`) and the
// posts it replies to (`thread`, each drawn by `post`, joined by a
// thread line down to the post); under its author, "Replied to …"
// (`replyTo`) where that context is not drawn.
let {
reason = null,
thread = null,
replyTo = null,
post
}: {
reason?: FeedReason | null;
thread?: FeedThread<T> | null;
replyTo?: { label: string; open: Open } | null;
post: Snippet<[T]>;
} = $props();
</script>
{#snippet icon(name: IconName)}
<svg viewBox="0 0 24 24" aria-hidden="true"><Glyph {name} /></svg>
{/snippet}
{#if reason?.kind === 'repost'}
{@const open = reason.open}
<p class="reason">
{@render icon('repost')}
<span class="words">
Reposted by
{#if open}<svelte:element this={tagOf(open)} {...opens(open)} class="bare name">{reason.name}</svelte:element>{:else}<span class="name">{reason.name}</span>{/if}
</span>
</p>
{:else if reason?.kind === 'pin'}
<p class="reason">{@render icon('pin')}<span class="words">Pinned</span></p>
{/if}
{#if thread}
<ul class="thread">
{#if thread.top !== null}
{@render post(thread.top)}
{/if}
{#if thread.gap}
{@const open = thread.gap.open}
<li class="gap">
{#if open}<svelte:element this={tagOf(open)} {...opens(open)} class="bare more">View full thread</svelte:element>{:else}<span class="more">…</span>{/if}
</li>
{/if}
{#if thread.repliedTo}
<li class="replied">{@render icon('repliedTo')}<span class="words">Replied to {thread.repliedTo}</span></li>
{/if}
{@render post(thread.parent)}
</ul>
{/if}
{#if replyTo}
<p class="replied">
{@render icon('repliedTo')}
{#if replyTo.open}
<svelte:element this={tagOf(replyTo.open)} {...opens(replyTo.open)} class="bare words">{replyTo.label}</svelte:element>
{:else}
<span class="words">{replyTo.label}</span>
{/if}
</p>
{/if}
<style>
.reason,
.replied {
display: flex;
align-items: center;
gap: var(--hud-space-1);
min-width: 0;
margin: 0;
color: var(--color-text-secondary);
font-size: var(--font-text-sm-size);
line-height: var(--font-text-sm-line-height);
}
.words {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
svg {
flex: none;
width: 1em;
height: 1em;
fill: none;
stroke: currentColor;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
}
/* A link's look: words that open something, underlined under the pointer; a button, or a link drawn as one. */
.bare {
display: inline-block;
padding: 0;
border: 0;
background: none;
color: inherit;
font: inherit;
text-align: start;
text-decoration: none;
cursor: pointer;
}
.bare:hover {
text-decoration: underline;
}
.name {
font-weight: var(--font-weight-semibold);
}
/* As the Bluesky app's feed: each post its author's face in a column
(the template's, 2.625rem), what it says beside it; the words here
(why it is in the feed, "View full thread", whom the parent replied
to) line up with what the posts say. */
.reason,
.thread > .replied,
.gap {
padding-left: calc(2.625rem + var(--hud-space-2));
}
/* The posts it replies to, oldest first, no less than the post itself,
a line running down the face column from under each face into the
next, the post's own last. */
.thread {
display: flex;
flex-direction: column;
min-width: 0;
margin: 0;
padding: 0;
list-style: none;
}
.thread > :global(li) {
position: relative;
}
.thread > :global(li)::before {
position: absolute;
top: 0;
bottom: 0;
left: calc(1.3125rem - 1px);
width: 2px;
background: var(--color-border-secondary);
/* Over a post's hover, which would hide it. */
z-index: 1;
content: '';
}
/* A post's stretch starts under its face (drawn a space down, its
hover's padding) and runs to just above the next face. */
.thread > :global(li.item)::before {
top: calc(var(--hud-space-2) + 2.625rem + 4px);
bottom: calc(4px - var(--hud-space-2));
}
/* The parent's, past the card's space, to the post's own face. */
.thread > :global(li.item:last-child)::before {
bottom: calc(4px - var(--hud-space-3));
}
/* Posts left out between the root and the parent: the line breaks into dots, and a link to the whole thread. */
.thread > .gap::before {
background: radial-gradient(circle, var(--color-border-primary) 1.5px, transparent 2px) center / 2px 7px repeat-y;
}
.gap {
display: flex;
align-items: center;
min-height: 2.5rem;
}
.more {
color: var(--color-text-info);
font-size: var(--font-text-sm-size);
}
</style>