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

	// Markdown's look, as GitHub draws a README or a pull's body: headings,
	// paragraphs, lists and task lists, quotes, code, rules, tables,
	// footnotes, details, pictures no wider than they were made (a
	// picture's alt text in its place where none is drawn), in the app's type.
	// A resolved tree's `Blocks` draw their elements in it; `element` is the box, for what listens to its clicks.
	let { element = $bindable(), children }: { element?: HTMLElement; children: Snippet } = $props();
</script>

<div class="markdown" bind:this={element}>{@render children()}</div>

<style>
	.markdown {
		min-width: 0;
		overflow-wrap: anywhere;
	}

	.markdown > :global(:first-child) {
		margin-top: 0;
	}

	.markdown > :global(:last-child) {
		margin-bottom: 0;
	}

	.markdown :global(:is(p, ul, ol, blockquote, pre, table, details)) {
		margin: 0 0 1em;
	}

	.markdown :global(:is(h1, h2, h3, h4, h5, h6)) {
		margin: 1.5em 0 0.5em;
		font-size: var(--font-heading-sm-size);
		line-height: var(--font-heading-sm-line-height);
	}

	.markdown :global(h1) {
		font-size: var(--font-heading-lg-size);
	}

	.markdown :global(h2) {
		font-size: var(--font-heading-md-size);
	}

	.markdown :global(a) {
		color: var(--color-text-info);
		text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
		text-underline-offset: 0.15em;
	}

	.markdown :global(:is(ul, ol)) {
		padding-left: 1.5em;
	}

	.markdown :global(li + li) {
		margin-top: 0.25em;
	}

	.markdown :global(li > :is(ul, ol)) {
		margin: 0.25em 0 0;
	}

	.markdown :global(blockquote) {
		padding-left: var(--hud-space-3);
		border-left: 3px solid var(--color-border-primary);
		color: var(--color-text-secondary);
	}

	.markdown :global(code) {
		padding: 0.1em 0.3em;
		border-radius: var(--border-radius-xs);
		background: var(--color-background-secondary);
		font-family: var(--font-mono);
		font-size: 0.875em;
	}

	.markdown :global(pre) {
		padding: var(--hud-space-3);
		border-radius: var(--border-radius-md);
		background: var(--color-background-secondary);
		overflow-x: auto;
		overflow-wrap: normal;
		line-height: 1.5;
	}

	.markdown :global(pre code) {
		padding: 0;
		background: none;
		white-space: pre;
	}

	.markdown :global(hr) {
		margin: 1.5em 0;
		border: 0;
		border-top: var(--border-width-regular) solid var(--color-border-secondary);
	}

	.markdown :global(table) {
		display: block;
		max-width: 100%;
		overflow-x: auto;
		border-collapse: collapse;
		font-size: 0.9em;
		overflow-wrap: normal;
	}

	.markdown :global(:is(th, td)) {
		padding: 0.35em 0.75em;
		border: var(--border-width-regular) solid var(--color-border-secondary);
		text-align: start;
	}

	.markdown :global(th) {
		background: var(--color-background-secondary);
		font-weight: var(--font-weight-semibold);
	}

	.markdown :global(li:has(> input[type='checkbox'])) {
		list-style: none;
		margin-left: -1.25em;
	}

	.markdown :global(input[type='checkbox']) {
		margin: 0 0.4em 0 0;
		vertical-align: -0.1em;
	}

	.markdown :global(.image-alt) {
		color: var(--color-text-tertiary);
		font-style: italic;
	}

	/* As wide as it was made, its place, or its shape at 60vh tall, whichever is least, so text shows beside it:
	   never letterboxed, and inside a hairline, so a white screenshot keeps its edge on a white tile. */
	.markdown :global(figure.image) {
		box-sizing: border-box;
		width: min(100%, var(--width, 100%), calc(60vh * var(--ratio)));
		border: var(--border-width-regular) solid var(--color-border-secondary);
		margin: 0 0 1em;
		aspect-ratio: var(--ratio);
		border-radius: var(--border-radius-md);
		overflow: hidden;
	}

	.markdown :global(:is(del, s)) {
		color: var(--color-text-secondary);
	}

	.markdown :global(.footnotes) {
		margin-top: 1.5em;
		padding-top: 0.75em;
		border-top: var(--border-width-regular) solid var(--color-border-secondary);
		color: var(--color-text-secondary);
		font-size: 0.9em;
	}

	.markdown :global(summary) {
		cursor: pointer;
	}

	.markdown :global(details[open] > summary) {
		margin-bottom: 0.5em;
	}

	.markdown :global(details > :last-child) {
		margin-bottom: 0;
	}

	.markdown :global(.sr-only) {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip-path: inset(50%);
		white-space: nowrap;
	}
</style>