~ 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
136 lines · 2.9 KB Raw History
<script lang="ts">
	import { Picture } from '@hud/renderer';
	import AppIcon from '../atoms/AppIcon.svelte';
	import type { IconName } from '../icons';

	/**
	 * A row the launcher (and the palette) opens: its picture, or its app's
	 * icon (else its kind's), what it is and its NSID under it, and what is said after it (a count,
	 * or `open` when it is on the strip already). `active` is
	 * the row Enter picks.
	 */
	let {
		text,
		sub = null,
		icon = null,
		domain = null,
		picture,
		tag = null,
		open = false,
		active = false,
		onpick,
		onhover
	}: {
		text: string;
		sub?: string | null;
		icon?: IconName | null;
		/** The app's domain, whose favicon stands before the kind's icon. */
		domain?: string | null;
		/** A picture in place of the icon: its URL, or null for its initial. */
		picture?: string | null;
		tag?: { text: string; kind: 'count' } | null;
		open?: boolean;
		active?: boolean;
		onpick: () => void;
		onhover?: () => void;
	} = $props();
</script>

<button type="button" class="row" class:active role="option" aria-selected={active} onclick={onpick} onmousemove={onhover}>
	{#if picture !== undefined}
		<span class="mark"><Picture src={picture} alt="" placeholder={[...text][0]?.toUpperCase() ?? '·'} /></span>
	{:else if icon}
		<span class="mark"><AppIcon {domain} fallback={icon} /></span>
	{/if}
	<span class="label">
		<span class="text">{text}</span>
		{#if sub}<span class="sub">{sub}</span>{/if}
	</span>
	{#if open}<span class="open">Open</span>{/if}
	{#if tag}<span class="tag {tag.kind}">{tag.text}</span>{/if}
</button>

<style>
	.row {
		display: flex;
		align-items: center;
		gap: var(--space-2);
		width: 100%;
		padding: var(--space-1) var(--space-2);
		border: 0;
		border-radius: var(--radius-md);
		background: none;
		color: var(--fg);
		font: inherit;
		font-size: var(--text-sm);
		text-align: left;
		cursor: pointer;
	}

	.row:hover {
		background: var(--hover);
	}

	.row.active {
		background: var(--accent-soft);
	}

	.mark {
		display: grid;
		flex: none;
		place-items: center;
		width: var(--avatar);
		height: var(--avatar);
		border-radius: var(--radius-sm);
		background: var(--soft);
		color: var(--mute);
		overflow: hidden;
		font-size: var(--text-2xs);
		font-weight: var(--weight-semibold);
	}

	.label {
		display: flex;
		flex: 1;
		flex-direction: column;
		min-width: 0;
		line-height: var(--leading-tight);
	}

	.text,
	.sub {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.sub {
		font-family: var(--font-mono);
		font-size: var(--text-xs);
	}

	.sub {
		color: var(--mute);
	}

	.open {
		flex: none;
		color: var(--accent);
		font-size: var(--text-xs);
	}

	.tag {
		flex: none;
		padding: 0 var(--space-1-5);
		border: var(--border);
		border-radius: var(--radius-full);
		color: var(--mute);
		font-size: var(--text-2xs);
		line-height: 18px;
	}

	.tag.count {
		border: 0;
		font-variant-numeric: tabular-nums;
	}
</style>