Skip to content
Notra logoNotra UI
Esc
↑↓navigate↵open⌘Jpreview
On this page

Timer

A ticking timer for how long a step has been running.

"use client";

import { useEffect, useState } from "react";

import { WorkflowTimer } from "../components/workflow-timer";

export default function WorkflowTimerExample() {
  const [ms, setMs] = useState(0);

  useEffect(() => {
    const started = performance.now();
    const id = window.setInterval(
      () => setMs((performance.now() - started) % 90_000),
      100
    );
    return () => window.clearInterval(id);
  }, []);

  return (
    <div className="flex flex-col items-start gap-3 text-sm">
      <span className="flex items-center gap-3">
        Crawling 214 pages <WorkflowTimer ms={ms} running />
      </span>
      <span className="flex items-center gap-3">
        Classified 37 listicles <WorkflowTimer ms={2240} />
      </span>
      <span className="flex items-center gap-3">
        Weekly visibility scan <WorkflowTimer ms={754_000} />
      </span>
    </div>
  );
}
$ bunx --bun shadcn@latest add @notra/workflow-timer

WorkflowTimer formats milliseconds as 1.4s or 12m 34s with tabular numbers, so it doesn’t jitter while it ticks. Set running to add a pulsing dot. Nodes, the run toolbar and the node sheet all use it.

Used in

GEO Workflow Builder

A workflow builder with a block palette, a playable canvas, a run log and a node sheet.