~ 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
70 lines · 2.2 KB Raw History
<script lang="ts">
	// A picture's alt text offered as a photo app offers it: "ALT" in its
	// bottom-right corner, which shows the text over the picture, and hides
	// it again. Its parent is the picture's box, positioned. `shown` bound,
	// its owner keeps one of a picture's overlays open at a time (a
	// gallery's, with its ⓘ). Each button's name holds the words it shows
	// (a voice saying "ALT" finds it), and the badge is a 24px target at
	// least, the pill drawn in it as small as its word.
	let { alt, shown = $bindable(false) }: { alt: string; shown?: boolean } = $props();
</script>

{#if shown}
	<button type="button" class="text" onclick={() => (shown = false)} title="Hide ALT text"><span>{alt}</span></button>
{/if}
<!-- "ALT" is a name, never a word: translated, German's "alt" made it "OLD". -->
<button type="button" class="badge" translate="no" aria-label={shown ? 'Hide ALT text' : 'Show ALT text'} aria-expanded={shown} onclick={() => (shown = !shown)}><span>ALT</span></button>

<style>
	/* Over an ⓘ's text too (InfoBadge), so both stay at hand: a bare box
	   24px square at least, reaching a little past the pill it draws. */
	.badge {
		position: absolute;
		z-index: 1;
		right: calc(var(--hud-space-2) - 2px);
		bottom: calc(var(--hud-space-2) - 2px);
		display: grid;
		place-items: center;
		min-width: 24px;
		min-height: 24px;
		padding: 2px;
		border: 0;
		background: none;
		font: inherit;
		cursor: pointer;
	}

	.badge > span {
		padding: 1px var(--hud-space-1);
		border-radius: var(--border-radius-xs);
		background: rgb(0 0 0 / 0.7);
		color: #fff;
		font-size: var(--font-text-xs-size);
		font-weight: var(--font-weight-bold);
		letter-spacing: 0.04em;
	}

	/* The text over the whole picture, centered both ways, scrolling when
	   longer than it: the span's auto margins center it without clipping
	   its top as flex centering would. */
	.text {
		position: absolute;
		inset: 0;
		display: flex;
		overflow-y: auto;
		padding: 20px;
		border: 0;
		background: rgb(0 0 0 / 0.6);
		color: #fff;
		font: inherit;
		font-size: var(--font-text-sm-size);
		line-height: var(--font-text-sm-line-height);
		text-align: center;
		white-space: pre-wrap;
		cursor: pointer;
	}

	.text span {
		margin: auto;
	}
</style>