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 committed 2026-04-26 01:22:06 -04:00
1 parent c6db7e6479
commit da70d07051
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)));