chore(client): document MUI default fallbacks in getResponseColor

Annotate the hex literals used when callers omit theme colours so the intent (defensive MUI default match) is obvious instead of looking like arbitrary values.
This commit is contained in:
gorkem-bwl authored and Alex Holliday committed 2026-04-27 10:52:23 -07:00
1 parent 7a0da57663
commit 0e532f16d4
1 file changed
+5 -3
+5 -3
View File
@@ -56,10 +56,12 @@ export const getResponseColor = (
// 0–300ms: interpolate start (good) -> mid (warning) // 0–300ms: interpolate start (good) -> mid (warning)
// 300–600ms: interpolate mid (warning) -> end (error) // 300–600ms: interpolate mid (warning) -> end (error)
// >600ms: solid end (error) // >600ms: solid end (error)
// MUI default success/warning/error.main values, used only when the caller
// fails to pass theme colors (defensive — keeps the gradient meaningful).
const safe = { ...colors }; const safe = { ...colors };
if (!safe.start) safe.start = "#4caf50"; // fallback green if (!safe.start) safe.start = "#4caf50";
if (!safe.mid) safe.mid = "#ff9800"; // fallback orange if (!safe.mid) safe.mid = "#ff9800";
if (!safe.end) safe.end = "#f44336"; // fallback red if (!safe.end) safe.end = "#f44336";
const toHex = (c: number) => c.toString(16).padStart(2, "0"); const toHex = (c: number) => c.toString(16).padStart(2, "0");
const clamp = (n: number) => Math.min(255, Math.max(0, Math.round(n))); const clamp = (n: number) => Math.min(255, Math.max(0, Math.round(n)));