({
latency,
isLoading,
className,
})
| 17 | } |
| 18 | |
| 19 | export const Latency: FC<LatencyProps> = ({ |
| 20 | latency, |
| 21 | isLoading, |
| 22 | className, |
| 23 | }) => { |
| 24 | // Always use the no latency color for loading. |
| 25 | const latencyColor = getLatencyColor(isLoading ? undefined : latency); |
| 26 | |
| 27 | if (isLoading) { |
| 28 | return ( |
| 29 | <Tooltip> |
| 30 | <TooltipTrigger asChild> |
| 31 | {/** |
| 32 | * Spinning progress icon must be placed inside a fixed-size container, |
| 33 | * to ensure tooltip remains stationary when opened |
| 34 | */} |
| 35 | <div |
| 36 | className={cn( |
| 37 | "size-4 flex flex-wrap place-content-center", |
| 38 | className, |
| 39 | )} |
| 40 | > |
| 41 | <Spinner loading className={cn("!size-icon-xs", latencyColor)} /> |
| 42 | </div> |
| 43 | </TooltipTrigger> |
| 44 | <TooltipContent side="bottom">Loading latency...</TooltipContent> |
| 45 | </Tooltip> |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | if (!latency) { |
| 50 | return ( |
| 51 | <Tooltip> |
| 52 | <TooltipTrigger asChild> |
| 53 | <CircleHelpIcon |
| 54 | aria-label="Latency not available" |
| 55 | className={cn("!size-icon-sm", latencyColor, className)} |
| 56 | /> |
| 57 | </TooltipTrigger> |
| 58 | <TooltipContent side="bottom">Latency not available</TooltipContent> |
| 59 | </Tooltip> |
| 60 | ); |
| 61 | } |
| 62 | |
| 63 | return ( |
| 64 | <div className={cn("text-sm", latencyColor, className)}> |
| 65 | <span className="sr-only">Latency: </span> |
| 66 | {latency.toFixed(0)} |
| 67 | <Abbr title="milliseconds">ms</Abbr> |
| 68 | </div> |
| 69 | ); |
| 70 | }; |
nothing calls this directly
no test coverage detected