Files
aigc-home/calliope-web/src/lib/components/ui/StatusChip.svelte
T
施工员andmultica-agent e42212a16f feat(ui): fusion design tokens and shared component reskin (HEL-651 A batch)
- app.css: HEL-649 §一 tokens (bg/line/accent/status/text/type/space/radius/shadow/motion), legacy names aliased, reduced-motion via prefers-reduced-motion and data-reduce
- shared .a-btn/.status-chip/.a-panel/inputs reskinned; new .a-tag/.a-progress/.a-sprocket/.a-stage/.a-float
- tailwind colors/radii reference the same CSS variables
- ui primitives (StatusChip/ProgressBar/Modal/Button/ConfirmDialog/Skeleton/Switch/Card/Toast) on tokens
- running state -> --run, awaiting confirm -> --warn, --cloud purple removed, old palette literals -> tokens

Co-authored-by: multica-agent <github@multica.ai>
2026-09-30 08:29:37 +08:00

99 lines
1.8 KiB
Svelte

<script lang="ts">
interface Props {
status: string;
label?: string;
}
let { status, label }: Props = $props();
type Tone = 'ok' | 'run' | 'muted' | 'err' | 'warn';
const toneByStatus: Record<string, Tone> = {
ready: 'ok',
done: 'ok',
completed: 'ok',
running: 'run',
generating: 'run',
in_progress: 'run',
queued: 'muted',
pending: 'muted',
idle: 'muted',
draft: 'muted',
failed: 'err',
error: 'err',
paused: 'warn',
};
const key = $derived(status.trim().toLowerCase());
const tone: Tone = $derived(toneByStatus[key] ?? 'muted');
const pulsing = $derived(tone === 'run');
</script>
<span class="chip chip-{tone}">
<span class="dot" class:pulsing></span>
<span class="chip-label">{label ?? status}</span>
</span>
<style>
/* §四.2 状态标签:20px 高、--r-sm、12px;语义色文字 + 13% 软底。 */
.chip {
display: inline-flex;
align-items: center;
gap: var(--sp-2);
height: 20px;
padding: 0 var(--sp-2);
border-radius: var(--r-sm);
font-size: var(--fs-aux);
font-weight: 600;
white-space: nowrap;
box-sizing: border-box;
}
.dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: currentColor;
flex-shrink: 0;
}
.chip-ok {
color: var(--ok);
background: var(--ok-soft);
}
.chip-run {
color: var(--run);
background: var(--run-soft);
}
.chip-err {
color: var(--err);
background: var(--err-soft);
}
.chip-warn {
color: var(--warn);
background: var(--warn-soft);
}
.chip-muted {
color: var(--text-2);
background: var(--bg-4);
}
.dot.pulsing {
animation: chip-pulse 1.4s ease-in-out infinite;
}
@keyframes chip-pulse {
0%,
100% {
opacity: 1;
}
50% {
opacity: 0.35;
}
}
@media (prefers-reduced-motion: reduce) {
.dot.pulsing {
animation: none;
}
}
:global(:root[data-reduce='1']) .dot.pulsing {
animation: none;
}
</style>