~ 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
137 lines · 3.9 KB Raw History
<script lang="ts">
	import { onDestroy, onMount } from 'svelte';
	import LoginDialog from './lib/organisms/LoginDialog.svelte';
	import LandingPage from './lib/templates/LandingPage.svelte';
	import { watchScheme, type Scheme } from './lib/theme';
	import { signUp, XrpcError } from './lib/xrpc';

	// Signed out: what HUD is, with Sign in, which opens the sign-in
	// dialog, and Create an account, which goes to the sign-up PDS's page
	// as the dialog's Create one does. An address with `?signin` opens the
	// dialog at once, so a link can lead straight to it.

	let open = $state(false);
	let creating = $state(false);
	let problem = $state('');
	/** The picture of the workspace in the scheme the page is drawn in. */
	let scheme = $state<Scheme>('light');
	onDestroy(watchScheme((seen) => (scheme = seen)));

	onMount(() => {
		if (new URLSearchParams(location.search).has('signin')) open = true;
	});

	/** Closed, the address loses its `?signin`, so a reload shows the page. */
	function close() {
		open = false;
		const url = new URL(location.href);
		if (!url.searchParams.has('signin')) return;
		url.searchParams.delete('signin');
		history.replaceState(history.state, '', url);
	}

	async function create() {
		if (creating) return;
		creating = true;
		problem = '';
		try {
			location.assign(await signUp());
		} catch (error) {
			problem = error instanceof XrpcError ? error.message : 'Creating an account did not work. Try again.';
			creating = false;
		}
	}
</script>

<LandingPage>
	{#snippet actions()}
		<button type="button" class="btn" onclick={() => (open = true)}>Sign in</button>
	{/snippet}
	{#snippet hero()}
		<h1>Your Atmosphere, all in one place</h1>
		<p class="lead">Feeds, posts, galleries and playlists from every atproto app, in columns you arrange.</p>
		<div class="start">
			<button type="button" class="btn primary" onclick={() => (open = true)}>Sign in</button>
			<button type="button" class="btn" disabled={creating} aria-busy={creating} onclick={() => void create()}>{creating ? 'Opening…' : 'Create an account'}</button>
		</div>
		{#if problem}<p class="problem" role="alert">{problem}</p>{/if}
	{/snippet}
	{#snippet picture()}
		<!-- Every theme in turn; still, in the page's scheme, for those who ask for less motion. -->
		<picture>
			<source media="(prefers-reduced-motion: reduce)" srcset={`/workspace/hero/workspace-${scheme}.webp`} />
			<img
				class="shot"
				src="/workspace/hero/workspace-themes.webp"
				alt="HUD's workspace in each of its themes in turn: a Grain gallery of mountains, a Bluesky post with a profile under it, and a list of knotless repositories, in columns side by side"
				width="2048"
				height="1280"
				decoding="async"
				fetchpriority="high"
			/>
		</picture>
	{/snippet}
	{#snippet foot()}
		<nav class="links" aria-label="About HUD">
			<a href="/terms">Terms</a>
			<a href="/privacy">Privacy</a>
			<a href="/guidelines">Guidelines</a>
			<a href="https://knotless.dev/chadtmiller.com/hud">Source</a>
		</nav>
	{/snippet}
	{#snippet overlays()}
		{#if open}<LoginDialog onclose={close} />{/if}
	{/snippet}
</LandingPage>

<style>
	h1 {
		max-width: var(--hero-width);
		font-size: var(--text-display);
		line-height: var(--leading-tight);
	}

	.lead {
		max-width: var(--hero-width);
		margin-top: var(--space-4);
		color: var(--mute);
		font-size: var(--text-lg);
	}

	.start {
		display: flex;
		flex-wrap: wrap;
		gap: var(--space-2);
		margin-top: var(--space-6);
	}

	.problem {
		margin-top: var(--space-2);
	}

	.links {
		display: flex;
		flex-wrap: wrap;
		gap: var(--space-2) var(--space-5);
		font-size: var(--text-sm);
	}

	.links a {
		color: var(--mute);
		text-decoration: underline;
		text-decoration-color: var(--link-line);
		text-underline-offset: var(--underline-offset);
	}

	.links a:hover {
		color: var(--fg);
	}

	.shot {
		display: block;
		width: 100%;
		height: auto;
		border: var(--border);
		border-radius: var(--radius-lg);
	}
</style>