Step loader
Named steps with a progress track and four loaders. Free and MIT licensed, as HTML, a typed React component or an Astro component, in three styles with light and dark mode.
Need this designed into your product? Book a call
Install
Add it to your project with the CLI.
HTML, CSS and JS
npx designme add step-loaderReact
npx designme add step-loader --reactAstro
npx designme add step-loader --astroshadcn, React
npx shadcn@latest add https://designme.dev/r/shadcn/step-loader.json shadcn, Astro
npx shadcn@latest add https://designme.dev/r/shadcn/astro/step-loader.json The CLI copies the source into your project, so you own it and can change anything. Where each version lands, what it needs and the shadcn theme bridge: Installation.
About
What it is for and what it does.
Step loader shows an agent task as a short list of named steps, with the current step's label, a count like 2/4 and a segmented progress track. Click the row to open the full list and see which steps are done and which are still to come.
- When an agent runs a known sequence, like reading frames, matching tokens and writing components.
- When people want one compact line by default, with the full list a click away.
- When finished steps should report what they did, such as "Read 4 frames" instead of "Reading Figma frames".
- When the end of a run should hand off with a clear label like "Ready for review".
- Pass
stepsand acurrentindex. Settingcurrenttosteps.lengthmarks every step done and shows a green check. - Each step has a running
labeland an optionaldonetext that replaces it once the step is finished. - The row label and the count crossfade as the agent moves to the next step, and the label shimmers while its step runs. The loader and each step's mark crossfade as they change, and the list's rows settle in one after another as it opens.
- In the open list, each step's mark sits under the row's loader and its words start where the row's do.
loaderpicks the animation beside the running step:radar,dots,ringorbars.doneLabelsets the text once everything is finished, "Ready for review" by default.- The step list can be left to toggle itself, or controlled with
open,defaultOpenandonOpenChange.
- The row is a button with
aria-expandedthat reflects whether the step list is open. - The track has
role="progressbar"witharia-valuemin,aria-valuemaxandaria-valuenowset from the steps. - When the list is closed it is
inertandaria-hidden, so hidden steps are skipped by keyboard and screen readers. - With reduced motion turned on, label swaps happen instantly and loader animations are cut short.
Usage
Import it in React and drive it from your own state, or place it in an Astro page.
React
import { StepLoader } from '@/components/designme/step-loader/StepLoader';React example
The demo above as a React component, 30 lines you can copy.
'use client';
// The animated preview from designme.dev, rebuilt from the React component: an example of driving it from your own state.
import { useState } from 'react';
import { StepLoader, type StepLoaderGlyph } from './StepLoader';
import { Seg } from '../lib/motion';
import { Demo } from '../lib/Demo';
import { useScript } from '../lib/useScript';
/* ---------- Step loader: four named steps, looping ---------- */
const STEPS = [
{ label: 'Reading Figma frames', done: 'Read 4 frames' }, { label: 'Matching tokens', done: 'Matched 18 tokens' },
{ label: 'Writing components', done: 'Wrote 3 components' }, { label: 'Checking contrast', done: 'Contrast passes' }
];
export default function StepLoaderDemo() {
const [loader, setLoader] = useState<StepLoaderGlyph>('radar');
const [current, setCurrent] = useState(0);
useScript(async ({ wait }) => {
for (;;) {
for (let i = 0; i < STEPS.length; i++) { setCurrent(i); await wait(1900); }
setCurrent(STEPS.length); await wait(3200);
setCurrent(0); await wait(700);
}
});
return (
<Demo switcher={<Seg label="Loader" value={loader} onChange={setLoader} options={[{ value: 'radar', label: 'Radar' }, { value: 'dots', label: 'Dots' }, { value: 'ring', label: 'Ring' }, { value: 'bars', label: 'Bars' }]} />}>
<StepLoader steps={STEPS} current={current} loader={loader} />
</Demo>
);
}
Astro
In a page in src/pages. It plays the demo above; change its step-loader.js to show your own data. Attributes like class go on its root element.
---
import StepLoader from '../components/designme/step-loader/StepLoader.astro';
---
<StepLoader />
<StepLoader data-style="soft" class="my-class" />Props
Everything StepLoader takes.
| Prop | Type | What it does |
|---|---|---|
stepsrequired | Step[] | |
currentrequired | number | Index of the step running now. steps.length (or more) means every step is done |
loader | StepLoaderGlyph | The loader beside the running step |
doneLabel | string | Label once every step is done |
open | boolean | Whether the list of every step is open. Leave it out to let the row toggle it |
defaultOpen | boolean | |
onOpenChange | (open: boolean) => void | |
className | string |
Code
The full source, as the CLI installs it.
StepLoader.tsxReact · 66 lines
'use client';
import { cx } from '../lib/cx';
import { useControllable } from '../lib/hooks';
import { Icon } from '../lib/icons';
import { Bars, Dot, Fold, Radar, Spin, Swap, SwapIcon, Think } from '../lib/motion';
import '../designme.css';
import './step-loader.css';
export interface Step {
/** Shown while the step runs, like "Reading Figma frames" */
label: string;
/** Shown once it is done, like "Read 4 frames". Falls back to label */
done?: string;
}
export type StepLoaderGlyph = 'radar' | 'dots' | 'ring' | 'bars';
export interface StepLoaderProps {
steps: Step[];
/** Index of the step running now. steps.length (or more) means every step is done */
current: number;
/** The loader beside the running step */
loader?: StepLoaderGlyph;
/** Label once every step is done */
doneLabel?: string;
/** Whether the list of every step is open. Leave it out to let the row toggle it */
open?: boolean;
defaultOpen?: boolean;
onOpenChange?: (open: boolean) => void;
className?: string;
}
const Loader = ({ kind }: { kind: StepLoaderGlyph }) =>
kind === 'dots' ? <Think /> : kind === 'ring' ? <Spin /> : kind === 'bars' ? <Bars /> : <Radar />;
/** Named steps with a progress track. Click the row to see every step. */
export function StepLoader({ steps, current, loader = 'radar', doneLabel = 'Ready for review', open, defaultOpen = false, onOpenChange, className }: StepLoaderProps) {
const [isOpen, setOpen] = useControllable(open, defaultOpen, onOpenChange);
const n = steps.length, done = current >= n, at = Math.min(current, n - 1);
return (
<div data-dm="" className={cx('dm-stl dm-mx-ic', className)} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 10 }}>
<button type="button" className="dm-stl-row dm-mx-press" aria-expanded={isOpen} onClick={() => setOpen(!isOpen)}>
<span className="dm-stl-g"><SwapIcon id={done ? 'ok' : loader}>{done ? <span className="dm-stl-ok"><Icon name="ok" /></span> : <Loader kind={loader} />}</SwapIcon></span>
<span className="dm-stl-t"><Swap className={cx('dm-stl-lab', !done && 'dm-shim')}>{done ? doneLabel : steps[at].label}</Swap><Swap className="dm-stl-n dm-num">{`${done ? n : at + 1}/${n}`}</Swap></span>
<Icon name="chev-d" size="xs" className="dm-stl-chev" />
</button>
<div className="dm-stl-track" role="progressbar" aria-valuemin={0} aria-valuemax={n} aria-valuenow={done ? n : at}>
{steps.map((_, i) => <i key={i} className={cx((done || i < current) && 'dm-on', !done && i === current && 'dm-run')} />)}
</div>
<Fold open={isOpen} className="dm-stl-fold">
<ol className={cx('dm-stl-list dm-mx-rows', isOpen && 'dm-mx-play')}>
{steps.map((s, i) => {
const finished = done || i < current, running = !done && i === current;
return (
<li key={i} className={cx(finished && 'dm-done', running && 'dm-run')}>
<span className="dm-g"><SwapIcon id={finished ? 'check' : running ? loader : 'dot'}>{finished ? <span className="dm-stl-ok"><Icon name="check" size="xs" /></span> : running ? <Loader kind={loader} /> : <Dot color="var(--dm-faint)" />}</SwapIcon></span>
{finished ? s.done ?? s.label : s.label}
</li>
);
})}
</ol>
</Fold>
</div>
);
}
step-loader.cssReact · 56 lines
/* Generated from designme.dev by scripts/sync.mjs. Edit the site, then sync. */
/* ---------- Step loader ---------- */
/* a pill with the step in hand (its loader, its name shimmering while it runs, how far along), a track of one part a step
under it, and a fold that lists every step. The list's marks sit centred under the pill's loader and its words start
where the pill's do. The pill is a disclosure: pointing at it gives it a quiet fill, never a bigger shadow */
.dm-stl .dm-dm-main{gap:10px}
.dm-stl-row{display:flex;align-items:center;gap:10px;background:var(--dm-surface);border-radius:var(--dm-r-pill);box-shadow:var(--dm-shadow);height:40px;padding:0 14px 0 13px;font-size:13.5px;min-width:250px;transition:background-color var(--dm-t-fast) var(--dm-ease)}
@media (hover:hover) and (pointer:fine){.dm-stl-row:hover{background:color-mix(in srgb,var(--dm-fg) 4%,var(--dm-surface))}}
/* its motion (the core's motion pieces, owner, 26 Nov): a press on the pill shows at once (.mx-press); a mark that changes, the
loader, the tick or a row's dot, crossfades in place (.mx-ic, iconSwap()); the list's rows settle one after another as it
opens (.mx-rows) */
.dm-stl-g{width:16px;display:grid;place-items:center;color:var(--dm-fg)}
/* a finished step's tick is the vivid mark green */
.dm-stl-ok{display:grid;color:var(--dm-ok-mark)}
/* (the step and its count share one baseline, grouped in their own line, while the loader and the chevron stay centred on
the pill; the count keeps the right end) */
.dm-stl-t{flex:1;min-width:0;display:flex;align-items:baseline;gap:10px;text-align:left}
.dm-stl-n{margin-left:auto;color:var(--dm-muted);font-size:12.5px}
.dm-stl-chev{color:var(--dm-muted);transition:transform .4s var(--dm-ease)}
.dm-stl-row[aria-expanded="true"] .dm-stl-chev{transform:rotate(180deg)}
.dm-stl-track{display:flex;gap:var(--dm-s-1);width:250px}
.dm-stl-track i{flex:1;height:3px;border-radius:var(--dm-r-tiny,2px);background:var(--dm-line);position:relative;overflow:hidden}
.dm-stl-track i::after{content:"";position:absolute;inset:0;background:var(--dm-accent-mark,var(--dm-accent));transform:scaleX(0);transform-origin:left;transition:transform .9s var(--dm-ease)}
.dm-stl-track i.dm-on::after{transform:scaleX(1)}
.dm-stl-track i.dm-run::after{transform:scaleX(.45);transition-duration:2.2s}
.dm-stl-fold{width:250px}
.dm-stl-fold>div{margin-inline:-16px;padding-inline:var(--dm-s-4)}
/* (10px above and below: with a step's own 6px, the first and last steps' words are 16px from the card's edges) */
.dm-stl-list{list-style:none;margin:6px 0 18px;padding:10px 6px;background:var(--dm-surface);border-radius:calc(14px * var(--dm-rk-l,var(--dm-rk)));box-shadow:var(--dm-shadow)}
/* each step's mark centred under the pill's loader (21px in), its words where the pill's start (39px in) */
.dm-stl-list li{display:flex;align-items:center;gap:10px;padding:6px var(--dm-s-2) 6px 7px;font-size:13px;color:var(--dm-muted)}
.dm-stl-list li.dm-done{color:var(--dm-fg2)}.dm-stl-list li.dm-run{color:var(--dm-fg)}
.dm-stl-list li .dm-g{width:16px;display:grid;place-items:center;flex:none}
/* Studio (owner, 19 Nov): the pill is Status pill's Studio pill (36px, a hairline and a short shadow, 13px words) with its
content 16px in; the list is a round card whose steps sit 8px in from its edges with their words 16px in, so its marks and
words share the pill's columns (24px and 40px in). The track is the neutral rail with the accent filling it, the tick the
vivid green, and the motion Studio's calm one */
/* the loader in the pill is the accent, which is white in Studio's dark mode (owner, 21 Nov: "accent color in light mode for
studio") */
:root[data-style="studio"] .dm-stl-g,:root [data-style="studio"] .dm-stl-g,:root [data-style="studio"].dm-stl-g{color:var(--dm-accent-mark)}
:root[data-style="studio"] .dm-stl-row,:root [data-style="studio"] .dm-stl-row,:root [data-style="studio"].dm-stl-row{height:36px;gap:8px;padding:0 16px;font-size:13px}
:root[data-style="studio"] .dm-stl-t,:root [data-style="studio"] .dm-stl-t,:root [data-style="studio"].dm-stl-t{gap:8px}
:root[data-style="studio"] .dm-stl-chev,:root [data-style="studio"] .dm-stl-chev,:root [data-style="studio"].dm-stl-chev{transition:transform var(--dm-t) var(--dm-ease)}
:root[data-style="studio"] .dm-stl-track i,:root [data-style="studio"] .dm-stl-track i,:root [data-style="studio"].dm-stl-track i{background:var(--dm-rail)}
:root[data-style="studio"] .dm-stl-list,:root [data-style="studio"] .dm-stl-list,:root [data-style="studio"].dm-stl-list{margin:8px 0 16px;padding:8px;border-radius:var(--dm-r-card)}
:root[data-style="studio"] .dm-stl-list li,:root [data-style="studio"] .dm-stl-list li,:root [data-style="studio"].dm-stl-list li{gap:8px;padding:8px;line-height:20px}
/* the row's hover is Studio's one hover laid over its fill (owner, 21 Nov), easing in and out over 220ms */
:root[data-style="studio"] .dm-stl-row,:root [data-style="studio"] .dm-stl-row,:root [data-style="studio"].dm-stl-row{transition:box-shadow var(--dm-t-fast) var(--dm-ease)}
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] .dm-stl-row:hover,:root [data-style="studio"] .dm-stl-row:hover,:root [data-style="studio"].dm-stl-row:hover{background:var(--dm-surface);box-shadow:var(--dm-shadow),inset 0 0 0 99px var(--dm-row)}}
/* (its press, the motion pieces' .mx-press: a step deeper than the hover, at once, in the hover's own layer) */
:root[data-style="studio"] .dm-stl-row.dm-mx-press:active,:root [data-style="studio"] .dm-stl-row.dm-mx-press:active,:root [data-style="studio"].dm-stl-row.dm-mx-press:active{box-shadow:var(--dm-shadow),inset 0 0 0 99px var(--dm-row-press);transition-duration:var(--dm-t-press)}
.dm-bars3{display:inline-flex;gap:2px;align-items:center;height:12px}
.dm-bars3 i{width:2.5px;height:100%;border-radius:var(--dm-r-tiny,2px);background:currentColor;animation:dm-b3 .9s var(--dm-ease-io) infinite}
.dm-bars3 i:nth-child(2){animation-delay:.15s}.dm-bars3 i:nth-child(3){animation-delay:.3s}
@keyframes dm-b3{0%,100%{transform:scaleY(.35)}50%{transform:scaleY(1)}}
StepLoader.astroAstro · 34 lines
---
// Generated from designme.dev by scripts/sync.mjs. Edit the site, then sync.
// Step loader: Named steps with a progress track and four loaders.
// The markup, CSS and script are designme.dev's own, run by the shared core in ../core, which mounts the component when it scrolls
// into view and plays its demo. To show your own data, change step-loader.js. The markup is kept exactly as it is (is:raw).
import type { HTMLAttributes } from 'astro/types';
import '../core/designme.css';
import './step-loader.css';
export interface Props extends HTMLAttributes<'div'> {
/** "soft" or "studio" draws it in that style. Leave it out for Blueprint, or for the style set on <html> (data-style="soft" or "studio") */
'data-style'?: 'soft' | 'studio';
}
const { class: className, ...rest } = Astro.props;
---
<div class:list={['card', 'wide', 'bare', className]} data-c="step-loader" {...rest}>
<div class="stage-in"><Fragment is:raw>
<div class="stl dm mx-ic"><div class="dm-main">
<button class="stl-row mx-press" aria-expanded="false">
<span class="stl-g"></span>
<span class="stl-t"><span class="stl-lab shim">Reading Figma frames</span><span class="stl-n num">1/4</span></span>
<svg class="i xs stl-chev"><use href="#i-chev-d"/></svg>
</button>
<div class="stl-track"><i></i><i></i><i></i><i></i></div>
<div class="fold shut stl-fold"><div><ol class="stl-list mx-rows"></ol></div></div>
</div>
<div class="demo"><div class="seg2" role="group" aria-label="Loader"><button aria-pressed="true" data-v="radar">Radar</button><button aria-pressed="false" data-v="think">Dots</button><button aria-pressed="false" data-v="spin">Ring</button><button aria-pressed="false" data-v="bars">Bars</button></div></div>
</div>
</Fragment></div>
</div>
<script>
import './step-loader.js';
</script>
step-loader.htmlHTML · 16 lines
<div class="card wide bare" data-c="step-loader">
<div class="stage-in">
<div class="stl dm mx-ic"><div class="dm-main">
<button class="stl-row mx-press" aria-expanded="false">
<span class="stl-g"></span>
<span class="stl-t"><span class="stl-lab shim">Reading Figma frames</span><span class="stl-n num">1/4</span></span>
<svg class="i xs stl-chev"><use href="#i-chev-d"/></svg>
</button>
<div class="stl-track"><i></i><i></i><i></i><i></i></div>
<div class="fold shut stl-fold"><div><ol class="stl-list mx-rows"></ol></div></div>
</div>
<div class="demo"><div class="seg2" role="group" aria-label="Loader"><button aria-pressed="true" data-v="radar">Radar</button><button aria-pressed="false" data-v="think">Dots</button><button aria-pressed="false" data-v="spin">Ring</button><button aria-pressed="false" data-v="bars">Bars</button></div></div>
</div>
</div>
</div>
step-loader.cssHTML · 55 lines
/* ---------- Step loader ---------- */
/* a pill with the step in hand (its loader, its name shimmering while it runs, how far along), a track of one part a step
under it, and a fold that lists every step. The list's marks sit centred under the pill's loader and its words start
where the pill's do. The pill is a disclosure: pointing at it gives it a quiet fill, never a bigger shadow */
.stl .dm-main{gap:10px}
.stl-row{display:flex;align-items:center;gap:10px;background:var(--dm-surface);border-radius:var(--dm-r-pill);box-shadow:var(--dm-shadow);height:40px;padding:0 14px 0 13px;font-size:13.5px;min-width:250px;transition:background-color var(--dm-t-fast) var(--dm-ease)}
@media (hover:hover) and (pointer:fine){.stl-row:hover{background:color-mix(in srgb,var(--dm-fg) 4%,var(--dm-surface))}}
/* its motion (the core's motion pieces, owner, 26 Nov): a press on the pill shows at once (.mx-press); a mark that changes, the
loader, the tick or a row's dot, crossfades in place (.mx-ic, iconSwap()); the list's rows settle one after another as it
opens (.mx-rows) */
.stl-g{width:16px;display:grid;place-items:center;color:var(--dm-fg)}
/* a finished step's tick is the vivid mark green */
.stl-ok{display:grid;color:var(--dm-ok-mark)}
/* (the step and its count share one baseline, grouped in their own line, while the loader and the chevron stay centred on
the pill; the count keeps the right end) */
.stl-t{flex:1;min-width:0;display:flex;align-items:baseline;gap:10px;text-align:left}
.stl-n{margin-left:auto;color:var(--dm-muted);font-size:12.5px}
.stl-chev{color:var(--dm-muted);transition:transform .4s var(--dm-ease)}
.stl-row[aria-expanded="true"] .stl-chev{transform:rotate(180deg)}
.stl-track{display:flex;gap:var(--dm-s-1);width:250px}
.stl-track i{flex:1;height:3px;border-radius:var(--dm-r-tiny,2px);background:var(--dm-line);position:relative;overflow:hidden}
.stl-track i::after{content:"";position:absolute;inset:0;background:var(--dm-accent-mark,var(--dm-accent));transform:scaleX(0);transform-origin:left;transition:transform .9s var(--dm-ease)}
.stl-track i.on::after{transform:scaleX(1)}
.stl-track i.run::after{transform:scaleX(.45);transition-duration:2.2s}
.stl-fold{width:250px}
.stl-fold>div{margin-inline:-16px;padding-inline:var(--dm-s-4)}
/* (10px above and below: with a step's own 6px, the first and last steps' words are 16px from the card's edges) */
.stl-list{list-style:none;margin:6px 0 18px;padding:10px 6px;background:var(--dm-surface);border-radius:calc(14px * var(--dm-rk-l,var(--dm-rk)));box-shadow:var(--dm-shadow)}
/* each step's mark centred under the pill's loader (21px in), its words where the pill's start (39px in) */
.stl-list li{display:flex;align-items:center;gap:10px;padding:6px var(--dm-s-2) 6px 7px;font-size:13px;color:var(--dm-muted)}
.stl-list li.done{color:var(--dm-fg2)}.stl-list li.run{color:var(--dm-fg)}
.stl-list li .g{width:16px;display:grid;place-items:center;flex:none}
/* Studio (owner, 19 Nov): the pill is Status pill's Studio pill (36px, a hairline and a short shadow, 13px words) with its
content 16px in; the list is a round card whose steps sit 8px in from its edges with their words 16px in, so its marks and
words share the pill's columns (24px and 40px in). The track is the neutral rail with the accent filling it, the tick the
vivid green, and the motion Studio's calm one */
/* the loader in the pill is the accent, which is white in Studio's dark mode (owner, 21 Nov: "accent color in light mode for
studio") */
:root[data-style="studio"] .stl-g,:root [data-style="studio"] .stl-g,:root [data-style="studio"].stl-g{color:var(--dm-accent-mark)}
:root[data-style="studio"] .stl-row,:root [data-style="studio"] .stl-row,:root [data-style="studio"].stl-row{height:36px;gap:8px;padding:0 16px;font-size:13px}
:root[data-style="studio"] .stl-t,:root [data-style="studio"] .stl-t,:root [data-style="studio"].stl-t{gap:8px}
:root[data-style="studio"] .stl-chev,:root [data-style="studio"] .stl-chev,:root [data-style="studio"].stl-chev{transition:transform var(--dm-t) var(--dm-ease)}
:root[data-style="studio"] .stl-track i,:root [data-style="studio"] .stl-track i,:root [data-style="studio"].stl-track i{background:var(--dm-rail)}
:root[data-style="studio"] .stl-list,:root [data-style="studio"] .stl-list,:root [data-style="studio"].stl-list{margin:8px 0 16px;padding:8px;border-radius:var(--dm-r-card)}
:root[data-style="studio"] .stl-list li,:root [data-style="studio"] .stl-list li,:root [data-style="studio"].stl-list li{gap:8px;padding:8px;line-height:20px}
/* the row's hover is Studio's one hover laid over its fill (owner, 21 Nov), easing in and out over 220ms */
:root[data-style="studio"] .stl-row,:root [data-style="studio"] .stl-row,:root [data-style="studio"].stl-row{transition:box-shadow var(--dm-t-fast) var(--dm-ease)}
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] .stl-row:hover,:root [data-style="studio"] .stl-row:hover,:root [data-style="studio"].stl-row:hover{background:var(--dm-surface);box-shadow:var(--dm-shadow),inset 0 0 0 99px var(--dm-row)}}
/* (its press, the motion pieces' .mx-press: a step deeper than the hover, at once, in the hover's own layer) */
:root[data-style="studio"] .stl-row.mx-press:active,:root [data-style="studio"] .stl-row.mx-press:active,:root [data-style="studio"].stl-row.mx-press:active{box-shadow:var(--dm-shadow),inset 0 0 0 99px var(--dm-row-press);transition-duration:var(--dm-t-press)}
.bars3{display:inline-flex;gap:2px;align-items:center;height:12px}
.bars3 i{width:2.5px;height:100%;border-radius:var(--dm-r-tiny,2px);background:currentColor;animation:b3 .9s var(--dm-ease-io) infinite}
.bars3 i:nth-child(2){animation-delay:.15s}.bars3 i:nth-child(3){animation-delay:.3s}
@keyframes b3{0%,100%{transform:scaleY(.35)}50%{transform:scaleY(1)}}
step-loader.jsHTML · 39 lines
DM.def('step-loader', (r, c) => {
// the chevron comes from I(), so it points at the icons wherever the component is mounted (designme.dev's own icon ids)
r.innerHTML = r.innerHTML.replace('{chev}', I('chev-d', 'xs stl-chev'));
const steps = [['Reading Figma frames','Read 4 frames'],['Matching tokens','Matched 18 tokens'],['Writing components','Wrote 3 components'],['Checking contrast','Contrast passes']];
const row = $('.stl-row', r), lab = $('.stl-lab', r), n = $('.stl-n', r), g = $('.stl-g', r), bars = $$('.stl-track i', r), list = $('.stl-list', r), fold = $('.stl-fold', r);
let kind = 'radar', cur = 0, done = false;
const glyph = () => kind === 'radar' ? '<span class="radar"></span>' : kind === 'think' ? '<span class="think on"><i></i><i></i><i></i><i></i></span>' : kind === 'spin' ? '<span class="spin"></span>' : '<span class="bars3"><i></i><i></i><i></i></span>';
// the rows stay and change in place: a mark that changes (the loader, the tick, the dot) crossfades (iconSwap()), and one
// that stays keeps playing where it is
const MARK = { ok:() => `<span class="stl-ok">${I('ok')}</span>`, check:() => `<span class="stl-ok">${I('check','xs')}</span>`, dot:() => '<span class="dot" style="color:var(--dm-faint)"></span>' };
const mark = (el, k) => { if (el.dataset.k === k) return; const first = !el.dataset.k; el.dataset.k = k; const put = () => { el.innerHTML = (MARK[k] || glyph)(); }; first ? put() : iconSwap(el, put); };
list.innerHTML = steps.map(() => '<li><span class="g"></span> </li>').join('');
const paint = () => {
mark(g, done ? 'ok' : kind);
[...list.children].forEach((li, i) => { const fin = i < cur || done;
li.className = fin ? 'done' : i === cur ? 'run' : ''; mark(li.firstElementChild, fin ? 'check' : i === cur ? kind : 'dot'); li.lastChild.nodeValue = fin ? steps[i][1] : steps[i][0]; });
};
seg($('.seg2', r), v => { kind = v; paint(); });
// the list's rows settle one after another as it opens (.mx-rows)
row.onclick = () => { const o = fold.classList.toggle('shut'); row.setAttribute('aria-expanded', !o); list.classList.toggle('mx-play', !o); };
paint();
c.run(async () => {
for (;;){
for (cur = 0; cur < steps.length; cur++){
bars[cur].classList.add('run'); paint();
swap(lab, steps[cur][0]); swap(n, (cur + 1) + '/4');
await c.wait(1900);
bars[cur].classList.remove('run'); bars[cur].classList.add('on');
}
done = true; lab.classList.remove('shim'); swap(lab, 'Ready for review'); swap(n, '4/4'); paint();
/* hold the finished state, then run the steps again */
await c.wait(3200);
// the pill says what runs again as the track empties, never "Ready for review" over an empty track
done = false; cur = 0; bars.forEach(b => b.classList.remove('on', 'run')); lab.classList.add('shim'); swap(lab, steps[0][0]); swap(n, '1/4'); paint();
await c.wait(700);
}
});
});
Questions
What people ask about it.
- How do I mark the whole run as finished?
- Set
currenttosteps.lengthor higher. The loader becomes a green check, every step shows itsdonetext and the row showsdoneLabel. - Can I open the step list from my own code?
- Yes. Pass
openand update it fromonOpenChangeto control it. Leaveopenout and the row toggles the list by itself, starting fromdefaultOpen. - Does the loader advance on its own?
- No. It shows whatever
currentyou pass, so you move it forward as your agent reports each step.
More in Agent status
Show what the agent is doing, how far along it is, and what it is working with.