Skip to content
Star

Recurring jobs

Tasks the agent runs on a schedule, with their last result and a switch. Free and MIT licensed, as HTML, a typed React component or an Astro component, in three styles with light and dark mode.

$npx designme add recurring-jobs
$npx shadcn@latest add https://designme.dev/r/shadcn/recurring-jobs.json

Need this designed into your product? Book a call

Recurring jobs
01

Install

Add it to your project with the CLI.

HTML, CSS and JS

$npx designme add recurring-jobs

React

$npx designme add recurring-jobs --react

Astro

$npx designme add recurring-jobs --astro

shadcn, React

$npx shadcn@latest add https://designme.dev/r/shadcn/recurring-jobs.json

shadcn, Astro

$npx shadcn@latest add https://designme.dev/r/shadcn/astro/recurring-jobs.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.

02

About

What it is for and what it does.

A list of tasks an agent runs on a schedule, like a weekly design QA. Each row says its schedule in words, when it runs next and how its last run went, with Run now and an on/off switch. A run whose last attempt failed says why and can offer a fix, a paused one dims and says Paused, and New schedule makes another from Every day, Every Monday or Custom days.

  • When people set an agent to repeat work, like checking pages every week or syncing tokens every morning.
  • When people need to see at a glance which recurring runs passed and which failed.
  • When a run fails for a reason people can fix, like an expired token, and should run again once it is fixed.
  • When people want to pause a recurring run without deleting it.
03

Usage

Import it in React and drive it from your own state, or place it in an Astro page.

React

import { RecurringJobs } from '@/components/designme/recurring-jobs/RecurringJobs';

React example

The demo above as a React component, 39 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 { useRef, useState } from 'react';
import { useStory, useWait } from '../lib/useScript';
import { RecurringJobs, type ScheduledRun } from './RecurringJobs';

/* ---------- Recurring jobs: run the design QA now, reconnect Figma so the token sync passes, pause the price check ---------- */
const RUNS: ScheduledRun[] = [
  { key: 'qa', name: 'Weekly design QA', schedule: 'Mondays at 9:00', next: 'Next in 2 days', result: 'passed', ago: '5 days ago', icon: 'palette', color: 'var(--dm-av-l)' },
  { key: 'tokens', name: 'Sync tokens from Figma', schedule: 'Every day at 8:00', next: 'Next in 17h', result: 'failed', error: 'Figma token expired', fix: 'Reconnect Figma', brand: 'figma' },
  { key: 'price', name: 'Competitor price check', schedule: 'Fridays at 17:00', next: 'Next in 6 days', result: 'passed', ago: 'yesterday', icon: 'chart', color: 'var(--dm-av-t)' }
];

export default function RecurringJobsDemo() {
  const ref = useRef<HTMLDivElement>(null);
  const [runs, setRuns] = useState(RUNS);
  const wait = useWait();
  const patch = (key: string, p: Partial<ScheduledRun>) => setRuns(rs => rs.map(r => r.key === key ? { ...r, ...p } : r));

  const runNow = async (key: string) => { patch(key, { result: 'running' }); await wait(3000); patch(key, { result: 'passed', ago: 'just now', error: undefined }); };
  // reconnecting takes a moment, then the run goes again straight away
  const fix = async (key: string) => { patch(key, { fixing: true }); await wait(900); patch(key, { fixing: false }); runNow(key); };

  // the preview's story: run the design QA and watch it pass, reconnect Figma so the token sync passes, then pause the price
  // check. A run at work keeps going under the pointer, as designme.dev's does
  useStory(ref, async ({ wait, press }) => {
    await wait(2000); press('.dm-shx-r:nth-child(1) .dm-shx-run');
    await wait(4000); press('.dm-shx-r:nth-child(2) .dm-shx-fx .dm-pill');
    await wait(5000); press('.dm-shx-r:nth-child(3) .dm-toggle');
  }, { hold: false });

  return (
    <div ref={ref} style={{ width: '100%' }}>
      <RecurringJobs runs={runs} onRunsChange={setRuns} onRunNow={runNow} onFix={fix}
        onCreate={n => setRuns(rs => [...rs, { key: 'new' + rs.length, name: n.task, schedule: n.schedule, next: n.next, result: 'never' }])} />
    </div>
  );
}

Astro

In a page in src/pages. It plays the demo above; change its recurring-jobs.js to show your own data. Attributes like class go on its root element.

---
import RecurringJobs from '../components/designme/recurring-jobs/RecurringJobs.astro';
---
<RecurringJobs />
<RecurringJobs data-style="soft" class="my-class" />
04

Props

Everything RecurringJobs takes.

PropTypeWhat it does
runsScheduledRun[]
defaultRunsScheduledRun[]
onRunsChange(runs: ScheduledRun[]) => voidCalled when a switch pauses or resumes a run, with the whole list
onRunNow(key: string) => voidAdds Run now to each row. Set the run's result to 'running' while it runs
onFix(key: string) => voidCalled by the fix button of a failed run
onCreate(run: RecurringJobsNew) => voidAdds New schedule: a task, Every day, Every Monday or Custom days, and Create
timestringThe time new schedules run at, in words. Defaults to "9:00"
hournumberThe hour of that time, so the form can say when the first run is. Defaults to 9
titlestringDefaults to "Recurring jobs"
statusstringA line under the title, like "Next run in 17h". Left out, the head is the title alone: the rows already say which runs are on, paused or failed
classNamestring
05

Code

The full source, as the CLI installs it.

RecurringJobs.tsxReact · 186 lines
'use client';
import { useRef, useState, type CSSProperties, type FormEvent } from 'react';
import { Brand, type BrandName } from '../lib/brands';
import { cx } from '../lib/cx';
import { useControllable, useIsoLayoutEffect, useReducedMotion } from '../lib/hooks';
import { Icon, type IconName } from '../lib/icons';
import { avatarInk, enter, Fold, Seg, Spin, Swap, Tip, useGrow } from '../lib/motion';
import { usePopover } from '../lib/popover';
import '../designme.css';
import './recurring-jobs.css';

/** How its last run went. running while it runs now; never before its first run */
export type ScheduledRunResult = 'passed' | 'failed' | 'running' | 'never';

/** A task the agent runs on a schedule */
export interface ScheduledRun {
  key: string;
  /** Like "Weekly design QA" */
  name: string;
  /** The schedule in words, like "Mondays at 9:00" */
  schedule: string;
  /** When it runs next, like "Next in 2 days". A paused run says "Paused" instead */
  next?: string;
  /** On or paused. Defaults to on */
  enabled?: boolean;
  result?: ScheduledRunResult;
  /** When the last run ended, like "5 days ago", shown as "Passed 5 days ago" */
  ago?: string;
  /** Why the last run failed, like "Figma token expired" */
  error?: string;
  /** The label of a button that fixes a failed run, like "Reconnect Figma". It calls `onFix` */
  fix?: string;
  /** The fix is under way: its button spins */
  fixing?: boolean;
  /** A service's own logo, on a white tile. Wins over `icon` */
  brand?: BrandName;
  /** An icon on a vivid tile of `color`. Defaults to a clock */
  icon?: IconName;
  /** The tile's colour, like 'var(--dm-av-l)'. The icon on it is white, or the colour's own ink for an avatar colour */
  color?: string;
}

/** What New schedule hands over: the task, and the days it runs on, 0 for Monday to 6 for Sunday */
export interface RecurringJobsNew {
  task: string;
  repeat: 'day' | 'monday' | 'custom';
  days: number[];
  /** The schedule in words, like "Mon, Wed, Fri at 9:00" */
  schedule: string;
  /** When it first runs, from now, like "Next in 18h" */
  next: string;
}

