~ 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
86 lines · 2.1 KB Raw History
<script lang="ts">
	import type { Snippet } from 'svelte';
	import JsonTree from './JsonTree.svelte';

	// One record as a card: its at-uri on top, then its fields (`known`, the
	// FieldRows its lexicon names), then those the lexicon does not name
	// (`extra`), under "Other fields"; with no lexicon, `json`, its value as a
	// JSON tree. With no `uri`, the fields alone, for a card whose frame is
	// around it already (a resolved tree's list).
	let {
		uri,
		json,
		known,
		extra
	}: { uri: string | null; json: { value: unknown } | null; known?: Snippet; extra?: Snippet } = $props();
</script>

{#snippet body()}
	{#if json}
		<JsonTree value={json.value} open={2} />
	{:else}
		<dl>{@render known?.()}</dl>
		{#if extra}
			<h4>Other fields</h4>
			<dl>{@render extra()}</dl>
		{/if}
	{/if}
{/snippet}

{#if uri !== null}
	<article class="card">
		<header>{uri}</header>
		<div class="body">{@render body()}</div>
	</article>
{:else}
	<div class="bare">{@render body()}</div>
{/if}

<style>
	.card {
		container-type: inline-size;
		border: var(--border-width-regular) solid var(--color-border-secondary);
		border-radius: var(--border-radius-lg);
		background: var(--color-background-primary);
		overflow: hidden;
	}

	.bare {
		container-type: inline-size;
		min-width: 0;
	}

	header {
		padding: var(--hud-space-2) var(--hud-space-3);
		border-bottom: var(--border-width-regular) solid var(--color-border-secondary);
		background: var(--color-background-secondary);
		color: var(--color-text-secondary);
		font-family: var(--font-mono);
		font-size: var(--font-text-xs-size);
		line-height: var(--font-text-xs-line-height);
		overflow-wrap: anywhere;
	}

	.body {
		padding: var(--hud-space-1) var(--hud-space-3) var(--hud-space-2);
	}

	.body > :global(.branch) {
		padding-top: var(--hud-space-2);
	}

	dl {
		margin: 0;
	}

	h4 {
		margin: var(--hud-space-2) 0 0;
		padding-top: var(--hud-space-2);
		border-top: var(--border-width-regular) solid var(--color-border-primary);
		color: var(--color-text-tertiary);
		font-size: var(--font-text-xs-size);
		font-weight: var(--font-weight-semibold);
		letter-spacing: 0.04em;
		text-transform: uppercase;
	}
</style>