~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/hud

A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts

0
0
106 lines · 2.5 KB Raw History
<script lang="ts">
	import { opens, tagOf, type Opener } from '../open';
	import Picture from '../Picture.svelte';
	import type { Source } from '../types';

	// A small card for something quoted that is not a post: its picture
	// (`src`, read already), name, who made it and a count; it opens what it
	// names when the app can (a link, where it has an address). `compact`:
	// one line of name and at-uri, as for a raw quote.
	let {
		src,
		title,
		byline,
		detail,
		open,
		compact = false
	}: {
		src: Source | null;
		title: string;
		byline: string;
		detail: string | null;
		open: Opener | null;
		compact?: boolean;
	} = $props();
</script>

{#snippet body()}
	{#if !compact}<span class="avatar"><Picture {src} alt="" placeholder={[...title][0]?.toUpperCase() ?? '·'} /></span>{/if}
	<span class="text">
		<span class="title">{title}</span>
		<span class="byline">{byline}</span>
		{#if detail}<span class="detail">{detail}</span>{/if}
	</span>
{/snippet}

{#if open}
	<svelte:element this={tagOf(open)} {...opens(open)} class="card" class:compact>{@render body()}</svelte:element>
{:else}
	<div class="card" class:compact>{@render body()}</div>
{/if}

<style>
	.card {
		display: flex;
		align-items: center;
		gap: var(--hud-space-3);
		width: 100%;
		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);
		color: var(--color-text-primary);
		font: inherit;
		text-align: start;
	}

	:is(a, button).card {
		cursor: pointer;
	}

	/* A link: sized as the button is, no line of a link's under its words. */
	a.card {
		box-sizing: border-box;
		text-decoration: none;
	}

	:is(a, button).card:hover {
		border-color: var(--color-border-primary);
		background: var(--color-background-secondary);
	}

	.avatar {
		flex: none;
		width: 2.75rem;
		height: 2.75rem;
		border-radius: var(--border-radius-md);
		background: var(--color-background-tertiary);
		overflow: hidden;
		font-weight: var(--font-weight-semibold);
	}

	.text {
		display: flex;
		flex-direction: column;
		min-width: 0;
		line-height: 1.35;
	}

	.title {
		font-size: var(--font-text-sm-size);
		font-weight: var(--font-weight-semibold);
		overflow-wrap: anywhere;
	}

	.byline,
	.detail {
		color: var(--color-text-secondary);
		font-size: var(--font-text-xs-size);
		overflow-wrap: anywhere;
	}

	.compact .byline {
		color: var(--color-text-tertiary);
		font-family: var(--font-mono);
	}
</style>