export interface RecurringJobsProps {
  runs?: ScheduledRun[];
  defaultRuns?: ScheduledRun[];
  /** Called when a switch pauses or resumes a run, with the whole list */
  onRunsChange?: (runs: ScheduledRun[]) => void;
  /** Adds Run now to each row. Set the run's result to 'running' while it runs */
  onRunNow?: (key: string) => void;
  /** Called by the fix button of a failed run */
  onFix?: (key: string) => void;
  /** Adds New schedule: a task, Every day, Every Monday or Custom days, and Create */
  onCreate?: (run: RecurringJobsNew) => void;
  /** The time new schedules run at, in words. Defaults to "9:00" */
  time?: string;
  /** The hour of that time, so the form can say when the first run is. Defaults to 9 */
  hour?: number;
  /** Defaults to "Recurring jobs" */
  title?: string;
  /** A line under the title, like "Next run in 17h". Left out, the head is the title alone: the rows already say which runs
      are on, paused or failed */
  status?: string;
  className?: string;
}

const DAY = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
const FULL = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
const words = (ds: number[], time: string) => ds.length === 7 ? `Every day at ${time}` : ds.join() === '0,1,2,3,4' ? `Weekdays at ${time}`
  : ds.length === 1 ? `${FULL[ds[0]]}s at ${time}` : `${ds.map(d => DAY[d]).join(', ')} at ${time}`;
/** When the first run is, from now: in hours when it's within a day, otherwise in days */
function firstRun(ds: number[], hour: number) {
  const now = new Date(), today = (now.getDay() + 6) % 7;
  const at = ds.map(d => { const t = new Date(now); t.setDate(now.getDate() + ((d - today + 7) % 7)); t.setHours(hour, 0, 0, 0); if (t <= now) t.setDate(t.getDate() + 7); return t; })
    .sort((a, b) => +a - +b)[0];
  const h = Math.round((+at - +now) / 36e5);
  if (h < 24) return `First run in ${Math.max(1, h)}h`;
  const days = Math.round((new Date(at).setHours(0, 0, 0, 0) - new Date(now).setHours(0, 0, 0, 0)) / 864e5);
  return `First run in ${days} days`;
}

/** The fix: as wide as its words, easing to "Reconnecting" with its spinner and back */
function Fix({ label, fixing, onClick }: { label: string; fixing?: boolean; onClick: () => void }) {
  const ref = useRef<HTMLButtonElement>(null), was = useRef(0), reduce = useReducedMotion();
  useIsoLayoutEffect(() => {
    const b = ref.current; if (!b) return;
    const w1 = b.getBoundingClientRect().width, w0 = was.current; was.current = w1;
    const cs = getComputedStyle(b), t = cs.getPropertyValue('--dm-t').trim();
    if (w0 && !reduce && Math.abs(w1 - w0) > .5) b.animate([{ width: w0 + 'px' }, { width: w1 + 'px' }], { duration: (t.endsWith('ms') ? parseFloat(t) : parseFloat(t) * 1000) || 340, easing: cs.getPropertyValue('--dm-ease').trim() || 'ease' });
  }, [fixing]);
  return <button ref={ref} type="button" className="dm-pill dm-accent dm-sm" aria-disabled={fixing || undefined} onClick={() => !fixing && onClick()}>{fixing ? <><Spin />Reconnecting</> : label}</button>;
}

/** Recurring agent tasks: each with its schedule in words, when it runs next, how its last run went, Run now and an
    on/off switch. A paused one dims and says so; a failed one says why and can offer a fix; New schedule makes another. */
export function RecurringJobs({ runs, defaultRuns = [], onRunsChange, onRunNow, onFix, onCreate, time = '9:00', hour = 9, title = 'Recurring jobs', status, className }: RecurringJobsProps) {
  const [list, setList] = useControllable(runs, defaultRuns, onRunsChange);
  // the card grows with its rows, and eases as a fix folds open or shut (as grow() on the site)
  const [root, inner] = useGrow();
  const field = useRef<HTMLInputElement>(null);
  // the form opens under its button, or above it when there is no room
  const menu = usePopover();
  const [task, setTask] = useState('');
  const [repeat, setRepeat] = useState<RecurringJobsNew['repeat']>('day');
  const [custom, setCustom] = useState([0, 2, 4]);
  const days = repeat === 'day' ? [0, 1, 2, 3, 4, 5, 6] : repeat === 'monday' ? [0] : custom;
  // a form that opened above New schedule grows upwards when Custom adds the days, so it is held by its bottom edge
  const [bottom, setBottom] = useState<CSSProperties>({});
  const up = String((menu.pop.style as Record<string, unknown>)['--dm-origin'] ?? '').startsWith('bottom');
  useIsoLayoutEffect(() => {
    const r = root.current?.querySelector<HTMLElement>('.dm-shx-add')?.getBoundingClientRect(), h = root.current?.getBoundingClientRect();
    setBottom(menu.open && up && r && h ? { top: 'auto', bottom: h.bottom - r.top + 6 } : {});
  }, [menu.open, repeat, up]);
  const [first] = useState(() => list.map(r => r.key));

  const on = (r: ScheduledRun) => r.enabled !== false;
  const toggle = (key: string) => setList(list.map(r => r.key === key ? { ...r, enabled: !on(r) } : r));
  const create = (e: FormEvent) => {
    e.preventDefault(); if (!task.trim() || !days.length) return;
    onCreate?.({ task: task.trim(), repeat, days, schedule: words(days, time), next: firstRun(days, hour).replace('First run', 'Next') });
    menu.close(); setTask('');
  };

  return (
    <div data-dm="" ref={root} className={cx('dm-shx dm-panel dm-growing dm-mx-grow', className)}>
      <div ref={inner} className="dm-grow">
      <div className="dm-shx-h"><span className="dm-shx-hi" aria-hidden="true"><Icon name="clock" size="xs" /></span><div><b>{title}</b>{status && <Swap className="dm-muted dm-shx-st">{status}</Swap>}</div></div>
      <div className="dm-shx-list" role="list" aria-label="Schedules">
        {list.map(r => {
          const at = first.indexOf(r.key), motion = enter(at >= 0 ? at * 50 : 0), running = r.result === 'running';
          const res = running ? 'Running now' : r.result === 'passed' ? 'Passed' + (r.ago ? ' ' + r.ago : '') : r.result === 'failed' ? 'Failed' + (r.error ? ': ' + r.error : '') : 'No runs yet';
          const st = running ? 'run' : r.result === 'passed' ? 'ok' : r.result === 'failed' ? 'bad' : 'none';
          const color = r.color ?? 'var(--dm-av-b)';
          return (
            <div key={r.key} className={cx('dm-shx-r', motion.className, !on(r) && 'dm-off')} style={motion.style} role="listitem" data-st={st}>
              {r.brand
                ? <span className="dm-ic dm-brandic" aria-hidden="true"><Brand name={r.brand} /></span>
                : <span className="dm-ic" style={{ background: color, color: avatarInk(color) ?? '#fff' }} aria-hidden="true"><Icon name={r.icon ?? 'clock'} size="xs" /></span>}
              <span className="dm-t">
                <span className="dm-nm">{r.name}</span>
                <Swap className="dm-d">{r.schedule + ' · ' + (on(r) ? r.next ?? '' : 'Paused')}</Swap>
                <span className="dm-res">{running ? <Spin /> : (r.result === 'passed' || r.result === 'failed') && <Icon name={r.result === 'passed' ? 'ok' : 'alert'} size="xs" />}<Swap className={running ? 'dm-shim' : undefined}>{res}</Swap></span>
              </span>
              <span className="dm-shx-act">
                {/* a labelled ghost button, so the switch is the one control on the row's right edge */}
                {onRunNow && <button type="button" className="dm-pill dm-ghost dm-sm dm-shx-run dm-mx-press" aria-label={`Run ${r.name} now`} disabled={running || !on(r)} onClick={() => onRunNow(r.key)}>Run now</button>}
                <Tip label={on(r) ? 'Pause' : 'Resume'}><button type="button" className="dm-toggle" role="switch" aria-checked={on(r)} aria-label={r.name} onClick={() => toggle(r.key)} /></Tip>
              </span>
              <Fold open={r.result === 'failed' && !!r.fix} className="dm-shx-fx">
                <div><Fix label={r.fix ?? ''} fixing={r.fixing} onClick={() => onFix?.(r.key)} /></div>
              </Fold>
            </div>
          );
        })}
      </div>
      {onCreate && <>
        <div className="dm-shx-ft"><button type="button" className="dm-shx-add dm-mx-press" {...menu.trigger} aria-haspopup="dialog" onClick={() => { menu.trigger.onClick(); if (!menu.open) requestAnimationFrame(() => field.current?.focus({ preventScroll: true })); }}><Icon name="plus" size="xs" />New schedule</button></div>
        <div {...menu.pop} style={{ ...menu.pop.style, ...bottom }} className={cx(menu.pop.className, 'dm-shx-pop dm-mx-pop')} role="dialog" aria-label="New schedule">
          <form className="dm-shx-f" onSubmit={create}>
            <h4>New schedule</h4>
            <input ref={field} className="dm-shx-in" value={task} onChange={e => setTask(e.target.value)} placeholder="What should the agent do?" aria-label="What should the agent do?" spellCheck={false} autoComplete="off" />
            <Seg className="dm-shx-rep" label="Repeat" value={repeat} onChange={setRepeat} options={[{ value: 'day', label: 'Every day' }, { value: 'monday', label: 'Every Monday' }, { value: 'custom', label: 'Custom' }]} />
            {repeat === 'custom' && (
              <div className="dm-shx-days" role="group" aria-label="Days">
                {DAY.map((d, i) => <button type="button" key={d} aria-pressed={custom.includes(i)} aria-label={FULL[i]} onClick={() => setCustom(c => c.includes(i) ? c.filter(x => x !== i) : [...c, i].sort())}>{d[0]}</button>)}
              </div>
            )}
            <div className="dm-shx-ff"><span className="dm-muted dm-shx-sum">{days.length ? firstRun(days, hour) : 'Pick at least one day'}</span><button type="submit" className="dm-pill dm-accent dm-sm" disabled={!task.trim() || !days.length}>Create</button></div>
          </form>
        </div>
      </>}
      </div>
    </div>
  );
}
recurring-jobs.cssReact · 99 lines
/* Generated from designme.dev by scripts/sync.mjs. Edit the site, then sync. */
/* ---------- Recurring jobs ---------- */
/* recurring agent tasks: the schedule in words, when it runs next and how its last run went, with Run now and an on/off
   switch. The card sits on two columns (owner, 18 Nov), its content 16px from every edge: the head's neutral mark in a 28px
   column with each run's mark under it, and the title and each run's words 12px after it; each run's mark, its three lines
   and its controls share one centre line, and the switches end on the content's right edge. A row is not a button, so it has
   no hover fill. The last line is the result, led by its mark (beside it, never over the run's own): a green tick when it
   passed, a red sign and the reason when it failed, with the fix under it, and a turning ring with words that shimmer while it
   runs. A paused one dims and says so. A run's mark is its tool's logo on a white tile, or its icon on a vivid tile of its
   colour (white or the colour's own ink on it). The card grows and shrinks with its rows (grow()) */
