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 Picture from '../Picture.svelte';
import type { Source } from '../types';
import { follow } from './context';
// A link card, read by the
// server, as Bluesky draws one: the page's picture
// across the top, then its title, two lines of its description, and its
// host. The card opens the page (`href`, http or https only; without
// one, it is shown, not followed). A GIF shows as its picture, `alt`
// its words.
let {
href,
title,
description,
host,
thumb,
gif,
alt,
onopenlink
}: {
href: string | null;
title: string;
description: string | null;
host: string | null;
thumb: Source | null;
gif: boolean;
alt: string;
onopenlink?: (url: string) => void;
} = $props();
</script>
{#if gif && href}
<a class="gif" {href} target="_blank" rel="noopener noreferrer" onclick={(event) => follow({ onopenlink }, event, href)}>
<Picture src={thumb} {alt} fit="contain" />
</a>
{:else}
{#snippet body()}
{#if thumb}<span class="thumb"><Picture src={thumb} alt="" /></span>{/if}
<span class="text">
<span class="title">{title}</span>
{#if description}<span class="description">{description}</span>{/if}
{#if host}<span class="host">{host}</span>{/if}
</span>
{/snippet}
{#if href}
<a class="card" {href} target="_blank" rel="noopener noreferrer" onclick={(event) => follow({ onopenlink }, event, href)}>
{@render body()}
</a>
{:else}
<div class="card">{@render body()}</div>
{/if}
{/if}
<style>
/* No wider than the widest picture the renderer draws, and centred
where its column is wider, as a post's media all are. */
.card {
display: flex;
flex-direction: column;
max-width: 40rem;
margin-inline: auto;
overflow: hidden;
border: var(--border-width-regular) solid var(--color-border-secondary);
border-radius: var(--border-radius-md);
background: var(--color-background-primary);
color: var(--color-text-primary);
text-decoration: none;
}
a.card:hover {
border-color: var(--color-border-primary);
background: var(--color-background-secondary);
}
.thumb {
display: block;
aspect-ratio: 1.91;
border-bottom: var(--border-width-regular) solid var(--color-border-secondary);
}
.text {
display: flex;
flex-direction: column;
gap: 0.125rem;
min-width: 0;
padding: var(--hud-space-2) var(--hud-space-3);
}
.title {
font-size: var(--font-text-sm-size);
font-weight: var(--font-weight-semibold);
line-height: var(--font-text-sm-line-height);
overflow-wrap: anywhere;
}
.description {
display: -webkit-box;
overflow: hidden;
color: var(--color-text-secondary);
font-size: var(--font-text-sm-size);
line-height: var(--font-text-sm-line-height);
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
line-clamp: 2;
}
.host {
margin-top: var(--hud-space-1);
color: var(--color-text-tertiary);
font-size: var(--font-text-xs-size);
overflow-wrap: anywhere;
}
.gif {
display: block;
width: fit-content;
margin-inline: auto;
max-width: 100%;
max-height: 20rem;
overflow: hidden;
border-radius: var(--border-radius-md);
}
.gif :global(img) {
width: auto;
max-width: 100%;
height: auto;
max-height: 20rem;
}
</style>