Open History to see the last commit
1import { cn } from "~/lib/utils";
2import { Tooltip, TooltipPopup, TooltipTrigger } from "~/components/ui/tooltip";
3
4type ConnectionStatusDotProps = {
5 tooltipText?: string | null;
6 dotClassName: string;
7 pingClassName?: string | null;
8};
9
10export function ConnectionStatusDot({
11 tooltipText,
12 dotClassName,
13 pingClassName,
14}: ConnectionStatusDotProps) {
15 const dotContent = (
16 <>
17 {pingClassName ? (
18 <span
19 className={cn(
20 "absolute inline-flex h-full w-full animate-ping rounded-full",
21 pingClassName,
22 )}
23 />
24 ) : null}
25 <span className={cn("relative inline-flex size-2 rounded-full", dotClassName)} />
26 </>
27 );
28
29 if (!tooltipText) {
30 return (
31 <span className="relative flex size-3 shrink-0 items-center justify-center">
32 {dotContent}
33 </span>
34 );
35 }
36
37 const dot = (
38 <button
39 type="button"
40 title={tooltipText}
41 aria-label={tooltipText}
42 className="relative flex size-3 shrink-0 cursor-help items-center justify-center rounded-full outline-hidden"
43 >
44 {dotContent}
45 </button>
46 );
47
48 return (
49 <Tooltip>
50 <TooltipTrigger render={dot} />
51 <TooltipPopup side="top" className="max-w-80 whitespace-pre-wrap leading-tight">
52 {tooltipText}
53 </TooltipPopup>
54 </Tooltip>
55 );
56}