.dm-shx{padding:var(--dm-s-4);display:flex;flex-direction:column}
.dm-shx.dm-growing:has(.dm-pop.dm-open){overflow:visible}
.dm-shx-h{display:flex;align-items:center;gap:var(--dm-s-3);padding-bottom:var(--dm-s-2)}
.dm-shx-hi{width:28px;height:28px;display:grid;place-items:center;flex:none;border-radius:calc(8px * var(--dm-rk-m,var(--dm-rk)));color:var(--dm-fg2);background:var(--dm-chip)}
.dm-shx-h>div{flex:1;display:flex;flex-direction:column;min-width:0}
.dm-shx-h b{font-weight:500;font-size:14px;line-height:20px}
.dm-shx-st{font-size:12px;line-height:18px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.dm-shx-list{display:flex;flex-direction:column}
.dm-shx-r{display:grid;grid-template-columns:28px minmax(0,1fr) auto;align-items:center;column-gap:var(--dm-s-3);padding:var(--dm-s-2) 0;font-size:13px}
.dm-shx-r .dm-ic{width:28px;height:28px;border-radius:calc(8px * var(--dm-rk-m,var(--dm-rk)));display:grid;place-items:center;grid-row:1/4;align-self:center;transition:opacity var(--dm-t-fast) var(--dm-ease)}
.dm-shx-r .dm-ic.dm-brandic{background:var(--dm-surface);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dm-line) 50%,transparent);color:var(--dm-fg)}
.dm-shx-r .dm-ic .dm-brand{width:15px;height:15px}
/* the name, the schedule and the result take the words' column; Run now and the switch sit beside all three */
.dm-shx-r .dm-t{display:contents}
.dm-shx-r :is(.dm-nm,.dm-d,.dm-res){grid-column:2;transition:color var(--dm-t-fast) var(--dm-ease)}
.dm-shx-r .dm-nm{line-height:20px}
/* a paused one dims: its tile fades, and its name and result step down to muted, so the text stays readable */
.dm-shx-r.dm-off .dm-ic{opacity:.5}.dm-shx-r.dm-off :is(.dm-nm,.dm-res .dm-i){color:var(--dm-muted)}
.dm-shx-r .dm-nm,.dm-shx-r .dm-d{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.dm-shx-r .dm-d{font-size:12px;line-height:18px;color:var(--dm-muted)}
.dm-shx-r .dm-res{display:flex;align-items:center;gap:5px;min-width:0;height:18px;font-size:12px;color:var(--dm-muted)}
.dm-shx-r .dm-res>span{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.dm-shx-r .dm-res .dm-shim{font-size:inherit}
.dm-shx-r .dm-res .dm-i{flex:none;color:var(--dm-ok-mark)}
.dm-shx-r .dm-res .dm-spin{width:11px;height:11px;margin:0 .5px;color:var(--dm-accent-mark,var(--dm-accent))}
.dm-shx-r[data-st="bad"] .dm-res{color:var(--dm-bad)}
/* why it failed is never cut short: on a narrow card it wraps, its sign on the first line */
.dm-shx-r[data-st="bad"] .dm-res{height:auto;min-height:18px;align-items:flex-start;line-height:18px}
.dm-shx-r[data-st="bad"] .dm-res .dm-i{margin-top:3px}
.dm-shx-r[data-st="bad"] .dm-res>span{white-space:normal;text-wrap:pretty}
.dm-shx-r[data-st="bad"] .dm-res .dm-i{color:var(--dm-bad-mark)}
.dm-shx-act{grid-column:3;grid-row:1/4;align-self:center;display:flex;align-items:center;gap:var(--dm-s-2)}
/* Run now is a labelled ghost button (owner, 28 Nov), so the switch is the one control on the row's right edge */
.dm-shx-run.dm-pill{padding:0 var(--dm-s-2)}
.dm-shx-run:disabled{opacity:1;cursor:not-allowed;background:none;color:var(--dm-dis);transform:none}
.dm-shx-r .dm-shx-fx{grid-column:2/-1;grid-row:4}
.dm-shx-fx>div{overflow-clip-margin:0px}
.dm-shx-fx>div>div{display:flex;flex-wrap:wrap;gap:6px;padding-top:var(--dm-s-2)}
.dm-shx-fx .dm-pill .dm-spin{width:11px;height:11px}
/* New schedule: its + centred in the marks' column and its words on the title's; the hover box starts on the content's edge */
.dm-shx-add{display:flex;align-items:center;gap:var(--dm-s-3);align-self:flex-start;height:32px;margin-top:var(--dm-s-1);padding:0 var(--dm-s-3) 0 0;font-size:13px;color:var(--dm-fg2);border-radius:calc(8px * var(--dm-rk-m,var(--dm-rk)));transition:background-color var(--dm-t-fast) var(--dm-ease),color var(--dm-t-fast) var(--dm-ease)}
/* the foot sits under a hairline in Soft and Blueprint, 16px under the last row's words (owner, 30 Nov: "and then add some
   spacing"); the button's words sit 16px under the hairline and 16px from the card's bottom edge. Studio's is a foot strip */
.dm-shx-ft{margin-top:var(--dm-s-2);margin-bottom:-6px;padding-top:10px;border-top:1px solid color-mix(in srgb,var(--dm-line) 50%,transparent)}
.dm-shx-ft .dm-shx-add{margin-top:0}
.dm-shx-add>.dm-i{width:28px;padding:0 8px;box-sizing:border-box}
.dm-shx-add[aria-expanded="true"]{color:var(--dm-fg);background:var(--dm-row)}
@media (hover:hover) and (pointer:fine){.dm-shx-add:hover{color:var(--dm-fg);background:var(--dm-row)}}
/* its motion (the core's motion pieces, owner, 26 Nov): New schedule and Run now press at once (.mx-press; Studio keeps its
   button's own press); the New schedule dialog grows out of its button and goes back into it quicker (.mx-pop); the card grows
   on the spring (.mx-grow) */
.dm-shx-pop{width:272px;padding:var(--dm-s-3)}
.dm-shx-f{display:flex;flex-direction:column;gap:var(--dm-s-2)}
.dm-shx-f h4{margin:0 0 2px;font-size:13px;font-weight:500}
.dm-shx-in{width:100%;height:32px;border:0;outline:0;border-radius:var(--dm-r-field);background:var(--dm-surface);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dm-field-line) 50%,transparent);padding:0 10px;font:inherit;font-size:13px;color:var(--dm-fg);transition:box-shadow var(--dm-t-fast)}
@supports (corner-shape:squircle){.dm-shx-in{corner-shape:squircle;border-radius:var(--dm-r-field-sq)}}
.dm-shx-in::placeholder{color:var(--dm-muted)}
.dm-shx-in:focus{box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dm-field-line-strong) 50%,transparent)}
.dm-shx-rep{display:flex}
.dm-shx-rep button{flex:1 1 auto;padding:0 var(--dm-s-2);white-space:nowrap}
.dm-shx-days{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:var(--dm-s-1)}
.dm-shx-days button{height:28px;border-radius:var(--dm-r-sm);background:var(--dm-chip);font-size:12px;color:var(--dm-fg2);transition:background-color var(--dm-t-fast) var(--dm-ease),color var(--dm-t-fast) var(--dm-ease)}
@media (hover:hover) and (pointer:fine){.dm-shx-days button:hover{background:var(--dm-hover);color:var(--dm-fg)}}
.dm-shx-days button[aria-pressed="true"]{background:var(--dm-accent-bg);color:var(--dm-accent-fg,var(--dm-accent))}
.dm-shx-ff{display:flex;align-items:center;gap:var(--dm-s-2);padding-top:2px}
.dm-shx-sum{flex:1;min-width:0;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
/* nothing in it grows or shrinks when it is pressed (owner, 18 Nov); Studio's ink primary alone presses */
.dm-shx :is(.dm-ib,.dm-pill,.dm-shx-days button):active,:root[data-style="studio"] .dm-shx .dm-ib:active,:root [data-style="studio"] .dm-shx .dm-ib:active,:root [data-style="studio"].dm-shx .dm-ib:active{transform:none}
/* Studio (owner, 17 and 18 Nov): the head an off-white strip with a hairline under it; the runs' marks one neutral grey with
   a hairline (their logos keep their own colours); New schedule a flat secondary button on an off-white foot strip, 8px from
   the card's edges; the content 16px in from each edge and 16px from each strip; the form's days are round chips, its fields
   10px corners, and it scales and fades from its button with the card's corners */
:root[data-style="studio"] .dm-shx.dm-panel,:root [data-style="studio"] .dm-shx.dm-panel,:root [data-style="studio"].dm-shx.dm-panel{padding:0}
:root[data-style="studio"] .dm-shx-h,:root [data-style="studio"] .dm-shx-h,:root [data-style="studio"].dm-shx-h{min-height:calc(28px + 2 * var(--dm-strip-y) + 1px);padding:var(--dm-strip-y) 16px;background:var(--dm-strip);border-bottom:1px solid var(--dm-line);border-radius:var(--dm-r-card) var(--dm-r-card) 0 0}
:root[data-style="studio"] .dm-shx-hi,:root [data-style="studio"] .dm-shx-hi,:root [data-style="studio"].dm-shx-hi{background:var(--dm-surface);box-shadow:inset 0 0 0 1px var(--dm-hair);border-radius:10px}
:root[data-style="studio"] .dm-shx-list,:root [data-style="studio"] .dm-shx-list,:root [data-style="studio"].dm-shx-list{padding:var(--dm-s-2) var(--dm-s-4)}
:root[data-style="studio"] .dm-shx-r .dm-ic,:root [data-style="studio"] .dm-shx-r .dm-ic,:root [data-style="studio"].dm-shx-r .dm-ic,:root[data-style="studio"] .dm-shx-r .dm-ic.dm-brandic,:root [data-style="studio"] .dm-shx-r .dm-ic.dm-brandic,:root [data-style="studio"].dm-shx-r .dm-ic.dm-brandic{background:var(--dm-surface)!important;color:var(--dm-fg2)!important;box-shadow:inset 0 0 0 1px var(--dm-hair);border-radius:10px}
:root[data-style="studio"] .dm-shx-r .dm-res .dm-i,:root [data-style="studio"] .dm-shx-r .dm-res .dm-i,:root [data-style="studio"].dm-shx-r .dm-res .dm-i{color:color-mix(in srgb,var(--dm-ok-mark) 80%,var(--dm-ok))}
:root[data-style="studio"] .dm-shx-r[data-st="bad"] .dm-res .dm-i,:root [data-style="studio"] .dm-shx-r[data-st="bad"] .dm-res .dm-i,:root [data-style="studio"].dm-shx-r[data-st="bad"] .dm-res .dm-i{color:var(--dm-bad-mark)}
:root[data-style="studio"] .dm-shx-r.dm-off .dm-res .dm-i,:root [data-style="studio"] .dm-shx-r.dm-off .dm-res .dm-i,:root [data-style="studio"].dm-shx-r.dm-off .dm-res .dm-i{color:var(--dm-muted)}
:root[data-style="studio"] .dm-shx-run,:root [data-style="studio"] .dm-shx-run,:root [data-style="studio"].dm-shx-run{transition:background-color var(--dm-t-fast) var(--dm-ease),color var(--dm-t-fast) var(--dm-ease)}
:root[data-style="studio"] .dm-shx-ft,:root [data-style="studio"] .dm-shx-ft,:root [data-style="studio"].dm-shx-ft{margin-top:0;margin-bottom:0;padding:var(--dm-strip-y) var(--dm-s-4);background:var(--dm-strip);border-top:1px solid var(--dm-line);border-radius:0 0 var(--dm-r-card) var(--dm-r-card)}
:root[data-style="studio"] .dm-shx-add,:root [data-style="studio"] .dm-shx-add,:root [data-style="studio"].dm-shx-add{gap:6px;height:28px;margin:0;padding:0 12px 0 10px;border-radius:var(--dm-r-pill);font-weight:500;color:var(--dm-fg);background:linear-gradient(180deg,var(--dm-btn2-1),var(--dm-btn2-2));box-shadow:var(--dm-btn2-depth);transition:box-shadow var(--dm-t-fast) var(--dm-ease)}
:root[data-style="studio"] .dm-shx-add>.dm-i,:root [data-style="studio"] .dm-shx-add>.dm-i,:root [data-style="studio"].dm-shx-add>.dm-i{width:12px;padding:0}
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] :is(.dm-shx-add:hover,.dm-shx-add[aria-expanded="true"]),:root [data-style="studio"] :is(.dm-shx-add:hover,.dm-shx-add[aria-expanded="true"]),:root [data-style="studio"]:is(.dm-shx-add:hover,.dm-shx-add[aria-expanded="true"]){background:linear-gradient(180deg,var(--dm-btn2-1),var(--dm-btn2-2));box-shadow:var(--dm-btn2-hover)}}
:root[data-style="studio"] .dm-shx-add:active,:root [data-style="studio"] .dm-shx-add:active,:root [data-style="studio"].dm-shx-add:active{box-shadow:var(--dm-btn2-press)}
:root[data-style="studio"] .dm-shx-pop,:root [data-style="studio"] .dm-shx-pop,:root [data-style="studio"].dm-shx-pop{width:288px;padding:var(--dm-s-4);border-radius:var(--dm-r-card)}
:root[data-style="studio"] .dm-shx-days button,:root [data-style="studio"] .dm-shx-days button,:root [data-style="studio"].dm-shx-days button{border-radius:var(--dm-r-pill);transition:background-color var(--dm-t-fast) var(--dm-ease),color var(--dm-t-fast) var(--dm-ease)}
RecurringJobs.astroAstro · 35 lines
---
// Generated from designme.dev by scripts/sync.mjs. Edit the site, then sync.
// Recurring jobs: Tasks the agent runs on a schedule, with their last result and a switch.
// 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 recurring-jobs.js. The markup is kept exactly as it is (is:raw).
import type { HTMLAttributes } from 'astro/types';
import '../core/designme.css';
import './recurring-jobs.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', className]} data-c="recurring-jobs" {...rest}>
  <div class="stage-in"><Fragment is:raw>
