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

	// Something that reads as a link but goes somewhere in the view, such as
	// another record or an account: a button, as it opens no page; with
	// `href`, the address of that page, a link to it, a click still going to
	// `onclick` unless the browser follows it itself (a new tab). `strong`,
	// a link of its own (a name), is heavier than the text around it;
	// `translate: "no"`, an identifier (a mention), is kept from a page's
	// translation (../translate.ts).
	let {
		onclick,
		href,
		title,
		mono = false,
		strong = false,
		translate,
		children
	}: { onclick: () => void; href?: string; title?: string; mono?: boolean; strong?: boolean; translate?: 'no'; children: Snippet } = $props();
</script>

{#if href === undefined}
	<button type="button" class="link" class:mono class:strong {onclick} {title} {translate}>{@render children()}</button>
{:else}
	<a class="link" class:mono class:strong {href} onclick={clickOpen(onclick)} {title} {translate}>{@render children()}</a>
{/if}

<style>
	.link {
		display: inline;
		padding: 0;
		border: 0;
		background: none;
		color: var(--color-text-info);
		font: inherit;
		text-align: start;
		text-decoration: none;
		text-underline-offset: 0.15em;
		overflow-wrap: anywhere;
		cursor: pointer;
	}

	/* A button is one box in its line, inline or not: as a link, the same box, so its words wrap and space as the button's did. */
	a.link {
		display: inline-block;
	}

	/* Its colour says it is a link; a line under it says where a pointer is. */
	.link:hover,
	.link:focus-visible {
		text-decoration: underline;
	}

	.strong {
		font-weight: var(--font-weight-semibold);
	}

	.mono {
		font-family: var(--font-mono);
		font-size: 0.92em;
	}
</style>