Files
craftvia/src/lib/risk.ts
T
msolarczekandClaude Opus 5 c8e6f30a27
CI / build-and-check (push) Canceled after 0s
CI / audit (push) Canceled after 0s
CI / sbom (push) Canceled after 0s
Basis: Certvia dev@a48c5fb als Fundament für Craftvia
Unveränderter Stand von certvia/dev (a48c5fb) plus Craftvia-Spezifikation
und Brandbook unter docs/craftvia/. ISMS-Module werden im Folgecommit entfernt.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 11:05:39 +02:00

38 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/** Score-Bänder der 5×5-Matrix (Farben/Stufen aus dem Mockup). */
export type RiskLevelKey = "low" | "medium" | "elevated" | "high" | "critical";
export function riskLevel(score: number): RiskLevelKey {
if (score >= 20) return "critical";
if (score >= 15) return "high";
if (score >= 10) return "elevated";
if (score >= 5) return "medium";
return "low";
}
/** Zellen-Hintergrund der Heatmap — kräftige Ampelfarben (auf Dunkel kontrastreich). */
export const RISK_CELL_COLORS: Record<RiskLevelKey, string> = {
low: "#2ea86b",
medium: "#e3b427",
elevated: "#e2802e",
high: "#e0553f",
critical: "#d63c5e",
};
/** Sättigungsstarke Farbskala grün→rot für den Risiko-Score-Balken. */
export const RISK_SCALE_GRADIENT =
"linear-gradient(90deg,#2ec76b 0%,#e3b427 32%,#e2802e 60%,#e0553f 82%,#d63c5e 100%)";
/** Pillen-Ton je Stufe — gemäß Heatmap-Skala: Grün → Gelb → Orange → Rot. */
export const RISK_PILL_TONE: Record<RiskLevelKey, "ok" | "warn" | "orange" | "risk"> = {
low: "ok",
medium: "warn",
elevated: "orange",
high: "risk",
critical: "risk",
};
export function riskRef(refNo: number): string {
return `R-${String(refNo).padStart(3, "0")}`;
}