<div class="shx panel mx-grow" data-reveal="flat">
  <div class="shx-h"><span class="shx-hi" aria-hidden="true"><svg class="i xs"><use href="#i-clock"/></svg></span><div><b>Recurring jobs</b></div></div>
  <div class="shx-list" role="list" aria-label="Schedules"></div>
  <div class="shx-ft"><button class="shx-add mx-press" data-pop=".shx-pop" aria-haspopup="dialog" aria-expanded="false"><svg class="i xs"><use href="#i-plus"/></svg>New schedule</button></div>
  <div class="pop shx-pop mx-pop" role="dialog" aria-label="New schedule"><form class="shx-f">
    <h4>New schedule</h4>
    <input class="shx-in" placeholder="What should the agent do?" aria-label="What should the agent do?" spellcheck="false" autocomplete="off">
    <div class="seg2 shx-rep" role="group" aria-label="Repeat"><button type="button" aria-pressed="true" data-v="day">Every day</button><button type="button" aria-pressed="false" data-v="mon">Every Monday</button><button type="button" aria-pressed="false" data-v="custom">Custom</button></div>
    <div class="shx-days" role="group" aria-label="Days" hidden></div>
    <div class="shx-ff"><span class="muted shx-sum"></span><button class="pill accent sm shx-mk" type="submit" disabled>Create</button></div>
  </form></div>
