# Calliope UI primitives
Shared component library for the Calliope UI. Import from `$lib/components/ui/`.
Svelte 5 runes mode, TypeScript strict, scoped styles driven by the CSS vars in
`src/routes/app.css`. No Tailwind.
Conventions shared by all primitives:
- Styling uses the global A「片场暗房」tokens in `src/routes/app.css` (`--surface`, `--border`, `--accent`, …; legacy names such as `--bg-surface` are aliases). Button renders the shared `.a-btn` classes. Never hardcode hex colors.
- All interactive primitives expose a `:focus-visible` accent ring. `app.css` also provides a global `:focus-visible` fallback for native elements.
- Motion respects `prefers-reduced-motion`: `app.css` kills animation/transition durations globally; components that need a styled static fallback (Skeleton, ProgressBar indeterminate, StatusChip pulse) handle it in their own scoped styles.
---
## Button
`import Button from '$lib/components/ui/Button.svelte';`
| Prop | Type | Default | Notes |
| ---------- | ------------------------------------------------- | ------------- | -------------------------------------------------- |
| `variant` | `'primary' \| 'secondary' \| 'ghost' \| 'danger'` | `'secondary'` | primary = `--accent` bg; danger = `--error` tinted |
| `size` | `'sm' \| 'md'` | `'md'` | sm = 30px, md = 34px min-height (shared `.a-btn`) |
| `block` | `boolean` | `false` | full container width (`.a-btn.block`) |
| `disabled` | `boolean` | `false` | reduced opacity, no pointer events |
| `loading` | `boolean` | `false` | inline spinner, disables, width stays stable |
| `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | |
| `title` | `string` | — | native tooltip |
| `onclick` | `(event: MouseEvent) => void` | — | |
| `children` | `Snippet` | required | label content |
```svelte
```
## Card
`import Card from '$lib/components/ui/Card.svelte';`
| Prop | Type | Default | Notes |
| ----------- | --------- | -------- | ---------------------------------------------------- |
| `hoverable` | `boolean` | `false` | border lightens + `translateY(-1px)` on hover |
| `title` | `string` | — | renders default header row |
| `actions` | `Snippet` | — | right side of the default header row |
| `header` | `Snippet` | — | full custom header row (overrides `title`/`actions`) |
| `children` | `Snippet` | required | body content |
| `class` | `string` | `''` | extra class on the root |
```svelte
{#snippet actions()}
{/snippet}
Body content here.
```
## StatusChip
`import StatusChip from '$lib/components/ui/StatusChip.svelte';`
| Prop | Type | Default | Notes |
| -------- | -------- | -------- | -------------------------------------- |
| `status` | `string` | required | matched case-insensitively after trim |
| `label` | `string` | — | display text; defaults to raw `status` |
Status → color mapping (unknown strings fall back to muted and show the raw string):
| Tone | Color var | Statuses |
| ------- | ------------------ | ---------------------------------------------- |
| success | `--success` | `ready`, `done`, `completed` |
| info | `--info` | `running` (dot pulses), `generating`, `queued` |
| muted | `--text-secondary` | `pending`, `idle`, `draft`, + any unknown |
| error | `--error` | `failed`, `error` |
| warning | `--warning` | `paused` |
| accent | `--accent` | `in_progress` |
```svelte
```
## ProgressBar
`import ProgressBar from '$lib/components/ui/ProgressBar.svelte';`
| Prop | Type | Default | Notes |
| --------------- | -------------- | ------- | ----------------------------------------- |
| `value` | `number` | `0` | clamped to 0–100 |
| `indeterminate` | `boolean` | `false` | sliding accent gradient, no % readout |
| `label` | `string` | — | text above the track, also the aria-label |
| `size` | `'sm' \| 'md'` | `'md'` | sm = 4px, md = 6px track |
| `tone` | `'accent' \| 'success' \| 'error'` | `'accent'` | done = success, failed = error (§5) |
| `bare` | `boolean` | `false` | track only, no label / % row |
```svelte
```
## Skeleton
`import Skeleton from '$lib/components/ui/Skeleton.svelte';`
| Prop | Type | Default | Notes |
| -------- | --------- | -------- | ------------------------------------------------------- |
| `width` | `string` | `'100%'` | any CSS length |
| `height` | `string` | `'14px'` | any CSS length |
| `circle` | `boolean` | `false` | 50% radius; defaults width to `height` when width unset |
```svelte
```
## Modal
`import Modal from '$lib/components/ui/Modal.svelte';`
| Prop | Type | Default | Notes |
| ------------- | ------------ | -------- | --------------------------------------------------------------------------- |
| `open` | `boolean` | `false` | **bindable** — use `bind:open` |
| `title` | `string` | — | wired to `aria-labelledby`; falls back to `aria-label="Dialog"` |
| `dismissible` | `boolean` | `true` | gates Esc, backdrop click, and the close button |
| `onclose` | `() => void` | — | fires once when the modal closes (any cause, incl. external `open = false`) |
| `footer` | `Snippet` | — | right-aligned action row |
| `children` | `Snippet` | required | body content |
Behavior: Esc and backdrop click close when dismissible; focus is trapped while
open; initial focus goes to the first focusable element (or the panel); focus is
restored to the invoking element on close; body scroll is locked while open;
`role="dialog" aria-modal="true"`; backdrop blur + fade, panel rises 8px.
```svelte
console.log('closed')}>
Body content.
{#snippet footer()}
{/snippet}
```
## ConfirmDialog
`import ConfirmDialog from '$lib/components/ui/ConfirmDialog.svelte';` (built on Modal)
| Prop | Type | Default | Notes |
| -------------- | ------------ | ----------- | ------------------------------------------------------------------- |
| `open` | `boolean` | `false` | **bindable** — use `bind:open` |
| `title` | `string` | required | |
| `message` | `string` | required | body copy |
| `confirmLabel` | `string` | `'Confirm'` | |
| `cancelLabel` | `string` | `'Cancel'` | |
| `danger` | `boolean` | `false` | confirm button uses the danger variant |
| `onconfirm` | `() => void` | required | fires once, after the dialog closes |
| `oncancel` | `() => void` | — | fires when closed without confirming (Esc, backdrop, cancel button) |
```svelte
console.log('kept')}
/>
```
## EmptyState
`import EmptyState from '$lib/components/ui/EmptyState.svelte';`
| Prop | Type | Default | Notes |
| -------- | --------- | -------- | -------------------------------------- |
| `title` | `string` | required | |
| `body` | `string` | — | supporting copy, max-width constrained |
| `icon` | `Snippet` | — | rendered muted above the title |
| `action` | `Snippet` | — | CTA row below the body |
```svelte
{#snippet icon()}
{/snippet}
{#snippet action()}
{/snippet}
```
## Spinner
`import Spinner from '$lib/components/ui/Spinner.svelte';`
| Prop | Type | Default | Notes |
| ------ | ---------------------- | ------- | ------------------------------- |
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | sm = 14px, md = 18px, lg = 28px |
`role="status"` with an sr-only "Loading". Colors can be overridden from a parent
via the `--spinner-track` / `--spinner-arc` CSS vars (Button uses this on
primary/danger).
```svelte
```
## Icon
`import Icon from '$lib/components/ui/Icon.svelte';`
| Prop | Type | Default | Notes |
| ------ | ---------- | -------- | --------------------------------------------------------- |
| `name` | `IconName` | required | union type from `icons.ts` — autocomplete lists all names |
| `size` | `number` | `18` | px, square |
Stroke-based inline SVG (1.5px stroke, `currentColor`), inherits text color.
`aria-hidden` — when an icon is the only content of a control, put an
`aria-label` on the control itself. Use these instead of emoji everywhere.
Icon names (`import { icons, type IconName } from '$lib/components/ui/icons';`):
- Navigation: `home`, `story`, `assets`, `script`, `video`, `queue`, `settings`, `playground`
- Actions: `plus`, `trash`, `edit`, `retry`, `close`, `download`, `upload`, `search`, `external-link`, `zoom-in`
- Media transport: `play`, `pause`, `stop`
- Status: `check`, `alert`, `info`, `clock`, `sparkle`
- Media: `image`, `folder`, `film`, `music`
- Chevrons: `chevron-left`, `chevron-right`, `chevron-up`, `chevron-down`
- Misc: `drag`
```svelte
```