kyd-shared-badge 0.1.13 → 0.1.14
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 +1 -1
- package/src/SharedBadgeDisplay.tsx +47 -2
- package/src/colors.ts +26 -0
- package/src/components/ReportHeader.tsx +4 -6
- package/src/images.d.ts +4 -0
package/package.json
CHANGED
|
@@ -10,6 +10,17 @@ import AppendixTables from './components/AppendixTables';
|
|
|
10
10
|
import ProviderInsights from './components/ProviderInsights';
|
|
11
11
|
import IpRiskAnalysisDisplay from './components/IpRiskAnalysisDisplay';
|
|
12
12
|
|
|
13
|
+
// Icon images from this package's public folder (will be bundled as assets)
|
|
14
|
+
import RiskGreen from '../public/riskgreen.png';
|
|
15
|
+
import RiskYellow from '../public/riskyellow.png';
|
|
16
|
+
import RiskRed from '../public/riskred.png';
|
|
17
|
+
import CodeGreen from '../public/codegreen.png';
|
|
18
|
+
import CodeYellow from '../public/codeyellow.png';
|
|
19
|
+
import CodeRed from '../public/codered.png';
|
|
20
|
+
import AiGreen from '../public/aigreen.png';
|
|
21
|
+
import AiYellow from '../public/aiyellow.png';
|
|
22
|
+
import AiRed from '../public/aired.png';
|
|
23
|
+
|
|
13
24
|
const getScoreColor = (score: number) => {
|
|
14
25
|
if (score >= 80) return 'text-[#6A9846]';
|
|
15
26
|
if (score >= 65) return 'text-[#EABE52]';
|
|
@@ -23,6 +34,31 @@ const getRiskText = (risk: number) => {
|
|
|
23
34
|
return 'Critical Risk';
|
|
24
35
|
};
|
|
25
36
|
|
|
37
|
+
// Helpers to map thresholds to icon images
|
|
38
|
+
const getTechnicalIconSrc = (score: number): string => {
|
|
39
|
+
if (score >= 80) return CodeGreen as unknown as string;
|
|
40
|
+
if (score >= 65) return CodeYellow as unknown as string;
|
|
41
|
+
return CodeRed as unknown as string;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const getRiskIconSrc = (score: number): string => {
|
|
45
|
+
if (score >= 80) return RiskGreen as unknown as string;
|
|
46
|
+
if (score >= 65) return RiskYellow as unknown as string;
|
|
47
|
+
return RiskRed as unknown as string;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const getAiIconSrc = (descriptor?: string): string => {
|
|
51
|
+
if (!descriptor) return AiYellow as unknown as string;
|
|
52
|
+
const d = descriptor.toLowerCase();
|
|
53
|
+
if (d.indexOf('low') !== -1 || d.indexOf('transparent') !== -1 || d.indexOf('responsible') !== -1 || d.indexOf('conservative') !== -1) {
|
|
54
|
+
return AiGreen as unknown as string;
|
|
55
|
+
}
|
|
56
|
+
if (d.indexOf('medium') !== -1 || d.indexOf('moderate') !== -1 || d.indexOf('balanced') !== -1) {
|
|
57
|
+
return AiYellow as unknown as string;
|
|
58
|
+
}
|
|
59
|
+
return AiRed as unknown as string;
|
|
60
|
+
};
|
|
61
|
+
|
|
26
62
|
interface ScoreCardProps {
|
|
27
63
|
title: React.ReactNode;
|
|
28
64
|
score: number;
|
|
@@ -31,9 +67,10 @@ interface ScoreCardProps {
|
|
|
31
67
|
icon: IconType;
|
|
32
68
|
scoreType: 'number' | 'risk' | 'descriptor';
|
|
33
69
|
isRecruiter?: boolean;
|
|
70
|
+
iconImageSrc?: string; // optional image-based icon
|
|
34
71
|
}
|
|
35
72
|
|
|
36
|
-
const ScoreCard = ({ title, score, description, descriptor, icon: Icon, scoreType, isRecruiter = false }: ScoreCardProps) => {
|
|
73
|
+
const ScoreCard = ({ title, score, description, descriptor, icon: Icon, scoreType, isRecruiter = false, iconImageSrc }: ScoreCardProps) => {
|
|
37
74
|
const scoreColor = scoreType === 'descriptor' ? 'text-neutral-400' : getScoreColor(score);
|
|
38
75
|
let displayScore;
|
|
39
76
|
|
|
@@ -55,7 +92,12 @@ const ScoreCard = ({ title, score, description, descriptor, icon: Icon, scoreTyp
|
|
|
55
92
|
style={isRecruiter ? { backgroundColor: 'var(--content-card-background)', borderColor: 'var(--icon-button-secondary)' } : undefined}
|
|
56
93
|
>
|
|
57
94
|
<div className={`text-3xl mb-4 ${scoreColor}`}>
|
|
58
|
-
|
|
95
|
+
{iconImageSrc ? (
|
|
96
|
+
// eslint-disable-next-line @next/next/no-img-element
|
|
97
|
+
<img src={iconImageSrc} alt="icon" className="h-8 w-8 object-contain" />
|
|
98
|
+
) : (
|
|
99
|
+
<Icon />
|
|
100
|
+
)}
|
|
59
101
|
</div>
|
|
60
102
|
<h3 className={`font-semibold text-xl ${scoreType === 'descriptor' ? 'text-neutral-400' : ''}`} style={isRecruiter ? { color: 'var(--text-main)' } : undefined}>{title}</h3>
|
|
61
103
|
<p className={`text-4xl font-bold ${scoreColor}`}>{displayScore}</p>
|
|
@@ -115,6 +157,7 @@ const SharedBadgeDisplay = ({ badgeData, type = 'individual' }: { badgeData: Pub
|
|
|
115
157
|
icon={FiThumbsUp}
|
|
116
158
|
scoreType='number'
|
|
117
159
|
isRecruiter={isRecruiter}
|
|
160
|
+
iconImageSrc={getTechnicalIconSrc(devTrustScore?.score || 0)}
|
|
118
161
|
/>
|
|
119
162
|
<ScoreCard
|
|
120
163
|
title="KYD Risk™"
|
|
@@ -123,6 +166,7 @@ const SharedBadgeDisplay = ({ badgeData, type = 'individual' }: { badgeData: Pub
|
|
|
123
166
|
icon={FiShield}
|
|
124
167
|
scoreType='risk'
|
|
125
168
|
isRecruiter={isRecruiter}
|
|
169
|
+
iconImageSrc={getRiskIconSrc(riskScore?.score || 0)}
|
|
126
170
|
/>
|
|
127
171
|
<ScoreCard
|
|
128
172
|
title={<span>KYD AI™ <span className="text-xs font-semibold bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200 px-2 py-1 rounded-full align-middle">Beta</span></span>}
|
|
@@ -132,6 +176,7 @@ const SharedBadgeDisplay = ({ badgeData, type = 'individual' }: { badgeData: Pub
|
|
|
132
176
|
icon={FiCpu}
|
|
133
177
|
scoreType='descriptor'
|
|
134
178
|
isRecruiter={isRecruiter}
|
|
179
|
+
iconImageSrc={getAiIconSrc(aiUsageScore?.descriptor)}
|
|
135
180
|
/>
|
|
136
181
|
</div>
|
|
137
182
|
|
package/src/colors.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const redColors = [
|
|
2
|
+
'#EC6662',
|
|
3
|
+
'#F1908C',
|
|
4
|
+
'#F5B7B3',
|
|
5
|
+
'#FADBDA',
|
|
6
|
+
'#FDF0EF',
|
|
7
|
+
]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
const yellowColors = [
|
|
11
|
+
'#FADBDA',
|
|
12
|
+
'#F2CA8C',
|
|
13
|
+
'#F9DFB6',
|
|
14
|
+
'#FDEFDB',
|
|
15
|
+
'#FEF9F0',
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
const greenColors = [
|
|
19
|
+
'#48A08A',
|
|
20
|
+
'#7BB9AA',
|
|
21
|
+
'#A5CCC2',
|
|
22
|
+
'#D5E8E2',
|
|
23
|
+
'#EEF6F4',
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
export { redColors, yellowColors, greenColors }
|
|
@@ -24,11 +24,9 @@ const ReportHeader = ({ badgeId, developerName, updatedAt, score = 0, isPublic,
|
|
|
24
24
|
const isRecruiter = type === 'recruiter';
|
|
25
25
|
|
|
26
26
|
const formattedDate = updatedAt ? new Date(updatedAt).toLocaleString(undefined, {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
hour: 'numeric',
|
|
31
|
-
minute: '2-digit',
|
|
27
|
+
year: 'numeric',
|
|
28
|
+
month: 'long',
|
|
29
|
+
day: 'numeric',
|
|
32
30
|
}) : 'N/A';
|
|
33
31
|
|
|
34
32
|
return (
|
|
@@ -63,7 +61,7 @@ const ReportHeader = ({ badgeId, developerName, updatedAt, score = 0, isPublic,
|
|
|
63
61
|
<div className={isRecruiter ? 'text-left text-sm space-y-1' : 'text-left text-sm text-neutral-600 dark:text-neutral-400 space-y-1'} style={isRecruiter ? { color: 'var(--text-secondary)' } : undefined}>
|
|
64
62
|
<p><span className={isRecruiter ? 'font-semibold' : 'font-semibold text-neutral-800 dark:text-neutral-200'} style={isRecruiter ? { color: 'var(--text-main)' } : undefined}>Requested By:</span> {developerName || 'N/A'}</p>
|
|
65
63
|
<p><span className={isRecruiter ? 'font-semibold' : 'font-semibold text-neutral-800 dark:text-neutral-200'} style={isRecruiter ? { color: 'var(--text-main)' } : undefined}>Organization:</span> Unaffiliated</p>
|
|
66
|
-
<p><span className={isRecruiter ? 'font-semibold' : 'font-semibold text-neutral-800 dark:text-neutral-200'} style={isRecruiter ? { color: 'var(--text-main)' } : undefined}>Date
|
|
64
|
+
<p><span className={isRecruiter ? 'font-semibold' : 'font-semibold text-neutral-800 dark:text-neutral-200'} style={isRecruiter ? { color: 'var(--text-main)' } : undefined}>Date Generated:</span> {formattedDate}</p>
|
|
67
65
|
<p><span className={isRecruiter ? 'font-semibold' : 'font-semibold text-neutral-800 dark:text-neutral-200'} style={isRecruiter ? { color: 'var(--text-main)' } : undefined}>Report ID:</span> {badgeId}</p>
|
|
68
66
|
</div>
|
|
69
67
|
</div>
|
package/src/images.d.ts
ADDED