~ 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
117 lines · 3.0 KB Raw History
<script lang="ts">
	import { Picture, type PlayerHost } from '@hud/renderer';

	// What plays, at the foot of the view while one moves about in it (an
	// artist's account, a record, back): its art, title and artist, play and
	// pause, the next track, a thin line of how far it is, and close, which
	// stops it.
	let { player }: { player: PlayerHost } = $props();

	const track = $derived(player.track);
	const progress = $derived(player.duration > 0 ? Math.min(player.time / player.duration, 1) : 0);
</script>

{#snippet icon(path: string)}
	<svg viewBox="0 0 24 24" aria-hidden="true"><path d={path} fill-rule="evenodd" /></svg>
{/snippet}

{#if track}
	<div class="now" role="region" aria-label="Now playing">
		<span class="art"><Picture src={track.art} alt="" placeholder="♪" /></span>
		<span class="words">
			<span class="title">{track.title || 'Untitled'}</span>
			{#if track.subtitle}<span class="artist">{track.subtitle}</span>{/if}
		</span>
		<button type="button" class="control" aria-label={player.paused ? 'Play' : 'Pause'} onclick={() => player.toggle()}>
			{@render icon(player.paused ? 'M7 4v16l13-8z' : 'M6 4h4v16H6zM14 4h4v16h-4z')}
		</button>
		<button type="button" class="control" aria-label="Next" onclick={() => player.next()}>{@render icon('M16 5h2v14h-2zM4 5v14l11-7z')}</button>
		<button type="button" class="control" aria-label="Stop and close" onclick={() => player.clear()}>
			{@render icon('M5.3 6.7l1.4-1.4L12 10.6l5.3-5.3 1.4 1.4-5.3 5.3 5.3 5.3-1.4 1.4-5.3-5.3-5.3 5.3-1.4-1.4 5.3-5.3z')}
		</button>
		<span class="progress" style:--played={progress} aria-hidden="true"></span>
	</div>
{/if}

<style>
	.now {
		position: sticky;
		bottom: var(--hud-space-2);
		z-index: 1;
		display: flex;
		align-items: center;
		gap: var(--hud-space-2);
		padding: var(--hud-space-2);
		border: var(--border-width-regular) solid var(--color-border-secondary);
		border-radius: var(--border-radius-lg);
		background: var(--color-background-secondary);
		overflow: hidden;
	}

	.art {
		flex: none;
		width: 2rem;
		height: 2rem;
		border-radius: var(--border-radius-sm);
		overflow: hidden;
	}

	.words {
		display: flex;
		flex: 1;
		flex-direction: column;
		min-width: 0;
	}

	.title,
	.artist {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.title {
		font-size: var(--font-text-sm-size);
		font-weight: var(--font-weight-semibold);
	}

	.artist {
		color: var(--color-text-secondary);
		font-size: var(--font-text-xs-size);
	}

	.control {
		display: grid;
		flex: none;
		place-items: center;
		width: 2rem;
		height: 2rem;
		padding: 0;
		border: 0;
		border-radius: var(--border-radius-full);
		background: none;
		color: var(--color-text-primary);
		cursor: pointer;
	}

	.control:hover {
		background: var(--color-background-tertiary);
	}

	svg {
		width: 1.125rem;
		height: 1.125rem;
		fill: currentColor;
	}

	.progress {
		position: absolute;
		right: 0;
		bottom: 0;
		left: 0;
		height: 2px;
		background: var(--color-text-info);
		transform: scaleX(var(--played));
		transform-origin: left;
	}
</style>