chadtmiller.com/hud
A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts
place.hud.hudkit 0.3.1 Latest 5 packages
0
0
<script lang="ts" module>
import type { IconName } from '../icons';
/** Each role's colour (a theme token's name, less `--hud-color-`) and icon. */
const ROLES: Record<string, { tone: string; icon: IconName }> = {
'open-pull': { tone: 'open', icon: 'pull' },
'draft-pull': { tone: 'neutral', icon: 'pullDraft' },
merged: { tone: 'merged', icon: 'merge' },
'closed-pull': { tone: 'closed', icon: 'pullClosed' },
'open-issue': { tone: 'open', icon: 'issue' },
'closed-issue': { tone: 'neutral', icon: 'issueClosed' },
success: { tone: 'open', icon: 'check' },
failure: { tone: 'closed', icon: 'x' },
running: { tone: 'running', icon: 'running' },
queued: { tone: 'running', icon: 'clock' },
skipped: { tone: 'neutral', icon: 'skipped' },
neutral: { tone: 'neutral', icon: 'circle' }
};
/** Whether a word is a role this draws; any other is drawn as neutral. */
export function isRole(found: unknown): found is string {
return typeof found === 'string' && Object.hasOwn(ROLES, found);
}
export type StateStyle = 'mark' | 'text' | 'pill';
</script>
<script lang="ts">
import Glyph from '../Glyph.svelte';
// A state, as knotless's pages draw a pull's, an issue's or a check's: its
// role's icon alone (`mark`, its word its accessible name), icon and word
// (`text`), or both on the role's colour (`pill`). The tree's State
// draws it.
let { role, word, style }: { role: string; word: string; style: StateStyle } = $props();
const shown = $derived(isRole(role) ? ROLES[role] : ROLES.neutral);
</script>
<span class="state {style} {shown.tone}" title={style === 'mark' ? word : undefined}>
<svg viewBox="0 0 24 24" aria-hidden="true">
<Glyph name={shown.icon} />
</svg>
{#if style === 'mark'}
<span class="hidden">{word}</span>
{:else}
<span>{word}</span>
{/if}
</span>
<style>
.state {
display: inline-flex;
flex: none;
align-items: center;
gap: var(--hud-space-1);
color: var(--tone);
font-size: var(--font-text-sm-size);
font-weight: var(--font-weight-medium);
line-height: var(--font-text-sm-line-height);
white-space: nowrap;
}
.open {
--tone: var(--hud-color-open);
}
.merged {
--tone: var(--hud-color-merged);
}
.closed {
--tone: var(--hud-color-closed);
}
.neutral {
--tone: var(--hud-color-neutral);
}
.running {
--tone: var(--hud-color-running);
}
svg {
flex: none;
width: 1em;
height: 1em;
fill: none;
stroke: currentColor;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
}
.mark svg {
width: 1.15em;
height: 1.15em;
}
/* A page's header: the word on the role's colour. */
.pill {
padding: var(--hud-space-1) var(--hud-space-3);
border-radius: var(--border-radius-full);
background: var(--tone);
color: var(--hud-color-on-role);
}
.hidden {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
</style>