chadtmiller.com/hud
A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts
place.hud.hudkit 0.4.0 Latest 5 packages
0
0
<script lang="ts" generics="T extends string">
import Icon from '../atoms/Icon.svelte';
import type { IconName } from '../icons';
/**
* A choice of one of a few, side by side, the one chosen pressed: each
* its word, and its icon where it has one. `label` names the choice.
* Tabs (`tabs`) are a tab list, each tab its panel's; else buttons.
* `wide`, it fills its row, each choice an equal share, a finger's height.
*/
let {
value,
options,
label,
tabs = false,
wide = false,
onchange
}: {
value: T;
options: { value: T; label: string; icon?: IconName; title?: string }[];
label: string;
tabs?: boolean;
wide?: boolean;
onchange: (value: T) => void;
} = $props();
</script>
<div class="segmented" class:wide role={tabs ? 'tablist' : 'group'} aria-label={label}>
{#each options as option (option.value)}
{@const chosen = option.value === value}
<button
type="button"
class:chosen
role={tabs ? 'tab' : undefined}
aria-selected={tabs ? chosen : undefined}
aria-pressed={tabs ? undefined : chosen}
title={option.title}
onclick={() => onchange(option.value)}
>
{#if option.icon}<Icon name={option.icon} />{/if}{option.label}
</button>
{/each}
</div>
<style>
.segmented {
display: inline-flex;
flex: none;
gap: var(--space-0-5);
padding: var(--space-0-5);
border: var(--border);
border-radius: var(--radius-md);
background: var(--soft);
}
.wide {
display: flex;
width: 100%;
height: var(--control);
}
.wide button {
flex: 1;
justify-content: center;
height: 100%;
}
button {
display: inline-flex;
align-items: center;
gap: var(--space-1);
height: calc(var(--control-sm) - var(--space-2));
padding: 0 var(--space-2);
border: 0;
border-radius: var(--radius-sm);
background: none;
color: var(--mute);
font: var(--weight-medium) var(--text-xs) var(--font-sans);
white-space: nowrap;
cursor: pointer;
}
button:hover {
color: var(--fg);
}
button.chosen {
background: var(--bg);
color: var(--fg);
box-shadow: 0 0 0 1px var(--line);
}
</style>