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 holdPositionOnExit={!alwaysVisible}
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 label={formatChatTimestampTooltip(createdAt, timestampFormat, m)}
39 >
40 {formatDayAwareTimestamp(createdAt, timestampFormat, undefined, undefined, m)}
41 </SharedTooltipTrigger>
42 );
43}
44
45export function ActivityShimmerOverlay({
46 children,
47 className,
48}: {
49 children: ReactNode;
50 className?: string;
51}) {
52 return (
53 <span
54 aria-hidden
55 className="live-activity-focus pointer-events-none absolute inset-y-0 select-none"
56 >
57 <span className="live-activity-focus-counter block">
58 <span className={cn("live-activity-focus-aligned block text-foreground", className)}>
59 {children}
60 </span>
61 </span>
62 </span>
63 );
64}