Projekte: Tonabbildung fuer Preview-, Analyse- und Projektstatus
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5647412e34
commit
9da42d52c3
2 files changed
+74
No files matched your search
@@ -0,0 +1,55 @@
|
||||
/* Tonabbildung der Projekt-Bausteine: reine Zuordnung, ohne JSX (Test: tests/unit/projectTones.test.mjs).
|
||||
Die Töne sind die Namen der Logik aus Badge.jsx: ok, warn, info, danger, muted, plain.
|
||||
Jede Zuordnung ist eine Map, kein Objekt: sonst liefert ein Schlüssel wie 'constructor' eine Funktion. */
|
||||
|
||||
// previewStatus().color (lib/previewView.js)
|
||||
const PREVIEW_COLOR_TONES = new Map([
|
||||
['green', 'ok'],
|
||||
['yellow', 'warn'],
|
||||
['red', 'danger'],
|
||||
['grey', 'plain'],
|
||||
])
|
||||
|
||||
// previewState der Services-Antwort (online, building, starting, sleeping, failed, off)
|
||||
const PREVIEW_STATE_TONES = new Map([
|
||||
['online', 'ok'],
|
||||
['building', 'warn'],
|
||||
['starting', 'warn'],
|
||||
['sleeping', 'warn'],
|
||||
['failed', 'danger'],
|
||||
])
|
||||
|
||||
// analyseStatus().color (lib/analyseView.js)
|
||||
const ANALYSE_COLOR_TONES = new Map([
|
||||
['green', 'ok'],
|
||||
['red', 'danger'],
|
||||
])
|
||||
|
||||
// status und provisioningStatus eines Projekts, wie die Farbtabelle STATUS_COLORS in AssignedProjectCard heute.
|
||||
// 'deployed' ist absichtlich nicht dabei: es blieb dort in der Standardfarbe (grau).
|
||||
const STATUS_VALUE_TONES = new Map([
|
||||
['ready', 'ok'],
|
||||
['live', 'ok'],
|
||||
['online', 'ok'],
|
||||
['provisioning', 'warn'],
|
||||
['pending', 'warn'],
|
||||
['building', 'info'],
|
||||
['error', 'danger'],
|
||||
['failed', 'danger'],
|
||||
])
|
||||
|
||||
export function previewColorTone(color) {
|
||||
return PREVIEW_COLOR_TONES.get(color) ?? 'plain'
|
||||
}
|
||||
|
||||
export function previewStateTone(state) {
|
||||
return PREVIEW_STATE_TONES.get(state) ?? 'plain'
|
||||
}
|
||||
|
||||
export function analyseColorTone(color) {
|
||||
return ANALYSE_COLOR_TONES.get(color) ?? 'muted'
|
||||
}
|
||||
|
||||
export function statusValueTone(value) {
|
||||
return STATUS_VALUE_TONES.get(String(value ?? '').toLowerCase()) ?? 'muted'
|
||||
}
|
||||
Reference in new issue
Block a user