Open History to see the last commit
1import { useMessages } from "gt-react";
2import { type ReactNode } from "react";
3import { cn } from "~/lib/utils";
4import { type TimestampFormat } from "@t3tools/contracts/settings";
5import { formatChatTimestampTooltip, formatDayAwareTimestamp } from "../../timestampFormat";
6import { SharedTooltipTrigger } from "../ui/shared-tooltip";
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 <SharedTooltipTrigger
28 render={
29 <span
30 className={cn(
31 "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",
32 alwaysVisible && "pointer-events-auto static opacity-100",
33 className,
34 )}
35 />
36 }
37 label={formatChatTimestampTooltip(createdAt, timestampFormat, m)}
38 >
39 {formatDayAwareTimestamp(createdAt, timestampFormat, undefined, undefined, m)}
40 </SharedTooltipTrigger>
41 );
42}
43
44export function ActivityShimmerOverlay({
45 children,
46 className,
47}: {
48 children: ReactNode;
49 className?: string;
50}) {
51 return (
52 <span
53 aria-hidden
54 className="live-activity-focus pointer-events-none absolute inset-y-0 select-none"
55 >
56 <span className="live-activity-focus-counter block">
57 <span className={cn("live-activity-focus-aligned block text-foreground", className)}>
58 {children}
59 </span>
60 </span>
61 </span>
62 );
63}