~ 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
65 lines · 1.9 KB Raw History
<script lang="ts">
	import { Picture } from '@hud/renderer';
	import { handleText } from '../model';
	import { profile } from '../profiles.svelte';

	/**
	 * Someone's face, round, from their Bluesky profile; their initial until
	 * it comes, or when they have none. Who it is shows on hover, after
	 * `prefix` ("Added by "); `here` rings it as someone with the canvas open.
	 * Given `src` (none for null) and `name`, as a search found them, it asks
	 * for no profile: signed out, there is no one to ask as.
	 */
	let {
		did,
		handle = null,
		src,
		name: given = null,
		size,
		prefix = '',
		here = false
	}: { did: string; handle?: string | null; src?: string | null; name?: string | null; size?: 'sm' | 'md'; prefix?: string; here?: boolean } = $props();

	const found = $derived(src === undefined ? profile(did) : { did, handle, name: given, avatar: src });
	const known = $derived(found?.handle ?? handle);
	const name = $derived(found?.name ?? known ?? did.replace(/^did:[a-z]+:/, ''));
	const who = $derived(`${prefix}${handleText(did, known)}`);
</script>

<span class="av {size ?? ''}" class:here title={who} role="img" aria-label={who}>
	<Picture src={found?.avatar ?? null} alt="" placeholder={[...name][0]?.toUpperCase() ?? '·'} />
</span>

<style>
	.av {
		display: inline-grid;
		place-items: center;
		flex: none;
		width: var(--avatar);
		height: var(--avatar);
		border-radius: var(--radius-full);
		background: var(--soft);
		color: var(--mute);
		overflow: hidden;
		font: var(--weight-semibold) var(--text-2xs) / var(--avatar) var(--font-sans);
	}

	.av.sm {
		width: var(--avatar-sm);
		height: var(--avatar-sm);
		line-height: var(--avatar-sm);
	}

	.av.md {
		width: var(--avatar-md);
		height: var(--avatar-md);
		font-size: var(--text-sm);
		line-height: var(--avatar-md);
	}

	.av.here {
		box-shadow:
			0 0 0 1.5px var(--bg),
			0 0 0 3px var(--success);
	}
</style>