</div>
  </Fragment></div>
</div>
<script>
  import './recurring-jobs.js';
</script>
recurring-jobs.htmlHTML · 17 lines
<div class="card" data-c="recurring-jobs">
  <div class="stage-in">
    <div class="shx panel mx-grow" data-reveal="flat">
      <div class="shx-h"><span class="shx-hi" aria-hidden="true"><svg class="i xs"><use href="#i-clock"/></svg></span><div><b>Recurring jobs</b></div></div>
      <div class="shx-list" role="list" aria-label="Schedules"></div>
      <div class="shx-ft"><button class="shx-add mx-press" data-pop=".shx-pop" aria-haspopup="dialog" aria-expanded="false"><svg class="i xs"><use href="#i-plus"/></svg>New schedule</button></div>
      <div class="pop shx-pop mx-pop" role="dialog" aria-label="New schedule"><form class="shx-f">
        <h4>New schedule</h4>
        <input class="shx-in" placeholder="What should the agent do?" aria-label="What should the agent do?" spellcheck="false" autocomplete="off">
        <div class="seg2 shx-rep" role="group" aria-label="Repeat"><button type="button" aria-pressed="true" data-v="day">Every day</button><button type="button" aria-pressed="false" data-v="mon">Every Monday</button><button type="button" aria-pressed="false" data-v="custom">Custom</button></div>
        <div class="shx-days" role="group" aria-label="Days" hidden></div>
        <div class="shx-ff"><span class="muted shx-sum"></span><button class="pill accent sm shx-mk" type="submit" disabled>Create</button></div>
      </form></div>
    </div>
  </div>
</div>
recurring-jobs.cssHTML · 98 lines
/* ---------- Recurring jobs ---------- */
/* recurring agent tasks: the schedule in words, when it runs next and how its last run went, with Run now and an on/off
   switch. The card sits on two columns (owner, 18 Nov), its content 16px from every edge: the head's neutral mark in a 28px
   column with each run's mark under it, and the title and each run's words 12px after it; each run's mark, its three lines
   and its controls share one centre line, and the switches end on the content's right edge. A row is not a button, so it has
   no hover fill. The last line is the result, led by its mark (beside it, never over the run's own): a green tick when it
   passed, a red sign and the reason when it failed, with the fix under it, and a turning ring with words that shimmer while it
   runs. A paused one dims and says so. A run's mark is its tool's logo on a white tile, or its icon on a vivid tile of its
   colour (white or the colour's own ink on it). The card grows and shrinks with its rows (grow()) */
