kyd-shared-badge 0.3.10 → 0.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kyd-shared-badge",
3
- "version": "0.3.10",
3
+ "version": "0.3.11",
4
4
  "private": false,
5
5
  "main": "./src/index.ts",
6
6
  "module": "./src/index.ts",
@@ -41,19 +41,27 @@ export default function RiskCard({
41
41
  return red;
42
42
  };
43
43
 
44
+ // color bands by bar position (tallest -> lowest)
45
+ // indices 4 and 3 (highest bars) => red, index 2 => yellow, indices 1 and 0 => green
46
+ const colorForIndex = (index: number) => {
47
+ if (index >= 3) return red;
48
+ if (index === 2) return yellow;
49
+ return green;
50
+ };
51
+
44
52
  const headerTint = hexToRgba(pickTint(pctGood), 0.06);
45
53
 
46
54
  // bar heights ascending representation
47
55
  const bars = [40, 60, 85, 110, 140];
48
- let activeIndex = 0; // Default to the shortest bar (highest risk)
56
+ let activeIndex = 4; // Default to the highest bar (0% score)
49
57
  if (pctGood >= 80) {
50
- activeIndex = 4;
58
+ activeIndex = 0;
51
59
  } else if (pctGood >= 60) {
52
- activeIndex = 3;
60
+ activeIndex = 1;
53
61
  } else if (pctGood >= 40) {
54
62
  activeIndex = 2;
55
63
  } else if (pctGood >= 20) {
56
- activeIndex = 1;
64
+ activeIndex = 3;
57
65
  }
58
66
 
59
67
  return (
@@ -88,7 +96,15 @@ export default function RiskCard({
88
96
  <div className="flex flex-col items-center justify-center gap-1" style={{ minHeight: 250 }}>
89
97
  <div className="relative group flex items-end justify-center gap-3">
90
98
  {bars.map((h, i) => (
91
- <div key={i} style={{ width: 36, height: h, backgroundColor: i === activeIndex ? 'var(--text-main)' : 'var(--icon-button-secondary)', borderRadius: 4 }} />
99
+ <div
100
+ key={i}
101
+ style={{
102
+ width: 36,
103
+ height: h,
104
+ backgroundColor: i === activeIndex ? colorForIndex(i) : 'var(--icon-button-secondary)',
105
+ borderRadius: 4,
106
+ }}
107
+ />
92
108
  ))}
93
109
  {(tooltipText || description) && (
94
110
  <div className="hidden group-hover:block absolute z-30 left-1/2 -translate-x-1/2 top-full mt-2 w-80">