kyd-shared-badge 0.1.20 → 0.1.22
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 +20 -41
- package/src/colors.ts +1 -1
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import { FiAlertTriangle, FiCpu, FiShield, FiThumbsUp } from 'react-icons/fi';
|
|
4
|
+
import { FiAlertTriangle } from 'react-icons/fi';
|
|
6
5
|
import { PublicBadgeData } from './types';
|
|
7
6
|
import ShareButton from './components/ShareButton';
|
|
8
7
|
import ReportHeader from './components/ReportHeader';
|
|
@@ -12,17 +11,6 @@ import IpRiskAnalysisDisplay from './components/IpRiskAnalysisDisplay';
|
|
|
12
11
|
import Image from 'next/image';
|
|
13
12
|
import { red, yellow, green } from './colors';
|
|
14
13
|
|
|
15
|
-
// Icon images from this package's public folder (will be bundled as assets)
|
|
16
|
-
import RiskGreen from './public/riskgreen.png';
|
|
17
|
-
import RiskYellow from './public/riskyellow.png';
|
|
18
|
-
import RiskRed from './public/riskred.png';
|
|
19
|
-
import CodeGreen from './public/codegreen.png';
|
|
20
|
-
import CodeYellow from './public/codeyellow.png';
|
|
21
|
-
import CodeRed from './public/codered.png';
|
|
22
|
-
import AiGreen from './public/aigreen.png';
|
|
23
|
-
import AiYellow from './public/aiyellow.png';
|
|
24
|
-
import AiRed from './public/aired.png';
|
|
25
|
-
|
|
26
14
|
const getScoreColor = (score: number) => {
|
|
27
15
|
if (score >= 80) return green;
|
|
28
16
|
if (score >= 65) return yellow;
|
|
@@ -38,27 +26,27 @@ const getRiskText = (risk: number) => {
|
|
|
38
26
|
|
|
39
27
|
// Helpers to map thresholds to icon images
|
|
40
28
|
const getTechnicalIconSrc = (score: number): string => {
|
|
41
|
-
if (score >= 80) return
|
|
42
|
-
if (score >= 65) return
|
|
43
|
-
return
|
|
29
|
+
if (score >= 80) return '/badge/codegreen.png';
|
|
30
|
+
if (score >= 65) return '/badge/codeyellow.png';
|
|
31
|
+
return '/badge/codered.png';
|
|
44
32
|
};
|
|
45
33
|
|
|
46
34
|
const getRiskIconSrc = (score: number): string => {
|
|
47
|
-
if (score >= 80) return
|
|
48
|
-
if (score >= 65) return
|
|
49
|
-
return
|
|
35
|
+
if (score >= 80) return '/badge/riskgreen.png';
|
|
36
|
+
if (score >= 65) return '/badge/riskyellow.png';
|
|
37
|
+
return '/badge/riskred.png';
|
|
50
38
|
};
|
|
51
39
|
|
|
52
40
|
const getAiIconSrc = (descriptor?: string): string => {
|
|
53
|
-
if (!descriptor) return
|
|
41
|
+
if (!descriptor) return '/badge/aiyellow.png';
|
|
54
42
|
const d = descriptor.toLowerCase();
|
|
55
43
|
if (d.indexOf('low') !== -1 || d.indexOf('transparent') !== -1 || d.indexOf('responsible') !== -1 || d.indexOf('conservative') !== -1) {
|
|
56
|
-
return
|
|
44
|
+
return '/badge/aigreen.png';
|
|
57
45
|
}
|
|
58
46
|
if (d.indexOf('medium') !== -1 || d.indexOf('moderate') !== -1 || d.indexOf('balanced') !== -1) {
|
|
59
|
-
return
|
|
47
|
+
return '/badge/aiyellow.png';
|
|
60
48
|
}
|
|
61
|
-
return
|
|
49
|
+
return '/badge/aired.png';
|
|
62
50
|
};
|
|
63
51
|
|
|
64
52
|
interface ScoreCardProps {
|
|
@@ -66,13 +54,12 @@ interface ScoreCardProps {
|
|
|
66
54
|
score: number;
|
|
67
55
|
description: string;
|
|
68
56
|
descriptor?: string;
|
|
69
|
-
icon: IconType;
|
|
70
57
|
scoreType: 'number' | 'risk' | 'descriptor';
|
|
71
58
|
isRecruiter?: boolean;
|
|
72
|
-
iconImageSrc
|
|
59
|
+
iconImageSrc: string;
|
|
73
60
|
}
|
|
74
61
|
|
|
75
|
-
const ScoreCard = ({ title, score, description, descriptor,
|
|
62
|
+
const ScoreCard = ({ title, score, description, descriptor, scoreType, isRecruiter = false, iconImageSrc }: ScoreCardProps) => {
|
|
76
63
|
const isDescriptor = scoreType === 'descriptor';
|
|
77
64
|
const scoreHex = isDescriptor ? undefined : getScoreColor(score);
|
|
78
65
|
const scoreClass = isDescriptor ? 'text-neutral-400' : '';
|
|
@@ -96,12 +83,7 @@ const ScoreCard = ({ title, score, description, descriptor, icon: Icon, scoreTyp
|
|
|
96
83
|
style={isRecruiter ? { backgroundColor: 'var(--content-card-background)', borderColor: 'var(--icon-button-secondary)' } : undefined}
|
|
97
84
|
>
|
|
98
85
|
<div className={`text-3xl mb-4 ${scoreClass}`} style={scoreHex ? { color: scoreHex } : undefined}>
|
|
99
|
-
|
|
100
|
-
// eslint-disable-next-line @next/next/no-img-element
|
|
101
|
-
<Image src={iconImageSrc} alt="icon" className="h-8 w-8 object-contain" />
|
|
102
|
-
) : (
|
|
103
|
-
<Icon />
|
|
104
|
-
)}
|
|
86
|
+
<Image src={iconImageSrc} alt="icon" width={32} height={32} className="h-8 w-8 object-contain" />
|
|
105
87
|
</div>
|
|
106
88
|
<h3 className={`font-semibold text-xl ${isDescriptor ? 'text-neutral-400' : ''}`} style={isRecruiter ? { color: 'var(--text-main)' } : undefined}>{title}</h3>
|
|
107
89
|
<p className={`text-4xl font-bold ${scoreClass}`} style={scoreHex ? { color: scoreHex } : undefined}>{displayScore}</p>
|
|
@@ -158,26 +140,23 @@ const SharedBadgeDisplay = ({ badgeData, type = 'individual' }: { badgeData: Pub
|
|
|
158
140
|
title="KYD Technical™"
|
|
159
141
|
score={devTrustScore?.score || 0}
|
|
160
142
|
description={devTrustScore?.description || ''}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
iconImageSrc={getTechnicalIconSrc(devTrustScore?.score || 0)}
|
|
143
|
+
scoreType='number'
|
|
144
|
+
isRecruiter={isRecruiter}
|
|
145
|
+
iconImageSrc={getTechnicalIconSrc(devTrustScore?.score || 0)}
|
|
165
146
|
/>
|
|
166
147
|
<ScoreCard
|
|
167
148
|
title="KYD Risk™"
|
|
168
149
|
score={riskScore?.score || 0}
|
|
169
150
|
description={riskScore?.description || ''}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
iconImageSrc={getRiskIconSrc(riskScore?.score || 0)}
|
|
151
|
+
scoreType='risk'
|
|
152
|
+
isRecruiter={isRecruiter}
|
|
153
|
+
iconImageSrc={getRiskIconSrc(riskScore?.score || 0)}
|
|
174
154
|
/>
|
|
175
155
|
<ScoreCard
|
|
176
156
|
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>}
|
|
177
157
|
score={0}
|
|
178
158
|
description={aiUsageScore?.description || 'Analysis of AI tool usage and transparency.'}
|
|
179
159
|
descriptor={aiUsageScore?.descriptor}
|
|
180
|
-
icon={FiCpu}
|
|
181
160
|
scoreType='descriptor'
|
|
182
161
|
isRecruiter={isRecruiter}
|
|
183
162
|
iconImageSrc={getAiIconSrc(aiUsageScore?.descriptor)}
|
package/src/colors.ts
CHANGED