kyd-shared-badge 0.3.97 → 0.3.99

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.97",
3
+ "version": "0.3.99",
4
4
  "private": false,
5
5
  "main": "./src/index.ts",
6
6
  "module": "./src/index.ts",
@@ -21,7 +21,7 @@
21
21
  "@aws-sdk/lib-dynamodb": "^3.893.0",
22
22
  "@chatscope/chat-ui-kit-react": "^2.1.1",
23
23
  "@chatscope/chat-ui-kit-styles": "^1.4.0",
24
- "@knowyourdeveloper/react-bubble-chart": "^1.0.5",
24
+ "@knowyourdeveloper/react-bubble-chart": "^1.0.6",
25
25
  "@knowyourdeveloper/react-gauge-component": "^1.1.30",
26
26
  "@radix-ui/react-slot": "^1.2.3",
27
27
  "@radix-ui/react-tooltip": "^1.2.8",
@@ -27,6 +27,7 @@ import UseCases from './components/UseCases';
27
27
  import SummaryCards from './components/SummaryCards';
28
28
  import GaugeCard from './components/GaugeCard';
29
29
  import RiskCard from './components/RiskCard';
30
+ import RoleOverviewCard from './components/RoleOverviewCard';
30
31
  import TopContributingFactors from './components/TopContributingFactors';
31
32
  import AiUsageBody from './components/AiUsageBody';
32
33
  import SanctionsMatches from './components/SanctionsMatches';
