mirror of
https://github.com/coder/coder.git
synced 2026-11-03 05:55:24 +08:00
This pull-request finds all of our previous instances of the MUI-based Latency `color`'s and updates them to use the equivalents form the Tailwind package.
30 lines
760 B
TypeScript
30 lines
760 B
TypeScript
const latencyColors = {
|
|
good: { text: "text-content-success", background: "bg-content-success" },
|
|
warning: {
|
|
text: "text-content-warning",
|
|
background: "bg-content-yellow",
|
|
},
|
|
critical: {
|
|
text: "text-content-destructive",
|
|
background: "bg-content-destructive",
|
|
},
|
|
unknown: {
|
|
text: "text-content-secondary",
|
|
background: "bg-content-secondary",
|
|
},
|
|
} as const;
|
|
|
|
type LatencyLevel = keyof typeof latencyColors;
|
|
|
|
const getLatencyLevel = (latency?: number): LatencyLevel => {
|
|
if (!latency) return "unknown";
|
|
if (latency < 150) return "good";
|
|
if (latency < 300) return "warning";
|
|
return "critical";
|
|
};
|
|
|
|
export const getLatencyColor = (
|
|
latency?: number,
|
|
type: "text" | "background" = "text",
|
|
) => latencyColors[getLatencyLevel(latency)][type];
|