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 { Snippet } from 'svelte';
import { formatDate, formatDateTime } from '../format';
import { opens, tagOf, type Opener } from '../open';
import Picture from '../Picture.svelte';
import type { Source } from '../types';
import { clock } from '../view/clock.svelte';
// A quoted post, read by the
// server, as a card inside the post: its author
// (picture, name, handle), when, its text (`text`) and its own embed
// (`inner`). The card opens what `open` does (the quoted post's
// thread; a link, where it has an address); its links and mentions open
// their own.
let {
name,
handle,
avatar,
when,
open,
text,
inner
}: {
name: string;
handle: string | null;
avatar: Source | null;
when: string | null;
open: Opener | null;
text?: Snippet;
inner?: Snippet;
} = $props();
// The day alone, as Bluesky's quote says when, its time in the title: room for the name.
const local = $derived(when ? formatDate(when, clock.fixed) : null);
</script>
<div class="quote" class:openable={open !== null}>
{#if open}<svelte:element this={tagOf(open)} {...opens(open)} class="open" aria-label="Open the quoted post by {name}"></svelte:element>{/if}
<div class="content">
<p class="byline" translate="no">
<span class="who">
<span class="avatar"><Picture src={avatar} alt="" placeholder={[...name][0]?.toUpperCase() ?? '·'} /></span>
<span class="name">{name}</span>
{#if handle}<span class="handle">@{handle}</span>{/if}
</span>
{#if local && when}<span class="when"><span aria-hidden="true">·</span><time datetime={when} title={formatDateTime(when, clock.fixed) ?? when}>{local}</time></span>{/if}
</p>
{@render text?.()}
{@render inner?.()}
</div>
</div>
<style>
.quote {
position: relative;
min-width: 0;
padding: var(--hud-space-2) var(--hud-space-3);
border: var(--border-width-regular) solid var(--color-border-secondary);
border-radius: var(--border-radius-md);
background: var(--color-background-primary);
font-size: var(--font-text-sm-size);
}
.content {
display: flex;
flex-direction: column;
gap: var(--hud-space-2);
min-width: 0;
}
.content :global(.plain) {
font-size: var(--font-text-sm-size);
line-height: var(--font-text-sm-line-height);
}
.byline {
display: flex;
align-items: center;
gap: var(--hud-space-1);
min-width: 0;
margin: 0;
white-space: nowrap;
}
.who {
display: flex;
flex: 0 1 auto;
align-items: center;
gap: var(--hud-space-1);
min-width: 0;
}
.avatar {
flex: none;
width: 1.25rem;
height: 1.25rem;
border-radius: var(--border-radius-full);
background: var(--color-background-tertiary);
overflow: hidden;
font-size: 0.625rem;
font-weight: var(--font-weight-semibold);
}
/* The name is the last to be cut short: the handle gives way first. */
.name {
min-width: 0;
overflow: hidden;
font-weight: var(--font-weight-semibold);
text-overflow: ellipsis;
}
.handle,
.when {
color: var(--color-text-secondary);
}
.handle {
flex-shrink: 100;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
}
.when {
display: flex;
flex: none;
gap: var(--hud-space-1);
}
/* The whole card opens: a button behind the content, which lets clicks
through to it but on the content's own links, buttons and players. */
.open {
position: absolute;
inset: 0;
width: 100%;
padding: 0;
border: 0;
border-radius: inherit;
background: none;
cursor: pointer;
}
.openable:hover {
border-color: var(--color-border-primary);
background: var(--color-background-secondary);
}
.openable > .content {
position: relative;
pointer-events: none;
}
.openable > .content :global(:is(a, button, input, audio, video, details, summary)) {
pointer-events: auto;
}
</style>