@@ -226,22 +227,17 @@ const SharedBadgeDisplay = ({ badgeData, chatProps, headless }: { badgeData: Pub
226
227
  />
227
228
  </div>
228
229
  {/* Top-right: Role match section */}
229
- <div className={'rounded-lg border p-4'} style={{ borderColor: 'var(--icon-button-secondary)' }}>
230
- <div className={'text-lg font-semibold mb-2'} style={{ color: 'var(--text-main)' }}>Role Alignment</div>
230
+ <div>
231
231
  {(() => {
232
232
  const em = assessmentResult?.enterprise_match;
233
233
  if (!em) return <div className={'text-sm'} style={{ color: 'var(--text-secondary)' }}>No role match available.</div>;
234
234
  const role = em.role || {};
235
235
  return (
236
- <div className={'space-y-2'}>
237
- <div className={'flex items-center gap-2'}>
238
- <div className={'font-semibold'} style={{ color: 'var(--text-main)' }}>{role?.name || 'Role'}</div>
239
- <span className={'px-2 py-0.5 rounded text-xs font-semibold'} style={{ backgroundColor: 'var(--content-card-background)', border: '1px solid var(--icon-button-secondary)', color: 'var(--text-main)' }}>{em.label}</span>
240
- </div>
241
- {em.description ? (
242
- <div className={'text-sm'} style={{ color: 'var(--text-secondary)' }}>{em.description}</div>
243
- ) : null}
244
- </div>
236
+ <RoleOverviewCard
237
+ title={'Role Alignment'}
238
+ matchLabel={em.label}
239
+ roleName={role?.name || 'Role'}
240
+ />
245
241
  );
246
242
  })()}
247
243
  </div>
@@ -291,10 +287,11 @@ const SharedBadgeDisplay = ({ badgeData, chatProps, headless }: { badgeData: Pub
291
287
  <SkillsBubble skillsCategoryRadar={graphInsights?.skillsCategoryRadar} headless={isHeadless} skillsByCategory={assessmentResult?.graph_insights?.skillsByCategory} skillsMeta={assessmentResult?.graph_insights?.skillsMeta} />
292
288
  </div>
293
289
  </Reveal>
294
- <div className={'pt-6 text-sm text-center'} style={{ color: 'var(--text-secondary)' }}>
290
+
291
+ </div>
292
+ <div className={'pt-6 text-sm text-center'} style={{ color: 'var(--text-secondary)' }}>
295
293
  Report Completed: {formatLocalDateTime(updatedAt)}
296
294
  </div>
297
- </div>
298
295
  </div>
299
296
  );
300
297
 
@@ -70,6 +70,13 @@ export default function GaugeCard({
70
70
  value={pct}
71
71
  minValue={0}
72
72
  maxValue={100}
73
+ labels={{
74
+ valueLabel: {
75
+ // Show backend-provided label in the center instead of percent
76
+ formatTextValue: () => displayLabel,
77
+ matchColorWithArc: true,
78
+ },
79
+ }}
73
80
  arc={{
74
81
  padding: 0.02,
75
82
  // Explicit subArcs ensure left->right map: red -> yellow -> green
@@ -0,0 +1,92 @@
1
+ 'use client';
2
+
3
+ import React, { useMemo } from 'react';
4
+ import GaugeComponent from '@knowyourdeveloper/react-gauge-component';
5
+ import { clampPercent, hexToRgba, scoreToColorHex, red, yellow, green } from '../colors';
6
+
7
+ export default function RoleOverviewCard({
8
+ title,
9
+ matchLabel,
10
+ roleName,
11
+ }: {
12
+ title: string;
13
+ matchLabel?: string;
14
+ roleName?: string;
15
+ }) {
16
+ const pct = useMemo(() => {
17
+ const raw = String(matchLabel || '').toLowerCase();
18
+ let mapped = 0;
19
+ if (raw.includes('optimal')) mapped = 100;
20
+ else if (raw.includes('strong')) mapped = 75;
21
+ else if (raw.includes('partial')) mapped = 50;
22
+ else if (raw.includes('weak')) mapped = 25;
23
+ else mapped = 0; // incompatible or unknown
24
+ return clampPercent(mapped);
25
+ }, [matchLabel]);
26
+
27
+ const headerTint = hexToRgba(scoreToColorHex(pct), 0.06);
28
+ const displayLabel = String(matchLabel || '').trim();
29
+
30
+ const segmentLabels = [
31
+ 'Incompatible',
32
+ 'Weak',
33
+ 'Partial',
34
+ 'Strong',
35
+ 'Optimal',
36
+ ];
37
+
38
+ return (
39
+ <div
40
+ className={'rounded-md p-5 border flex flex-col min-h-full'}
41
+ style={{
42
+ backgroundColor: 'var(--content-card-background)',
43
+ borderColor: 'var(--icon-button-secondary)',
44
+ backgroundImage: `linear-gradient(${headerTint}, ${headerTint})`,
45
+ }}
46
+ >
47
+ <div className="mb-3 flex items-start justify-between gap-2">
48
+ <div>
49
+ <div className={'font-semibold'} style={{ color: 'var(--text-main)' }}>{title}</div>
50
+ {roleName ? (
51
+ <div className={'text-xs mt-1'} style={{ color: 'var(--text-secondary)' }}>{roleName}</div>
52
+ ) : null}
53
+ </div>
54
+ </div>
55
+ <div className="flex-grow flex flex-col items-center justify-center" style={{ minHeight: 200 }}>
56
+ <div className="relative" style={{ width: '100%', aspectRatio: '2 / 1', maxWidth: 360 }}>
57
+ <GaugeComponent
58
+ type="semicircle"
59
+ style={{ width: '100%', height: '100%' }}
60
+ value={pct}
61
+ minValue={0}
62
+ maxValue={100}
63
+ labels={{
64
+ valueLabel: {
65
+ formatTextValue: () => displayLabel,
66
+ matchColorWithArc: true,
67
+ },
68
+ }}
69
+ arc={{
70
+ padding: 0.02,
71
+ gradient: true,
72
+ colorArray: [red, yellow, green],
73
+ }}
74
+ pointer={{ type: 'arrow', elastic: true, animationDelay: 0 }}
75
+ />
76
+ </div>
77
+ <div className="mt-3 w-full">
78
+ <div className="grid grid-cols-5 text-[10px] sm:text-xs" style={{ color: 'var(--text-secondary)' }}>
79
+ {segmentLabels.map((label, idx) => (
80
+ <div key={idx} className="flex flex-col items-center">
81
+ <div className="h-2 w-px" style={{ background: 'var(--icon-button-secondary)' }} />
82
+ <div className="mt-1 whitespace-nowrap">{label}</div>
83
+ </div>
84
+ ))}
85
+ </div>
86
+ </div>
87
+ </div>
88
+ </div>
89
+ );
90
+ }
91
+
92
+
@@ -57,6 +57,7 @@ export default function SkillsBubble({ skillsCategoryRadar, skillsByCategory, sk
57
57
  const legendRef = useRef<HTMLDivElement>(null);
58
58
  const [legendTooltip, setLegendTooltip] = useState<HoverTooltipState>(null);
59
59
  const [activeCategory, setActiveCategory] = useState<string | null>(null);
60
+ const [legendHovered, setLegendHovered] = useState<boolean>(false);
60
61
  useEffect(() => {
61
62
  if (typeof window !== 'undefined') {
62
63
  const id = window.setTimeout(() => {
@@ -114,9 +115,10 @@ export default function SkillsBubble({ skillsCategoryRadar, skillsByCategory, sk
114
115
  _id: String(b.label || ''),
115
116
  value: Number(b.value || 0),
116
117
  displayText: String(b.label || ''),
117
- colorValue: Number(b.data?.experience || 0)
118
+ colorValue: Number(b.data?.experience || 0),
119
+ selected: legendHovered && !!activeCategory && String(b.label || '') === String(activeCategory)
118
120
  }));
119
- }, [bubbles]);
121
+ }, [bubbles, legendHovered, activeCategory]);
120
122
 
121
123
  const colorLegend = useMemo(() => {
122
124
  return [green5, green4, green3, green2, green1];
@@ -215,7 +217,7 @@ export default function SkillsBubble({ skillsCategoryRadar, skillsByCategory, sk
215
217
  <div className="flex flex-col min-w-0 justify-center">
216
218
  <div className="flex items-center gap-2 min-w-0 text-lg text-[var(--text-main)]">
217
219
  <span className={'inline-block h-2 w-2 rounded-full'} style={{ backgroundColor: entry ? 'var(--icon-button-secondary)' : 'transparent', flexShrink: 0 }} />
218
- <span className="shrink-0 opacity-70">{idx + (isLeft ? 1 : 6)}.</span>
220
+ <span className="shrink-0 opacity-70 ">{idx + (isLeft ? 1 : 6)}.</span>
219
221
  {entry && typeof entry !== 'string' ? (
220
222
  <span className="truncate" title={entry.label}>{entry.label}</span>
221
223
  ) : (
@@ -254,7 +256,7 @@ export default function SkillsBubble({ skillsCategoryRadar, skillsByCategory, sk
254
256
  </div>
255
257
  {entry && typeof entry !== 'string' ? (
256
258
  <div className="flex flex-col items-end leading-tight h-full justify-between text-base">
257
- {entry.years ? <span className="whitespace-nowrap text-[var(--text-main)]">{`${entry.years} Years`}</span> : <span className="opacity-0 whitespace-nowrap text-[var(--text-main)]">0 Years</span>}
259
+ {entry.years ? <span className="whitespace-nowrap text-[var(--text-secondary)]">{`${entry.years} Years`}</span> : <span className="opacity-0 whitespace-nowrap text-[var(--text-secondary)]">0 Years</span>}
258
260
  {entry.presence ? (
259
261
  <div className="flex items-center gap-1">
260
262
  <span className="inline-block h-2 w-2 rounded-full text-sm" style={{ background: presenceColor(entry.presence) }} />
@@ -340,7 +342,13 @@ export default function SkillsBubble({ skillsCategoryRadar, skillsByCategory, sk
340
342
  />
341
343
  </div>
342
344
  <div className='mt-8'>
343
- <div ref={legendRef} className={'kyd-avoid-break'} style={{ position: 'relative', breakInside: 'avoid', pageBreakInside: 'avoid' as unknown as undefined }}>
345
+ <div
346
+ ref={legendRef}
347
+ className={'kyd-avoid-break'}
348
+ style={{ position: 'relative', breakInside: 'avoid', pageBreakInside: 'avoid' as unknown as undefined }}
349
+ onMouseEnter={() => setLegendHovered(true)}
350
+ onMouseLeave={() => setLegendHovered(false)}
351
+ >
344
352
  <div className="mb-2 text-xs font-medium" style={{ color: 'var(--text-main)' }}>
345
353
 
346
354
  {activeCategory ? (