kyd-shared-badge 0.3.96 → 0.3.97
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 +2 -1
- package/src/components/GaugeCard.tsx +20 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kyd-shared-badge",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.97",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"module": "./src/index.ts",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"@chatscope/chat-ui-kit-react": "^2.1.1",
|
|
23
23
|
"@chatscope/chat-ui-kit-styles": "^1.4.0",
|
|
24
24
|
"@knowyourdeveloper/react-bubble-chart": "^1.0.5",
|
|
25
|
+
"@knowyourdeveloper/react-gauge-component": "^1.1.30",
|
|
25
26
|
"@radix-ui/react-slot": "^1.2.3",
|
|
26
27
|
"@radix-ui/react-tooltip": "^1.2.8",
|
|
27
28
|
"ai": "5.0.47",
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import GaugeComponent from '@knowyourdeveloper/react-gauge-component';
|
|
4
5
|
import BusinessRuleLink from './BusinessRuleLink';
|
|
5
6
|
import { FiInfo } from 'react-icons/fi';
|
|
6
|
-
import { hexToRgba, scoreToColorHex, scoreToCssVar, clampPercent } from '../colors';
|
|
7
|
+
import { hexToRgba, scoreToColorHex, scoreToCssVar, clampPercent, red, yellow, green } from '../colors';
|
|
7
8
|
|
|
8
9
|
type TopMover = { label?: string; uid?: string };
|
|
9
10
|
|
|
@@ -28,13 +29,7 @@ export default function GaugeCard({
|
|
|
28
29
|
}) {
|
|
29
30
|
const pct = clampPercent(percent);
|
|
30
31
|
const displayLabel = label || '';
|
|
31
|
-
//
|
|
32
|
-
const size = 280;
|
|
33
|
-
const strokeWidth = 32;
|
|
34
|
-
const radius = (size - strokeWidth) / 2;
|
|
35
|
-
const circumference = Math.PI * radius;
|
|
36
|
-
const progress = pct / 100;
|
|
37
|
-
const dash = circumference * progress;
|
|
32
|
+
// Keep card tinting consistent with score
|
|
38
33
|
const progressColor = scoreToCssVar(pct);
|
|
39
34
|
const headerTint = hexToRgba(scoreToColorHex(pct), 0.06);
|
|
40
35
|
|
|
@@ -69,11 +64,23 @@ export default function GaugeCard({
|
|
|
69
64
|
</div>
|
|
70
65
|
<div className="flex-grow flex flex-col items-center justify-center" style={{ minHeight: 200 }}>
|
|
71
66
|
<div className="relative group" style={{ width: '100%', aspectRatio: '2 / 1', maxWidth: 360 }}>
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
<GaugeComponent
|
|
68
|
+
type="semicircle"
|
|
69
|
+
style={{ width: '100%', height: '100%' }}
|
|
70
|
+
value={pct}
|
|
71
|
+
minValue={0}
|
|
72
|
+
maxValue={100}
|
|
73
|
+
arc={{
|
|
74
|
+
padding: 0.02,
|
|
75
|
+
// Explicit subArcs ensure left->right map: red -> yellow -> green
|
|
76
|
+
subArcs: [
|
|
77
|
+
{ limit: 33, color: red },
|
|
78
|
+
{ limit: 66, color: yellow },
|
|
79
|
+
{ limit: 100, color: green },
|
|
80
|
+
],
|
|
81
|
+
}}
|
|
82
|
+
pointer={{ type: 'blob', elastic: true, animationDelay: 0 }}
|
|
83
|
+
/>
|
|
77
84
|
{(tooltipText || description) && (
|
|
78
85
|
<div className="hidden group-hover:block absolute z-30 left-1/2 -translate-x-1/2 top-full mt-2 w-80">
|
|
79
86
|
<div style={{ background: 'var(--content-card-background)', border: '1px solid var(--icon-button-secondary)', color: 'var(--text-main)', padding: 10, borderRadius: 6 }}>
|