Skip to content

Commit 02aaf0a

Browse files
committed
Add lifecycle marker to badge
1 parent 0e961e6 commit 02aaf0a

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

utils/badge.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ export function generate_badge(svc) {
2323
const slider = 60;
2424
const padding = 25;
2525
const divider_offset = 0;
26-
const marker_size = 32;
26+
const marker_size = 40;
2727

2828
const bg_color = "#EEEEEE";
29-
const kicker_color = "#888888";
29+
const kicker_color = "#AAAAAA";
3030
const title_color = "brown";
3131
const text_color = "#222222";
3232
const line_color = "brown";
@@ -45,7 +45,14 @@ export function generate_badge(svc) {
4545
if (desc_lines.length > 3) {
4646
desc_lines[2] += " ...";
4747
}
48-
const criticality_class = svc.criticality.charAt(0)
48+
const criticality_class = svc.criticality.charAt(0);
49+
const lifecycle_class = {
50+
"1 - Planlagt": "✧",
51+
"1.1- Pilot/Testdrift": "⚙︎",
52+
"2 - Produksjon": "︎✓",
53+
"3 - Under utfasing": "✗",
54+
"4 - Avviklet": "⚱︎"
55+
}[svc.lifecycle];
4956

5057
let svg = `
5158
<svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -59,7 +66,7 @@ export function generate_badge(svc) {
5966
<text x="${border_width + slider/2}" y="${height/2-5}" text-anchor="middle" font-family="Courier" font-size="40" font-weight="bold" fill="${bg_color}">TJ</text>
6067
<text x="${border_width + slider/2}" y="${height/2+5}" text-anchor="middle" font-family="Verdana" font-size="8" font-weight="bold" fill="${bg_color}">katalogen</text>
6168
62-
<text x="${border_width + slider + padding}" y="40" font-family="monospace" font-size="18" fill="${kicker_color}" font-weight="normal">
69+
<text x="${border_width + slider + padding}" y="40" font-family="monospace" font-size="18" fill="${kicker_color}" font-weight="bold">
6370
${svc.id}
6471
</text>
6572
@@ -80,8 +87,12 @@ export function generate_badge(svc) {
8087
</text>
8188
8289
<!-- critically class -->
83-
<rect x="${width - border_width - marker_size - 20 }" y="20" width="${marker_size}" height="${marker_size}" rx="4" fill="#ffffff" stroke="${line_color}" stroke-width="1.5" />
84-
<text x="${width - border_width - marker_size/2 - 20 }" y="${20 + marker_size/2 + marker_size/10}" text-anchor="middle" alignment-baseline="middle" fill="${title_color}" font-family="${font_family}" font-weight="bold" font-size="${marker_size}">${criticality_class}</text>
90+
<rect x="${width - border_width - marker_size - 20 }" y="20" width="${marker_size}" height="${marker_size}" rx="6" fill="${line_color}" stroke="none" />
91+
<text x="${width - border_width - marker_size/2 - 20 }" y="${20 + marker_size/2 + marker_size*0.8/10}" text-anchor="middle" alignment-baseline="middle" fill="${bg_color}" font-family="${font_family}" font-weight="bold" font-size="${marker_size*0.8}">${criticality_class}</text>
92+
93+
<!-- lifecycle class -->
94+
<rect x="${width - border_width - marker_size - 20 - (marker_size*1 + 8) }" y="20" width="${marker_size}" height="${marker_size}" rx="6" fill="${line_color}" stroke="none" />
95+
<text x="${width - border_width - marker_size/2 - 20 - (marker_size*1 + 8) }" y="${20 + marker_size/2}" text-anchor="middle" alignment-baseline="middle" fill="${bg_color}" font-family="${font_family}" font-weight="normal" font-size="${marker_size*0.8}">${lifecycle_class}</text>
8596
8697
<use href="#outline" fill="none" stroke="${line_color}" />
8798
</svg>`;

0 commit comments

Comments
 (0)