.shx{padding:var(--dm-s-4);display:flex;flex-direction:column}
.shx.growing:has(.pop.open){overflow:visible}
.shx-h{display:flex;align-items:center;gap:var(--dm-s-3);padding-bottom:var(--dm-s-2)}
.shx-hi{width:28px;height:28px;display:grid;place-items:center;flex:none;border-radius:calc(8px * var(--dm-rk-m,var(--dm-rk)));color:var(--dm-fg2);background:var(--dm-chip)}
.shx-h>div{flex:1;display:flex;flex-direction:column;min-width:0}
.shx-h b{font-weight:500;font-size:14px;line-height:20px}
.shx-st{font-size:12px;line-height:18px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.shx-list{display:flex;flex-direction:column}
.shx-r{display:grid;grid-template-columns:28px minmax(0,1fr) auto;align-items:center;column-gap:var(--dm-s-3);padding:var(--dm-s-2) 0;font-size:13px}
.shx-r .ic{width:28px;height:28px;border-radius:calc(8px * var(--dm-rk-m,var(--dm-rk)));display:grid;place-items:center;grid-row:1/4;align-self:center;transition:opacity var(--dm-t-fast) var(--dm-ease)}
.shx-r .ic.brandic{background:var(--dm-surface);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dm-line) 50%,transparent);color:var(--dm-fg)}
.shx-r .ic .brand{width:15px;height:15px}
/* the name, the schedule and the result take the words' column; Run now and the switch sit beside all three */
.shx-r .t{display:contents}
.shx-r :is(.nm,.d,.res){grid-column:2;transition:color var(--dm-t-fast) var(--dm-ease)}
.shx-r .nm{line-height:20px}
/* a paused one dims: its tile fades, and its name and result step down to muted, so the text stays readable */
.shx-r.off .ic{opacity:.5}.shx-r.off :is(.nm,.res .i){color:var(--dm-muted)}
.shx-r .nm,.shx-r .d{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.shx-r .d{font-size:12px;line-height:18px;color:var(--dm-muted)}
.shx-r .res{display:flex;align-items:center;gap:5px;min-width:0;height:18px;font-size:12px;color:var(--dm-muted)}
.shx-r .res>span{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.shx-r .res .shim{font-size:inherit}
.shx-r .res .i{flex:none;color:var(--dm-ok-mark)}
.shx-r .res .spin{width:11px;height:11px;margin:0 .5px;color:var(--dm-accent-mark,var(--dm-accent))}
.shx-r[data-st="bad"] .res{color:var(--dm-bad)}
/* why it failed is never cut short: on a narrow card it wraps, its sign on the first line */
.shx-r[data-st="bad"] .res{height:auto;min-height:18px;align-items:flex-start;line-height:18px}
.shx-r[data-st="bad"] .res .i{margin-top:3px}
.shx-r[data-st="bad"] .res>span{white-space:normal;text-wrap:pretty}
.shx-r[data-st="bad"] .res .i{color:var(--dm-bad-mark)}
.shx-act{grid-column:3;grid-row:1/4;align-self:center;display:flex;align-items:center;gap:var(--dm-s-2)}
/* Run now is a labelled ghost button (owner, 28 Nov), so the switch is the one control on the row's right edge */
.shx-run.pill{padding:0 var(--dm-s-2)}
.shx-run:disabled{opacity:1;cursor:not-allowed;background:none;color:var(--dm-dis);transform:none}
.shx-r .shx-fx{grid-column:2/-1;grid-row:4}
.shx-fx>div{overflow-clip-margin:0px}
.shx-fx>div>div{display:flex;flex-wrap:wrap;gap:6px;padding-top:var(--dm-s-2)}
.shx-fx .pill .spin{width:11px;height:11px}
/* New schedule: its + centred in the marks' column and its words on the title's; the hover box starts on the content's edge */
.shx-add{display:flex;align-items:center;gap:var(--dm-s-3);align-self:flex-start;height:32px;margin-top:var(--dm-s-1);padding:0 var(--dm-s-3) 0 0;font-size:13px;color:var(--dm-fg2);border-radius:calc(8px * var(--dm-rk-m,var(--dm-rk)));transition:background-color var(--dm-t-fast) var(--dm-ease),color var(--dm-t-fast) var(--dm-ease)}
/* the foot sits under a hairline in Soft and Blueprint, 16px under the last row's words (owner, 30 Nov: "and then add some
   spacing"); the button's words sit 16px under the hairline and 16px from the card's bottom edge. Studio's is a foot strip */
.shx-ft{margin-top:var(--dm-s-2);margin-bottom:-6px;padding-top:10px;border-top:1px solid color-mix(in srgb,var(--dm-line) 50%,transparent)}
.shx-ft .shx-add{margin-top:0}
.shx-add>.i{width:28px;padding:0 8px;box-sizing:border-box}
.shx-add[aria-expanded="true"]{color:var(--dm-fg);background:var(--dm-row)}
@media (hover:hover) and (pointer:fine){.shx-add:hover{color:var(--dm-fg);background:var(--dm-row)}}
/* its motion (the core's motion pieces, owner, 26 Nov): New schedule and Run now press at once (.mx-press; Studio keeps its
   button's own press); the New schedule dialog grows out of its button and goes back into it quicker (.mx-pop); the card grows
   on the spring (.mx-grow) */
.shx-pop{width:272px;padding:var(--dm-s-3)}
.shx-f{display:flex;flex-direction:column;gap:var(--dm-s-2)}
.shx-f h4{margin:0 0 2px;font-size:13px;font-weight:500}
.shx-in{width:100%;height:32px;border:0;outline:0;border-radius:var(--dm-r-field);background:var(--dm-surface);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dm-field-line) 50%,transparent);padding:0 10px;font:inherit;font-size:13px;color:var(--dm-fg);transition:box-shadow var(--dm-t-fast)}
@supports (corner-shape:squircle){.shx-in{corner-shape:squircle;border-radius:var(--dm-r-field-sq)}}
.shx-in::placeholder{color:var(--dm-muted)}
.shx-in:focus{box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dm-field-line-strong) 50%,transparent)}
.shx-rep{display:flex}
.shx-rep button{flex:1 1 auto;padding:0 var(--dm-s-2);white-space:nowrap}
.shx-days{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:var(--dm-s-1)}
.shx-days button{height:28px;border-radius:var(--dm-r-sm);background:var(--dm-chip);font-size:12px;color:var(--dm-fg2);transition:background-color var(--dm-t-fast) var(--dm-ease),color var(--dm-t-fast) var(--dm-ease)}
@media (hover:hover) and (pointer:fine){.shx-days button:hover{background:var(--dm-hover);color:var(--dm-fg)}}
.shx-days button[aria-pressed="true"]{background:var(--dm-accent-bg);color:var(--dm-accent-fg,var(--dm-accent))}
.shx-ff{display:flex;align-items:center;gap:var(--dm-s-2);padding-top:2px}
.shx-sum{flex:1;min-width:0;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
/* nothing in it grows or shrinks when it is pressed (owner, 18 Nov); Studio's ink primary alone presses */
.shx :is(.ib,.pill,.shx-days button):active,:root[data-style="studio"] .shx .ib:active,:root [data-style="studio"] .shx .ib:active,:root [data-style="studio"].shx .ib:active{transform:none}
/* Studio (owner, 17 and 18 Nov): the head an off-white strip with a hairline under it; the runs' marks one neutral grey with
   a hairline (their logos keep their own colours); New schedule a flat secondary button on an off-white foot strip, 8px from
   the card's edges; the content 16px in from each edge and 16px from each strip; the form's days are round chips, its fields
   10px corners, and it scales and fades from its button with the card's corners */
:root[data-style="studio"] .shx.panel,:root [data-style="studio"] .shx.panel,:root [data-style="studio"].shx.panel{padding:0}
:root[data-style="studio"] .shx-h,:root [data-style="studio"] .shx-h,:root [data-style="studio"].shx-h{min-height:calc(28px + 2 * var(--dm-strip-y) + 1px);padding:var(--dm-strip-y) 16px;background:var(--dm-strip);border-bottom:1px solid var(--dm-line);border-radius:var(--dm-r-card) var(--dm-r-card) 0 0}
:root[data-style="studio"] .shx-hi,:root [data-style="studio"] .shx-hi,:root [data-style="studio"].shx-hi{background:var(--dm-surface);box-shadow:inset 0 0 0 1px var(--dm-hair);border-radius:10px}
:root[data-style="studio"] .shx-list,:root [data-style="studio"] .shx-list,:root [data-style="studio"].shx-list{padding:var(--dm-s-2) var(--dm-s-4)}
:root[data-style="studio"] .shx-r .ic,:root [data-style="studio"] .shx-r .ic,:root [data-style="studio"].shx-r .ic,:root[data-style="studio"] .shx-r .ic.brandic,:root [data-style="studio"] .shx-r .ic.brandic,:root [data-style="studio"].shx-r .ic.brandic{background:var(--dm-surface)!important;color:var(--dm-fg2)!important;box-shadow:inset 0 0 0 1px var(--dm-hair);border-radius:10px}
:root[data-style="studio"] .shx-r .res .i,:root [data-style="studio"] .shx-r .res .i,:root [data-style="studio"].shx-r .res .i{color:color-mix(in srgb,var(--dm-ok-mark) 80%,var(--dm-ok))}
:root[data-style="studio"] .shx-r[data-st="bad"] .res .i,:root [data-style="studio"] .shx-r[data-st="bad"] .res .i,:root [data-style="studio"].shx-r[data-st="bad"] .res .i{color:var(--dm-bad-mark)}
:root[data-style="studio"] .shx-r.off .res .i,:root [data-style="studio"] .shx-r.off .res .i,:root [data-style="studio"].shx-r.off .res .i{color:var(--dm-muted)}
:root[data-style="studio"] .shx-run,:root [data-style="studio"] .shx-run,:root [data-style="studio"].shx-run{transition:background-color var(--dm-t-fast) var(--dm-ease),color var(--dm-t-fast) var(--dm-ease)}
:root[data-style="studio"] .shx-ft,:root [data-style="studio"] .shx-ft,:root [data-style="studio"].shx-ft{margin-top:0;margin-bottom:0;padding:var(--dm-strip-y) var(--dm-s-4);background:var(--dm-strip);border-top:1px solid var(--dm-line);border-radius:0 0 var(--dm-r-card) var(--dm-r-card)}
:root[data-style="studio"] .shx-add,:root [data-style="studio"] .shx-add,:root [data-style="studio"].shx-add{gap:6px;height:28px;margin:0;padding:0 12px 0 10px;border-radius:var(--dm-r-pill);font-weight:500;color:var(--dm-fg);background:linear-gradient(180deg,var(--dm-btn2-1),var(--dm-btn2-2));box-shadow:var(--dm-btn2-depth);transition:box-shadow var(--dm-t-fast) var(--dm-ease)}
:root[data-style="studio"] .shx-add>.i,:root [data-style="studio"] .shx-add>.i,:root [data-style="studio"].shx-add>.i{width:12px;padding:0}
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] :is(.shx-add:hover,.shx-add[aria-expanded="true"]),:root [data-style="studio"] :is(.shx-add:hover,.shx-add[aria-expanded="true"]),:root [data-style="studio"]:is(.shx-add:hover,.shx-add[aria-expanded="true"]){background:linear-gradient(180deg,var(--dm-btn2-1),var(--dm-btn2-2));box-shadow:var(--dm-btn2-hover)}}
:root[data-style="studio"] .shx-add:active,:root [data-style="studio"] .shx-add:active,:root [data-style="studio"].shx-add:active{box-shadow:var(--dm-btn2-press)}
:root[data-style="studio"] .shx-pop,:root [data-style="studio"] .shx-pop,:root [data-style="studio"].shx-pop{width:288px;padding:var(--dm-s-4);border-radius:var(--dm-r-card)}
:root[data-style="studio"] .shx-days button,:root [data-style="studio"] .shx-days button,:root [data-style="studio"].shx-days button{border-radius:var(--dm-r-pill);transition:background-color var(--dm-t-fast) var(--dm-ease),color var(--dm-t-fast) var(--dm-ease)}
recurring-jobs.jsHTML · 95 lines
DM.def('recurring-jobs', (r, c) => {
  r.innerHTML = r.innerHTML.replace('{plus}', I('plus','xs')).replace('{clock}', I('clock','xs'));
  // in this preview it is Saturday afternoon, so Monday at 9:00 is two days off, and every new schedule runs at 9:00. A run's
  // mark is its tool's logo, or its icon on a vivid tile of its colour
  const R = [
    { mark:'palette', col:'l', name:'Weekly design QA', when:'Mondays at 9:00', next:'Next in 2 days', on:true, res:'ok', ago:'5 days ago' },
    { mark:'@figma', name:'Sync tokens from Figma', when:'Every day at 8:00', next:'Next in 17h', on:true, res:'bad', why:'Figma token expired', fix:'Reconnect Figma' },
    { mark:'chart', col:'t', name:'Competitor price check', when:'Fridays at 17:00', next:'Next in 6 days', on:true, res:'ok', ago:'yesterday' }
  ];
  const root = $('.shx', r) || r, list = $('.shx-list', r), add = $('.shx-add', r), pop = $('.shx-pop', r), form = $('.shx-f', r);
  const inp = $('.shx-in', r), days = $('.shx-days', r), sum = $('.shx-sum', r), mk = $('.shx-mk', r);
  function row(x){
    const ic = x.mark[0] === '@' ? `<span class="ic brandic" aria-hidden="true">${BRAND[x.mark.slice(1)]}</span>` : `<span class="ic" style="background:var(--dm-av-${x.col});color:var(--dm-av-${x.col}-ink)" aria-hidden="true">${I(x.mark,'xs')}</span>`;
    x.el = html(`<div class="shx-r" role="listitem">${ic}<span class="t"><span class="nm"></span><span class="d"></span><span class="res"></span></span><span class="shx-act"><button class="pill ghost sm shx-run mx-press">Run now</button><button class="toggle" role="switch"></button></span><div class="shx-fx fold shut" inert><div><div><button class="pill accent sm shx-fix"></button></div></div></div></div>`);
    $('.nm', x.el).textContent = x.name; $('.shx-run', x.el).setAttribute('aria-label', 'Run ' + x.name + ' now'); $('.toggle', x.el).setAttribute('aria-label', x.name);
    $('.shx-run', x.el).onclick = () => run(x);
    $('.toggle', x.el).onclick = () => { x.on = !x.on; paint(x); };
    $('.shx-fix', x.el).onclick = () => fix(x);
    paint(x, true); return x.el;
  }
  // the result line, led by its mark: a tick when it passed, a sign when it failed, a turning ring while it runs (its words
  // shimmer, as every line of a process at work)
  function paint(x, now){
    const el = x.el, put = (e, t, h) => now ? (h ? e.innerHTML = t : e.textContent = t) : swap(e, t, h);
    el.classList.toggle('off', !x.on); el.dataset.st = x.run ? 'run' : x.res || 'none';
    const tg = $('.toggle', el); tg.setAttribute('aria-checked', x.on); tg.dataset.tip = x.on ? 'Pause' : 'Resume';
    put($('.d', el), x.when + ' · ' + (x.on ? x.next : 'Paused'));
    const res = document.createElement('span'); res.textContent = x.run ? 'Running now' : x.res === 'ok' ? 'Passed ' + x.ago : x.res === 'bad' ? 'Failed: ' + x.why : 'No runs yet';
    if (x.run) res.className = 'shim';
    put($('.res', el), (x.run ? '<span class="spin" aria-hidden="true"></span>' : x.res ? I(x.res === 'ok' ? 'ok' : 'alert', 'xs') : '') + res.outerHTML, true);
    $('.shx-run', el).disabled = !!x.run || !x.on;
    const fx = $('.shx-fx', el), on = x.res === 'bad' && !x.run, b = $('.shx-fix', el);
    if (on && !x.fixing){ b.textContent = x.fix; b.removeAttribute('aria-disabled'); }
    fx.classList.toggle('shut', !on); fx.inert = !on;
  }
  // Run now: the result's ring turns while it runs, then it passes
  function run(x){
    if (x.run) return; x.run = true; paint(x);
    c.later(3000, () => { x.run = false; x.res = 'ok'; x.ago = 'just now'; paint(x); });
  }
  // the fix for a failed run reconnects, then runs it again straight away. The button is as wide as its words and eases to
  // the new ones
  function fix(x){
    if (x.fixing) return; x.fixing = true; const b = $('.shx-fix', x.el), w0 = b.getBoundingClientRect().width;
    // it keeps its colour while it reconnects, and takes no second press
    b.setAttribute('aria-disabled', 'true'); b.innerHTML = '<span class="spin"></span>Reconnecting'; const w1 = b.getBoundingClientRect().width;
    const cs = getComputedStyle(b), t = cs.getPropertyValue('--dm-t').trim();
    if (!REDUCE && Math.abs(w1 - w0) > .5) b.animate([{ width:w0 + 'px' }, { width:w1 + 'px' }], { duration:(t.endsWith('ms') ? parseFloat(t) : parseFloat(t) * 1000) || 340, easing:cs.getPropertyValue('--dm-ease').trim() || 'ease' });
    c.later(900, () => { x.fixing = false; run(x); });
  }
  // the head is the title alone: no count that repeats what the rows say (the owner's notes on batch 2)
  R.forEach(x => list.appendChild(row(x))); stagger([...list.children], 50);
  // New schedule: a task in words and how often. Custom picks the days; the line under it says when the first run is
  const DAY = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], FULL = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
  days.innerHTML = DAY.map((d, i) => `<button type="button" aria-pressed="${i === 0 || i === 2 || i === 4}" aria-label="${FULL[i]}">${d[0]}</button>`).join('');
  let rep = 'day';
  const picked = () => rep === 'day' ? [0, 1, 2, 3, 4, 5, 6] : rep === 'mon' ? [0] : $$('button', days).map((b, i) => b.getAttribute('aria-pressed') === 'true' ? i : -1).filter(i => i >= 0);
  const when = ds => ds.length === 7 ? 'Every day at 9:00' : ds.join() === '0,1,2,3,4' ? 'Weekdays at 9:00' : ds.length === 1 ? FULL[ds[0]] + 's at 9:00' : ds.map(d => DAY[d]).join(', ') + ' at 9:00';
  // today is Saturday (5) after 9:00, so tomorrow's run is 18 hours off and the rest whole days
  const next = ds => { const n = Math.min(...ds.map(d => (d - 5 + 7) % 7 || 7)); return n === 1 ? 'Next in 18h' : `Next in ${n} days`; };
  function form1(){ const ds = picked(); sum.textContent = ds.length ? next(ds).replace('Next', 'First run') : 'Pick at least one day'; mk.disabled = !inp.value.trim() || !ds.length; }
  // a menu opens over the card from its button: down when it fits below, up when it doesn't and fits above or has more room
  // there (as placePop), within the stage's room, so it never spills over the card's caption under the stage (as Artifact
  // card's version menu). The side is set on the button just before the menu is placed
  const side = (btn, pop) => { const room = popRoom(btn), st = btn.closest('.stage-inner') || btn.closest('.stage');
    if (st){ const sr = st.getBoundingClientRect(), cs = getComputedStyle(st); room.top = Math.max(room.top, sr.top + parseFloat(cs.paddingTop)); room.bottom = Math.min(room.bottom, sr.bottom - parseFloat(cs.paddingBottom)); }
    const br = btn.getBoundingClientRect(), need = pop.offsetHeight + 12, below = room.bottom - br.bottom, above = br.top - room.top;
    btn.dataset.popPos = below < need && (above >= need || above > below) ? 'up' : 'down'; };
  // the form keeps the side it opened on: one that opened upwards grows upwards, held by its bottom edge
  const replace = () => { if (!(pop.style.getPropertyValue('--dm-origin') || '').startsWith('bottom')) side(add, pop); placePop(add, pop); };
  seg($('.shx-rep', r), v => { rep = v; days.hidden = v !== 'custom'; form1(); if (pop.classList.contains('open')) replace(); });
  $$('button', days).forEach(b => b.onclick = () => { b.setAttribute('aria-pressed', b.getAttribute('aria-pressed') !== 'true'); form1(); });
  inp.oninput = form1; form1();
  c.on(add, 'click', e => { if (pop.classList.contains('open')) return; side(add, pop); if (e.isTrusted) c.later(0, () => inp.focus({ preventScroll:true })); });
  c.on(form, 'submit', e => {
    e.preventDefault(); const ds = picked(); if (!inp.value.trim() || !ds.length) return;
    const x = { mark:'clock', col:'b', name:inp.value.trim(), when:when(ds), next:next(ds), on:true, res:null };
    R.push(x); list.appendChild(row(x)); enter(x.el); closePops(); inp.value = ''; form1();
  });
  // the card grows with its rows, and eases as a fix folds open or shut (owner, 17 Nov: no room kept for a later state)
  c.offs.push(grow(root));
  // the preview's story: run the design QA now and watch it pass, reconnect Figma so the token sync passes again, then
  // pause the price check
  c.story(async s => {
    const [qa, fig, price] = R;
    await s.beat(3);
    await s.point($('.shx-run', qa.el)); await s.beat(1);
    await s.tap($('.shx-run', qa.el)); s.away();
    await s.until(() => !qa.run && qa.ago === 'just now'); await s.beat(2);
    await s.tap($('.shx-fix', fig.el)); s.away();
    await s.until(() => !fig.run && fig.res === 'ok'); await s.beat(2);
    await s.tap($('.toggle', price.el)); s.away(); await s.beat(3);
  });
});
06

