Calliope 1.1.0: publish backend, web, and example workflows

This commit is contained in:
Benjiyaya
2026-08-19 03:53:29 +08:00
parent 83784ff4dc
commit 170dc0695d
138 changed files with 28423 additions and 3978 deletions
@@ -0,0 +1,147 @@
<script lang="ts">
import type { Snippet } from 'svelte';
import Spinner from './Spinner.svelte';
interface Props {
variant?: 'primary' | 'secondary' | 'ghost' | 'danger';
size?: 'sm' | 'md';
disabled?: boolean;
loading?: boolean;
type?: 'button' | 'submit' | 'reset';
title?: string;
onclick?: (event: MouseEvent) => void;
children: Snippet;
}
let {
variant = 'secondary',
size = 'md',
disabled = false,
loading = false,
type = 'button',
title,
onclick,
children,
}: Props = $props();
</script>
<button
{type}
class="btn btn-{variant} btn-{size}"
class:loading
disabled={disabled || loading}
{title}
{onclick}
>
<span class="btn-content" aria-hidden={loading || undefined}
>{@render children()}</span
>
{#if loading}
<span class="btn-spinner">
<Spinner size="sm" />
</span>
{/if}
</button>
<style>
.btn {
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 8px;
border: 1px solid transparent;
border-radius: var(--radius-sm);
font-family: inherit;
font-weight: 500;
white-space: nowrap;
cursor: pointer;
transition:
background-color 150ms ease,
border-color 150ms ease,
color 150ms ease,
box-shadow 150ms ease,
transform 100ms ease;
}
.btn-sm {
min-height: 28px;
padding: 5px 10px;
font-size: 12px;
}
.btn-md {
min-height: 34px;
padding: 8px 14px;
font-size: 13px;
}
.btn-primary {
background: var(--accent);
color: #fff;
}
.btn-primary:hover:not(:disabled) {
background: var(--accent-hover);
}
.btn-secondary {
background: var(--bg-elevated);
border-color: var(--border);
color: var(--text-primary);
}
.btn-secondary:hover:not(:disabled) {
background: #23232b;
border-color: #3f3f46;
}
.btn-ghost {
background: transparent;
color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
background: rgba(255, 255, 255, 0.05);
color: var(--text-primary);
}
.btn-danger {
background: rgba(239, 68, 68, 0.1);
border-color: rgba(239, 68, 68, 0.3);
color: var(--error);
}
.btn-danger:hover:not(:disabled) {
background: rgba(239, 68, 68, 0.18);
border-color: rgba(239, 68, 68, 0.45);
}
.btn:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
.btn:active:not(:disabled) {
transform: scale(0.98);
}
.btn:disabled {
opacity: 0.45;
cursor: not-allowed;
pointer-events: none;
}
.btn-content {
display: inline-flex;
align-items: center;
gap: inherit;
}
.btn.loading .btn-content {
visibility: hidden;
}
.btn-spinner {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
}
.btn-primary .btn-spinner,
.btn-danger .btn-spinner {
--spinner-track: rgba(255, 255, 255, 0.35);
--spinner-arc: #fff;
}
</style>
@@ -0,0 +1,84 @@
<script lang="ts">
import type { Snippet } from 'svelte';
interface Props {
hoverable?: boolean;
title?: string;
actions?: Snippet;
header?: Snippet;
children: Snippet;
class?: string;
}
let {
hoverable = false,
title,
actions,
header,
children,
class: klass = '',
}: Props = $props();
</script>
<div class="card {klass}" class:hoverable>
{#if header}
<div class="card-header">
{@render header()}
</div>
{:else if title || actions}
<div class="card-header">
{#if title}
<h3 class="card-title">{title}</h3>
{/if}
{#if actions}
<div class="card-actions">
{@render actions()}
</div>
{/if}
</div>
{/if}
<div class="card-body">
{@render children()}
</div>
</div>
<style>
.card {
background: var(--bg-surface);
border: 1px solid var(--border);
border-radius: var(--radius-md);
}
.card.hoverable {
transition:
border-color 150ms ease,
transform 150ms ease;
}
.card.hoverable:hover {
border-color: #3f3f46;
transform: translateY(-1px);
}
.card-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 14px 16px;
border-bottom: 1px solid var(--border);
}
.card-title {
margin: 0;
font-family: var(--font-display);
font-size: 14px;
font-weight: 600;
color: var(--text-primary);
}
.card-actions {
display: flex;
align-items: center;
gap: 8px;
margin-left: auto;
}
.card-body {
padding: 16px;
}
</style>
@@ -0,0 +1,63 @@
<script lang="ts">
import Button from './Button.svelte';
import Modal from './Modal.svelte';
interface Props {
open?: boolean;
title: string;
message: string;
confirmLabel?: string;
cancelLabel?: string;
danger?: boolean;
onconfirm: () => void;
oncancel?: () => void;
}
let {
open = $bindable(false),
title,
message,
confirmLabel = 'Confirm',
cancelLabel = 'Cancel',
danger = false,
onconfirm,
oncancel,
}: Props = $props();
// Set when the user confirms, so the ensuing close is not reported as a cancel.
let confirmed = false;
function handleConfirm() {
confirmed = true;
open = false;
onconfirm();
}
function handleClose() {
if (confirmed) {
confirmed = false;
return;
}
oncancel?.();
}
</script>
<Modal bind:open {title} onclose={handleClose}>
<p class="confirm-message">{message}</p>
{#snippet footer()}
<Button variant="ghost" onclick={() => (open = false)}>{cancelLabel}</Button
>
<Button variant={danger ? 'danger' : 'primary'} onclick={handleConfirm}
>{confirmLabel}</Button
>
{/snippet}
</Modal>
<style>
.confirm-message {
margin: 0;
font-size: 14px;
line-height: 1.5;
color: var(--text-secondary);
}
</style>
@@ -0,0 +1,64 @@
<script lang="ts">
import type { Snippet } from 'svelte';
interface Props {
title: string;
body?: string;
icon?: Snippet;
action?: Snippet;
}
let { title, body, icon, action }: Props = $props();
</script>
<div class="empty-state">
{#if icon}
<div class="empty-icon">
{@render icon()}
</div>
{/if}
<h3 class="empty-title">{title}</h3>
{#if body}
<p class="empty-body">{body}</p>
{/if}
{#if action}
<div class="empty-action">
{@render action()}
</div>
{/if}
</div>
<style>
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
padding: 40px 24px;
text-align: center;
background: var(--bg-surface);
border: 1px dashed var(--border);
border-radius: var(--radius-lg);
}
.empty-icon {
display: flex;
margin-bottom: 12px;
color: var(--text-muted);
}
.empty-title {
margin: 0;
font-family: var(--font-display);
font-size: 15px;
font-weight: 600;
color: var(--text-primary);
}
.empty-body {
margin: 6px 0 0;
max-width: 420px;
font-size: 13px;
line-height: 1.5;
color: var(--text-secondary);
}
.empty-action {
margin-top: 16px;
}
</style>
@@ -0,0 +1,37 @@
<script lang="ts">
import { icons, type IconName } from './icons';
interface Props {
name: IconName;
size?: number;
}
let { name, size = 18 }: Props = $props();
const content = $derived(icons[name] ?? '');
</script>
{#if content}
<svg
class="icon"
width={size}
height={size}
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
{@html content}
</svg>
{/if}
<style>
.icon {
display: inline-block;
vertical-align: -0.125em;
flex-shrink: 0;
}
</style>
@@ -0,0 +1,230 @@
<script lang="ts">
import type { Snippet } from 'svelte';
import Icon from './Icon.svelte';
interface Props {
open?: boolean;
title?: string;
dismissible?: boolean;
onclose?: () => void;
footer?: Snippet;
children: Snippet;
}
let {
open = $bindable(false),
title,
dismissible = true,
onclose,
footer,
children,
}: Props = $props();
const FOCUSABLE =
'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
const titleId = `modal-title-${Math.random().toString(36).slice(2, 9)}`;
let panel = $state<HTMLDivElement | null>(null);
function requestClose() {
if (!dismissible) return;
open = false;
}
function handleKeydown(event: KeyboardEvent) {
if (event.key === 'Escape') {
event.preventDefault();
requestClose();
return;
}
if (event.key === 'Tab') trapFocus(event);
}
function trapFocus(event: KeyboardEvent) {
if (!panel) return;
const focusables = Array.from(
panel.querySelectorAll<HTMLElement>(FOCUSABLE),
).filter((el) => el.getClientRects().length > 0);
if (focusables.length === 0) {
event.preventDefault();
panel.focus();
return;
}
const first = focusables[0];
const last = focusables[focusables.length - 1];
const active = document.activeElement;
const focusInside = panel.contains(active);
if (event.shiftKey && (!focusInside || active === first)) {
event.preventDefault();
last.focus();
} else if (!event.shiftKey && (!focusInside || active === last)) {
event.preventDefault();
first.focus();
}
}
function handleBackdropClick(event: MouseEvent) {
if (event.target === event.currentTarget) requestClose();
}
$effect(() => {
if (!open) return;
const invoker = document.activeElement as HTMLElement | null;
const previousOverflow = document.body.style.overflow;
document.body.style.overflow = 'hidden';
document.addEventListener('keydown', handleKeydown, true);
requestAnimationFrame(() => {
if (!panel || panel.contains(document.activeElement)) return;
const first = panel.querySelector<HTMLElement>(FOCUSABLE);
(first ?? panel).focus();
});
return () => {
document.body.style.overflow = previousOverflow;
document.removeEventListener('keydown', handleKeydown, true);
if (invoker?.isConnected) invoker.focus();
onclose?.();
};
});
</script>
{#if open}
<!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_static_element_interactions -->
<div class="modal-backdrop" onclick={handleBackdropClick}>
<div
bind:this={panel}
class="modal-panel"
role="dialog"
aria-modal="true"
aria-labelledby={title ? titleId : undefined}
aria-label={title ? undefined : 'Dialog'}
tabindex="-1"
>
{#if title || dismissible}
<div class="modal-header">
{#if title}
<h2 class="modal-title" id={titleId}>{title}</h2>
{/if}
{#if dismissible}
<button
type="button"
class="modal-close"
aria-label="Close dialog"
onclick={requestClose}
>
<Icon name="close" size={16} />
</button>
{/if}
</div>
{/if}
<div class="modal-body">
{@render children()}
</div>
{#if footer}
<div class="modal-footer">
{@render footer()}
</div>
{/if}
</div>
</div>
{/if}
<style>
.modal-backdrop {
position: fixed;
inset: 0;
z-index: 900;
display: flex;
align-items: center;
justify-content: center;
padding: 24px;
background: rgba(5, 5, 8, 0.6);
backdrop-filter: blur(6px);
-webkit-backdrop-filter: blur(6px);
animation: modal-fade 150ms ease-out;
}
.modal-panel {
width: min(520px, 100%);
max-height: calc(100vh - 96px);
display: flex;
flex-direction: column;
background: var(--bg-surface);
border: 1px solid var(--border);
border-radius: var(--radius-lg);
box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
outline: none;
animation: modal-rise 180ms ease-out;
}
.modal-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 18px 20px 0;
}
.modal-title {
margin: 0;
font-family: var(--font-display);
font-size: 16px;
font-weight: 600;
color: var(--text-primary);
}
.modal-close {
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
margin-left: auto;
border: none;
border-radius: var(--radius-sm);
background: transparent;
color: var(--text-muted);
cursor: pointer;
transition:
background-color 150ms ease,
color 150ms ease;
}
.modal-close:hover {
background: rgba(255, 255, 255, 0.06);
color: var(--text-primary);
}
.modal-close:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
.modal-body {
padding: 16px 20px 20px;
overflow-y: auto;
font-size: 14px;
line-height: 1.5;
color: var(--text-primary);
}
.modal-footer {
display: flex;
justify-content: flex-end;
gap: 8px;
padding: 0 20px 20px;
}
@keyframes modal-fade {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes modal-rise {
from {
opacity: 0;
transform: translateY(8px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
</style>
@@ -0,0 +1,121 @@
<script lang="ts">
interface Props {
value?: number;
indeterminate?: boolean;
label?: string;
size?: 'sm' | 'md';
}
let {
value = 0,
indeterminate = false,
label,
size = 'md',
}: Props = $props();
const pct = $derived(Math.round(Math.min(100, Math.max(0, value))));
const showMeta = $derived(Boolean(label) || !indeterminate);
</script>
<div class="progress progress-{size}">
{#if showMeta}
<div class="progress-meta">
{#if label}
<span class="progress-label">{label}</span>
{/if}
{#if !indeterminate}
<span class="progress-value">{pct}%</span>
{/if}
</div>
{/if}
<div
class="track"
role="progressbar"
aria-valuemin={0}
aria-valuemax={100}
aria-valuenow={indeterminate ? undefined : pct}
aria-label={label ?? 'Progress'}
>
{#if indeterminate}
<div class="fill indeterminate"></div>
{:else}
<div class="fill" style:width={pct + '%'}></div>
{/if}
</div>
</div>
<style>
.progress {
width: 100%;
}
.progress-meta {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 12px;
margin-bottom: 6px;
}
.progress-label {
font-size: 12px;
color: var(--text-secondary);
}
.progress-value {
margin-left: auto;
font-family: var(--font-mono);
font-size: 11px;
color: var(--text-muted);
}
.track {
position: relative;
width: 100%;
overflow: hidden;
background: var(--bg-elevated);
border-radius: 999px;
}
.progress-sm .track {
height: 4px;
}
.progress-md .track {
height: 6px;
}
.fill {
height: 100%;
background: var(--accent);
border-radius: 999px;
transition: width 250ms ease;
}
.fill.indeterminate {
position: absolute;
top: 0;
left: 0;
width: 40%;
background: linear-gradient(
90deg,
transparent,
var(--accent) 40%,
var(--accent) 60%,
transparent
);
transition: none;
animation: progress-slide 1.2s ease-in-out infinite;
}
@keyframes progress-slide {
0% {
left: -40%;
}
100% {
left: 100%;
}
}
@media (prefers-reduced-motion: reduce) {
.fill {
transition: none;
}
.fill.indeterminate {
animation: none;
left: 0;
width: 100%;
opacity: 0.4;
}
}
</style>
@@ -0,0 +1,263 @@
# 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 tokens (`--bg-surface`, `--border`, `--accent`, `--radius-*`, `--space-*`, fonts). Never hardcode hex colors outside this directory.
- 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 = 28px, md = 34px min-height |
| `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
<script lang="ts">
import Button from '$lib/components/ui/Button.svelte';
let saving = $state(false);
</script>
<Button variant="primary" loading={saving} onclick={() => (saving = true)}
>Generate</Button
>
<Button variant="danger" size="sm" onclick={remove}>Delete</Button>
<Button variant="ghost" onclick={cancel}>Cancel</Button>
```
## 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
<Card title="Renders" hoverable>
{#snippet actions()}
<Button size="sm" onclick={refresh}>Refresh</Button>
{/snippet}
<p>Body content here.</p>
</Card>
```
## 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
<StatusChip status={job.status} />
<StatusChip status="in_progress" label="Rendering" />
```
## 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 |
```svelte
<ProgressBar value={job.progress} label={job.name} />
<ProgressBar indeterminate label="Connecting" size="sm" />
```
## 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
<Skeleton width="60%" />
<Skeleton height="120px" />
<Skeleton circle height="32px" />
```
## 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
<script lang="ts">
import Modal from '$lib/components/ui/Modal.svelte';
import Button from '$lib/components/ui/Button.svelte';
let open = $state(false);
</script>
<Button variant="primary" onclick={() => (open = true)}>Open</Button>
<Modal bind:open title="Render settings" onclose={() => console.log('closed')}>
<p>Body content.</p>
{#snippet footer()}
<Button variant="ghost" onclick={() => (open = false)}>Cancel</Button>
<Button variant="primary" onclick={save}>Save</Button>
{/snippet}
</Modal>
```
## 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
<script lang="ts">
import ConfirmDialog from '$lib/components/ui/ConfirmDialog.svelte';
let confirmDelete = $state(false);
</script>
<ConfirmDialog
bind:open={confirmDelete}
title="Delete asset?"
message="This removes the asset and its generated files. This cannot be undone."
confirmLabel="Delete"
danger
onconfirm={deleteAsset}
oncancel={() => 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
<EmptyState
title="No assets yet"
body="Create a character or location to start generating."
>
{#snippet icon()}
<Icon name="assets" size={28} />
{/snippet}
{#snippet action()}
<Button variant="primary" onclick={addAsset}>New asset</Button>
{/snippet}
</EmptyState>
```
## 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
<Spinner size="sm" />
```
## 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
<script lang="ts">
import Icon from '$lib/components/ui/Icon.svelte';
</script>
<Icon name="sparkle" />
<Icon name="play" size={24} />
<Button variant="ghost" title="Settings" aria-label="Settings"
><Icon name="settings" /></Button
>
```
@@ -0,0 +1,54 @@
<script lang="ts">
interface Props {
width?: string;
height?: string;
circle?: boolean;
}
let { width = '100%', height = '14px', circle = false }: Props = $props();
const resolvedWidth = $derived(circle && width === '100%' ? height : width);
</script>
<div
class="skeleton"
class:circle
style:width={resolvedWidth}
style:height
aria-hidden="true"
></div>
<style>
.skeleton {
position: relative;
overflow: hidden;
background: var(--bg-elevated);
border-radius: var(--radius-sm);
}
.skeleton.circle {
border-radius: 50%;
}
.skeleton::after {
content: '';
position: absolute;
inset: 0;
background: linear-gradient(
90deg,
transparent,
rgba(255, 255, 255, 0.06),
transparent
);
transform: translateX(-100%);
animation: skeleton-shimmer 1.6s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
to {
transform: translateX(100%);
}
}
@media (prefers-reduced-motion: reduce) {
.skeleton::after {
display: none;
}
}
</style>
@@ -0,0 +1,59 @@
<script lang="ts">
interface Props {
size?: 'sm' | 'md' | 'lg';
}
let { size = 'md' }: Props = $props();
</script>
<span class="spinner spinner-{size}" role="status">
<span class="sr-only">Loading</span>
</span>
<style>
.spinner {
display: inline-block;
flex-shrink: 0;
border-radius: 50%;
border-style: solid;
border-color: var(--spinner-track, var(--bg-elevated));
border-top-color: var(--spinner-arc, var(--accent));
animation: spin 0.7s linear infinite;
}
.spinner-sm {
width: 14px;
height: 14px;
border-width: 2px;
}
.spinner-md {
width: 18px;
height: 18px;
border-width: 2px;
}
.spinner-lg {
width: 28px;
height: 28px;
border-width: 3px;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: reduce) {
.spinner {
animation: none;
}
}
</style>
@@ -0,0 +1,106 @@
<script lang="ts">
interface Props {
status: string;
label?: string;
}
let { status, label }: Props = $props();
type Tone = 'success' | 'info' | 'muted' | 'error' | 'warning' | 'accent';
const toneByStatus: Record<string, Tone> = {
ready: 'success',
done: 'success',
completed: 'success',
running: 'info',
generating: 'info',
queued: 'info',
pending: 'muted',
idle: 'muted',
draft: 'muted',
failed: 'error',
error: 'error',
paused: 'warning',
in_progress: 'accent',
};
const key = $derived(status.trim().toLowerCase());
const tone: Tone = $derived(toneByStatus[key] ?? 'muted');
const pulsing = $derived(key === 'running');
</script>
<span class="chip chip-{tone}">
<span class="dot" class:pulsing></span>
<span class="chip-label">{label ?? status}</span>
</span>
<style>
.chip {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 3px 9px;
border: 1px solid;
border-radius: 999px;
font-size: 10px;
font-weight: 600;
letter-spacing: 0.08em;
text-transform: uppercase;
line-height: 1.4;
white-space: nowrap;
}
.dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: currentColor;
flex-shrink: 0;
}
.chip-success {
color: var(--success);
background: color-mix(in srgb, var(--success) 12%, transparent);
border-color: color-mix(in srgb, var(--success) 35%, transparent);
}
.chip-info {
color: var(--info);
background: color-mix(in srgb, var(--info) 12%, transparent);
border-color: color-mix(in srgb, var(--info) 35%, transparent);
}
.chip-error {
color: var(--error);
background: color-mix(in srgb, var(--error) 12%, transparent);
border-color: color-mix(in srgb, var(--error) 35%, transparent);
}
.chip-warning {
color: var(--warning);
background: color-mix(in srgb, var(--warning) 12%, transparent);
border-color: color-mix(in srgb, var(--warning) 35%, transparent);
}
.chip-accent {
color: var(--accent);
background: color-mix(in srgb, var(--accent) 12%, transparent);
border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}
.chip-muted {
color: var(--text-secondary);
background: rgba(255, 255, 255, 0.04);
border-color: var(--border);
}
.dot.pulsing {
animation: chip-pulse 1.2s ease-in-out infinite;
}
@keyframes chip-pulse {
0%,
100% {
opacity: 1;
}
50% {
opacity: 0.35;
}
}
@media (prefers-reduced-motion: reduce) {
.dot.pulsing {
animation: none;
}
}
</style>
@@ -0,0 +1,70 @@
/**
* Inline SVG icon set for Calliope UI primitives.
* 24x24 viewBox, stroke-based (1.5px), currentColor — Lucide-style geometry.
* Each entry is SVG inner content rendered by Icon.svelte via {@html}.
*/
export const icons = {
// Navigation
home: '<path d="m3 10 9-7 9 7v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z"/><path d="M9 22V12h6v10"/>',
story:
'<path d="M2 4h6a4 4 0 0 1 4 4v12a3 3 0 0 0-3-3H2z"/><path d="M22 4h-6a4 4 0 0 0-4 4v12a3 3 0 0 1 3-3h7z"/>',
assets:
'<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/>',
script:
'<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6"/><path d="M16 13H8"/><path d="M16 17H8"/><path d="M10 9H8"/>',
video:
'<rect x="2" y="2" width="20" height="20" rx="2.18"/><path d="M7 2v20"/><path d="M17 2v20"/><path d="M2 12h20"/><path d="M2 7h5"/><path d="M2 17h5"/><path d="M17 17h5"/><path d="M17 7h5"/>',
queue:
'<path d="M8 6h13"/><path d="M8 12h13"/><path d="M8 18h13"/><path d="M3 6h.01"/><path d="M3 12h.01"/><path d="M3 18h.01"/>',
settings:
'<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/>',
playground:
'<path d="M10 2v7.53a2 2 0 0 1-.21.9L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45L14.21 10.4a2 2 0 0 1-.21-.9V2"/><path d="M8.5 2h7"/><path d="M7 16h10"/>',
// Actions
plus: '<path d="M5 12h14"/><path d="M12 5v14"/>',
trash:
'<path d="M3 6h18"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><path d="M10 11v6"/><path d="M14 11v6"/>',
edit: '<path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/>',
retry:
'<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M3 21v-5h5"/>',
close: '<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',
download:
'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/><path d="M12 15V3"/>',
upload:
'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m17 8-5-5-5 5"/><path d="M12 3v12"/>',
search: '<circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/>',
'external-link':
'<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><path d="M15 3h6v6"/><path d="M10 14 21 3"/>',
'zoom-in':
'<circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/><path d="M11 8v6"/><path d="M8 11h6"/>',
// Media transport
play: '<polygon points="6 3 20 12 6 21 6 3"/>',
pause:
'<rect x="6" y="4" width="4" height="16" rx="1"/><rect x="14" y="4" width="4" height="16" rx="1"/>',
stop: '<rect x="5" y="5" width="14" height="14" rx="2"/>',
// Status
check: '<path d="M20 6 9 17l-5-5"/>',
alert:
'<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><path d="M12 9v4"/><path d="M12 17h.01"/>',
info: '<circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/>',
clock: '<circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/>',
sparkle:
'<path d="M12 3l1.9 5.76a2 2 0 0 0 1.24 1.24L21 12l-5.86 1.9a2 2 0 0 0-1.24 1.24L12 21l-1.9-5.86a2 2 0 0 0-1.24-1.24L3 12l5.86-1.9a2 2 0 0 0 1.24-1.24Z"/>',
// Media
image:
'<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.09-3.09a2 2 0 0 0-2.82 0L6 21"/>',
film: '<rect x="2" y="4" width="20" height="16" rx="2"/><path d="M2 8h20"/><path d="M2 16h20"/><path d="M9 8v8"/><path d="M15 8v8"/>',
music:
'<path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/>',
folder:
'<path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/>',
// Chevrons
'chevron-left': '<path d="m15 18-6-6 6-6"/>',
'chevron-right': '<path d="m9 18 6-6-6-6"/>',
'chevron-up': '<path d="m18 15-6-6-6 6"/>',
'chevron-down': '<path d="m6 9 6 6 6-6"/>',
// Misc
drag: '<circle cx="9" cy="6" r="1"/><circle cx="9" cy="12" r="1"/><circle cx="9" cy="18" r="1"/><circle cx="15" cy="6" r="1"/><circle cx="15" cy="12" r="1"/><circle cx="15" cy="18" r="1"/>',
} as const satisfies Record<string, string>;
export type IconName = keyof typeof icons;