Data display
Timeline
Events or steps in order, with the line on the start side. A step can show its state, its duration and a detail. A failed step opens to show its detail.
import { Timeline } from "@percentsa/ui";Examples
- 09:12Order placedDone
- 09:14Paid with madaDone
- 11:40PackedRiyadh warehouse
- TomorrowOut for delivery
- TomorrowDelivered
Code
export function TimelineExample() {
const t = useT();
return (
<Timeline
className="w-full max-w-sm"
items={[
{ id: "placed", time: "09:12", title: t("Order placed", "تم الطلب"), status: "done" },
{ id: "paid", time: "09:14", title: t("Paid with mada", "تم الدفع عبر مدى"), status: "done" },
{ id: "packed", time: "11:40", title: t("Packed", "تم التغليف"), description: t("Riyadh warehouse", "مستودع الرياض"), status: "current" },
{ id: "out", time: t("Tomorrow", "غدًا"), title: t("Out for delivery", "خرج للتوصيل"), status: "next" },
{ id: "delivered", time: t("Tomorrow", "غدًا"), title: t("Delivered", "تم التسليم"), status: "next" },
]}
/>
);
}- 4 sDone
- 1 min 12 sFailed
$ bun run build error: Cannot find module './shop' exit code 1
- Skipped
- Waiting
Selected: Build
Code
export function TimelineStepsExample() {
const t = useT();
const [selected, setSelected] = useState("build");
const names: Record<string, string> = { clone: t("Clone", "استنساخ"), build: t("Build", "بناء"), start: t("Start", "تشغيل"), check: t("Check", "فحص") };
return (
<div className="grid w-full max-w-sm gap-4">
<Timeline
onSelect={setSelected}
items={[
{ id: "clone", title: t("Clone", "استنساخ"), status: "done", duration: t("4 s", "4 ث") },
{
id: "build",
title: t("Build", "بناء"),
status: "failed",
duration: t("1 min 12 s", "1 د 12 ث"),
detail: (
<pre dir="ltr" className="font-mono text-xs whitespace-pre-wrap">
{"$ bun run build\nerror: Cannot find module './shop'\nexit code 1"}
</pre>
),
},
{ id: "start", title: t("Start", "تشغيل"), status: "skipped" },
{ id: "check", title: t("Check", "فحص"), status: "waiting" },
]}
/>
<p className="text-sm text-fg-2">
{t("Selected: ", "المحدد: ")}
{names[selected]}
</p>
</div>
);
}