Questions

What people ask about it.

Does Run now start the run?
No. It calls onRunNow with the run's key. Start it in your own code, set its result to 'running', and to 'passed' or 'failed' when it ends.
How do I show a fix like reconnecting a service?
Give the failed run a fix label, like "Reconnect Figma". When onFix is called, set fixing while you reconnect, then run it again and update its result.
What time do new schedules run at?
At time, 9:00 unless you change it, with hour set to match so the form can say when the first run is. The days come back as numbers, 0 for Monday to 6 for Sunday.
Can I write schedules my own way?
Yes. schedule and next are plain text, so "Weekdays at 8:30" or "Next tomorrow" work as well.
What colours can a run's tile take?
Any colour in color. One of the avatar colours, like 'var(--dm-av-l)', gives the icon that colour's own ink; any other colour gives it white. A brand logo sits on a white tile instead.
07

More in Workspace

Navigation, search, settings, models and automations around the agent.

Tool railA board's tools in one vertical rail: pick one, and its name and key show on hover.
Zoom barUndo, redo, zoom and fit in one floating bar for a canvas.
Run drawerA workflow's run under its canvas: the steps, the log and the data.
Command paletteJump anywhere or hand a task to the agent from one box.
Team memoryWhat the agent remembers about your team, editable and removable.
Tools and connectionsThe tools the agent can reach, and how much it may do with each.
Knowledge sourcesThe files, sites and folders the agent knows, and how far each is indexed.
File explorerProject files, with the ones the agent touched marked.