- 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>
138 lines
2.6 KiB
Svelte
138 lines
2.6 KiB
Svelte
<script lang="ts">
|
|
interface Props {
|
|
value?: number;
|
|
indeterminate?: boolean;
|
|
label?: string;
|
|
size?: 'sm' | 'md';
|
|
/** 进度条: running = 信号青, done = green, failed = red (static). */
|
|
tone?: 'run' | 'success' | 'error';
|
|
/** Track only — no label / percentage row. */
|
|
bare?: boolean;
|
|
}
|
|
|
|
let {
|
|
value = 0,
|
|
indeterminate = false,
|
|
label,
|
|
size = 'md',
|
|
tone = 'run',
|
|
bare = false,
|
|
}: Props = $props();
|
|
|
|
const pct = $derived(Math.round(Math.min(100, Math.max(0, value))));
|
|
const showMeta = $derived(!bare && (Boolean(label) || !indeterminate));
|
|
</script>
|
|
|
|
<div class="progress progress-{size} tone-{tone}">
|
|
{#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:transform="scaleX({pct / 100})"></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-4);
|
|
border-radius: var(--r-pill);
|
|
}
|
|
.progress-sm .track {
|
|
height: 4px;
|
|
}
|
|
.progress-md .track {
|
|
height: 6px;
|
|
}
|
|
.fill {
|
|
height: 100%;
|
|
background: var(--run-grad);
|
|
box-shadow: 0 0 8px var(--run-soft);
|
|
transform-origin: left;
|
|
transition: transform var(--d-progress) linear;
|
|
}
|
|
.tone-success .fill {
|
|
background: var(--ok);
|
|
box-shadow: none;
|
|
}
|
|
.tone-error .fill {
|
|
background: var(--err);
|
|
box-shadow: none;
|
|
}
|
|
.fill.indeterminate {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 40%;
|
|
background: linear-gradient(
|
|
90deg,
|
|
transparent,
|
|
var(--run) 40%,
|
|
var(--run) 60%,
|
|
transparent
|
|
);
|
|
box-shadow: none;
|
|
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>
|