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