~ 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
77 lines · 2.3 KB Raw History
<script lang="ts">
	import Picture from '../Picture.svelte';
	import { follow } from './context';

	// A post's video, shaped by its aspect ratio before it loads: the
	// browser's own player, loading nothing until it is played, `poster` its
	// picture. It plays Bluesky's HLS (`hls`) where the browser plays HLS
	// itself, else the server's stream (`src`). With neither, the poster and
	// a link to watch it on Bluesky (`watch`).
	let {
		src,
		hls,
		poster,
		ratio,
		alt,
		watch,
		onopenlink
	}: { src: string | null; hls: string | null; poster: string | null; ratio: number; alt: string; watch: string | null; onopenlink?: (url: string) => void } = $props();
</script>

<div class="frame" style:--ratio={ratio}>
	{#if hls}
		<!-- svelte-ignore a11y_media_has_caption (Bluesky's videos carry no caption track HUD can reach) -->
		<video controls playsinline preload="none" poster={poster ?? undefined} aria-label={alt}>
			<source src={hls} type="application/vnd.apple.mpegurl" />
			{#if src}<source {src} />{/if}
		</video>
	{:else if src}
		<!-- svelte-ignore a11y_media_has_caption (Bluesky's videos carry no caption track HUD can reach) -->
		<video controls playsinline preload="none" poster={poster ?? undefined} {src} aria-label={alt}></video>
	{:else}
		<Picture src={poster} {alt} placeholder="Video" />
		{#if watch}
			<a class="watch" href={watch} target="_blank" rel="noopener noreferrer" onclick={(event) => follow({ onopenlink }, event, watch)}>▶ Play on Bluesky</a>
		{/if}
	{/if}
</div>

<style>
	/* As tall as a screenful at most, and centred where its column is wider. */
	.frame {
		position: relative;
		width: min(100%, calc(min(28rem, 70vh) * var(--ratio)));
		margin-inline: auto;
		aspect-ratio: var(--ratio);
		overflow: hidden;
		border-radius: var(--border-radius-md);
		background: #000;
	}

	video {
		display: block;
		width: 100%;
		height: 100%;
		object-fit: contain;
		background: #000;
	}

	.watch {
		position: absolute;
		left: 50%;
		top: 50%;
		padding: var(--hud-space-2) var(--hud-space-3);
		border-radius: var(--border-radius-full);
		background: rgb(0 0 0 / 0.7);
		color: #fff;
		font-size: var(--font-text-sm-size);
		font-weight: var(--font-weight-semibold);
		text-decoration: none;
		transform: translate(-50%, -50%);
		white-space: nowrap;
	}

	.watch:hover {
		background: rgb(0 0 0 / 0.85);
	}
</style>