Open History to see the last commit
1import { type ReactNode } from "react";
2import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
3import { cn } from "~/lib/utils";
4import { type TimestampFormat } from "@t3tools/contracts/settings";
5import { formatChatTimestampTooltip, formatDayAwareTimestamp } from "../../timestampFormat";
6
7export const MESSAGE_HEADING_LEVEL = 3;
8
9export function MessageAuthorHeading({ children }: { children: string }) {
10 return <h3 className="sr-only select-none">{children}</h3>;
11}
12
13export function TimelineRowTimestamp({
14 createdAt,
15 timestampFormat,
16 className,
17 alwaysVisible = false,
18}: {
19 createdAt: string;
20 timestampFormat: TimestampFormat;
21 className?: string;
22 alwaysVisible?: boolean;
23}) {
24 return (
25 <Tooltip>
26 <TooltipTrigger
27 render={
28 <span
29 className={cn(
30 "pointer-events-none absolute me-1 shrink-0 whitespace-nowrap rounded-md text-muted-foreground text-xs tabular-nums opacity-0 group-hover/timeline-row:pointer-events-auto group-hover/timeline-row:static group-hover/timeline-row:opacity-100 group-focus-within/timeline-row:pointer-events-auto group-focus-within/timeline-row:static group-focus-within/timeline-row:opacity-100",
31 alwaysVisible && "pointer-events-auto static opacity-100",
32 className,
33 )}
34 />
35 }
36 >
37 {formatDayAwareTimestamp(createdAt, timestampFormat)}
38 </TooltipTrigger>
39 <TooltipPopup>{formatChatTimestampTooltip(createdAt, timestampFormat)}</TooltipPopup>
40 </Tooltip>
41 );
42}
43
44export function ActivityShimmerOverlay({ children }: { children: ReactNode }) {
45 return (
46 <span
47 aria-hidden
48 className="live-activity-focus pointer-events-none absolute inset-y-0 select-none"
49 >
50 <span className="live-activity-focus-counter block">
51 <span className="live-activity-focus-aligned block text-foreground">{children}</span>
52 </span>
53 </span>
54 );
55}