Open History to see the last commit
1import type { ReactNode } from "react";
2import type { LucideIcon } from "lucide-react";
3
4import { cn } from "~/lib/utils";
5import { Tooltip, TooltipPopup, TooltipTrigger } from "~/components/ui/tooltip";
6
7export function TimelineSystemDivider(props: {
8 readonly label: string;
9 readonly detail?: ReactNode | null;
10 readonly tone?: "neutral" | "danger";
11 readonly icon?: LucideIcon;
12 readonly showDetailSeparator?: boolean;
13 readonly wrapDetail?: boolean;
14 readonly actionLabel?: string;
15 readonly onAction?: () => void;
16}) {
17 const Icon = props.icon;
18 const content = (
19 <>
20 {Icon ? <Icon className="size-3 shrink-0" /> : null}
21 <span className="font-medium">{props.label}</span>
22 {props.detail ? (
23 <span
24 className={cn(
25 "inline-flex min-w-0 items-center opacity-70",
26 typeof props.detail === "string" &&
27 (props.wrapDetail ? "max-w-80 whitespace-pre-wrap" : "max-w-80 truncate"),
28 )}
29 >
30 {props.showDetailSeparator === false ? null : "·\u00a0"}
31 {props.detail}
32 </span>
33 ) : null}
34 </>
35 );
36
37 return (
38 <div
39 className={cn(
40 "flex min-w-0 items-center gap-2 py-2 text-2xs text-muted-foreground",
41 props.tone === "danger" && "text-destructive",
42 )}
43 >
44 <span aria-hidden="true" className="h-px flex-1 bg-border/70" />
45 {props.onAction ? (
46 <Tooltip>
47 <TooltipTrigger
48 render={
49 <button
50 type="button"
51 aria-label={props.actionLabel}
52 onClick={props.onAction}
53 className="flex min-w-0 cursor-pointer items-center gap-1.5 rounded-full border border-border/70 bg-background px-2.5 py-1 transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70"
54 />
55 }
56 >
57 {content}
58 </TooltipTrigger>
59 <TooltipPopup side="top">{props.actionLabel}</TooltipPopup>
60 </Tooltip>
61 ) : (
62 <span className="flex min-w-0 flex-wrap items-center justify-center gap-1.5 rounded-full px-2 py-1">
63 {content}
64 </span>
65 )}
66 <span aria-hidden="true" className="h-px flex-1 bg-border/70" />
67 </div>
68 );
69}