kyd-shared-badge 0.3.119 → 0.3.120

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.119",
3
+ "version": "0.3.120",
4
4
  "private": false,
5
5
  "main": "./src/index.ts",
6
6
  "module": "./src/index.ts",
@@ -5,7 +5,7 @@ import { normalizeLinkedInInput } from './linkedin';
5
5
  import type { ConnectAccountsProps } from './types';
6
6
  import { CheckCircle, Link2, LinkIcon, Unlink, ArrowLeft, ExternalLink, Settings, Shield, InfoIcon } from 'lucide-react';
7
7
  import { AnimatePresence, motion } from 'framer-motion';
8
- import { Button, Input, Spinner, Card, CardHeader, CardContent, CardFooter, CardTitle, ProgressCircle } from '../ui';
8
+ import { Button, Input, Spinner, Card, CardHeader, CardContent, CardFooter, CardTitle, ConnectProgress } from '../ui';
9
9
  import Link from 'next/link';
10
10
  import { Tooltip, TooltipTrigger, TooltipProvider, TooltipContent } from '../ui/';
11
11
 
@@ -222,32 +222,22 @@ export function ConnectAccounts(props: ConnectAccountsProps) {
222
222
  return setupAction === 'install' || setupAction === 'created';
223
223
  }, [githubConnectedAccount]);
224
224
 
225
- // Progress computation
226
- const targetProviderIds = useMemo(() => {
227
- const targets = (requiredProviders && requiredProviders.length
228
- ? requiredProviders
229
- : providers.map(p => p.id))
230
- .map(id => id.toLowerCase());
231
- return new Set(targets);
232
- }, [requiredProviders, providers]);
233
- const numConnectedTargets = useMemo(() => {
234
- let count = 0;
235
- targetProviderIds.forEach(id => { if (connectedIds.has(id)) count += 1; });
236
- return count;
237
- }, [targetProviderIds, connectedIds]);
238
- const progressPercent = useMemo(() => {
239
- const total = targetProviderIds.size;
240
- if (!total) return 0;
241
- return Math.round((numConnectedTargets / total) * 100);
242
- }, [numConnectedTargets, targetProviderIds]);
225
+ // Progress UI is outsourced to ConnectProgress
243
226
 
244
227
  return (
245
228
  <>
229
+ {/* Mobile: relative summary above content */}
246
230
  {providers?.length ? (
247
- <div className="fixed sm:bottom-6 sm:right-6 bottom-4 right-4 z-50 pointer-events-none">
248
- <ProgressCircle value={progressPercent} size={68} thickness={6} />
231
+ <div className="sm:hidden px-4 mb-3">
232
+ <ConnectProgress layout="inline" providers={providers} connectedIds={connectedIds} />
249
233
  </div>
250
234
  ) : null}
235
+
236
+ {/* Desktop: fixed top-right summary */}
237
+ {providers?.length ? (
238
+ <ConnectProgress providers={providers} connectedIds={connectedIds} />
239
+ ) : null}
240
+
251
241
  <AnimatePresence initial={false} mode="wait">
252
242
  {showDataHandling ? (
253
243
  <motion.div
@@ -0,0 +1,97 @@
1
+ 'use client'
2
+ import React, { useMemo } from 'react'
3
+ import { Card, CardContent } from './card'
4
+ import { ProgressCircle } from './progress-circle'
5
+
6
+ export type ConnectProgressProps = {
7
+ providers: Array<{ id: string; name: string }>
8
+ connectedIds: Set<string>
9
+ className?: string
10
+ layout?: 'fixed-desktop' | 'inline'
11
+ }
12
+
13
+ export function ConnectProgress(props: ConnectProgressProps) {
14
+ const { providers, connectedIds, className, layout = 'fixed-desktop' } = props
15
+
16
+ const hasGithub = connectedIds.has('github')
17
+ const hasLinkedIn = connectedIds.has('linkedin')
18
+ const otherConnectedCount = useMemo(() => {
19
+ let count = 0
20
+ connectedIds.forEach(id => { if (id !== 'github' && id !== 'linkedin') count += 1 })
21
+ return count
22
+ }, [connectedIds])
23
+
24
+ const progressPercent = useMemo(() => {
25
+ const githubWeight = hasGithub ? 65 : 0
26
+ const linkedinWeight = hasLinkedIn ? 15 : 0
27
+ const othersWeight = Math.min(otherConnectedCount, 2) * 10
28
+ return Math.max(0, Math.min(100, githubWeight + linkedinWeight + othersWeight))
29
+ }, [hasGithub, hasLinkedIn, otherConnectedCount])
30
+
31
+ const progressCopy = useMemo(() => {
32
+ const score = progressPercent
33
+ if (score === 0) {
34
+ return {
35
+ headline: 'Get started — connect GitHub',
36
+ body: 'GitHub contributes ~65% of your profile strength. Add LinkedIn (+15%) and 1–2 other platforms (+10% each). 70%+ is strong; 100% is optional.'
37
+ }
38
+ }
39
+ if (hasGithub && score < 70) {
40
+ return {
41
+ headline: 'Good base — add more signals',
42
+ body: 'Add LinkedIn (+15%) and at least one other platform (+10%) to reach 70%+, which is considered strong. 100% is not mandatory.'
43
+ }
44
+ }
45
+ if (!hasGithub && score < 70) {
46
+ return {
47
+ headline: 'Add GitHub for a big boost',
48
+ body: 'Current signals are light. Connecting GitHub adds ~65% weight and significantly improves your profile.'
49
+ }
50
+ }
51
+ if (score >= 70 && score < 90) {
52
+ return {
53
+ headline: 'Strong — recommended coverage achieved',
54
+ body: '70%+ indicates a strong profile. Adding more platforms can further improve verification. 100% is optional but even better.'
55
+ }
56
+ }
57
+ if (score >= 90) {
58
+ return {
59
+ headline: 'Excellent — high confidence',
60
+ body: 'You are near complete coverage. 100% is not required, but additional platforms can further increase confidence.'
61
+ }
62
+ }
63
+ return {
64
+ headline: 'Keep going',
65
+ body: 'Connect more platforms to strengthen your profile. 70%+ is strong; 100% is optional.'
66
+ }
67
+ }, [progressPercent, hasGithub])
68
+
69
+ const content = (
70
+ <Card className={`border-[var(--icon-button-secondary)] ${className || ''}`} style={{ backgroundColor: 'var(--content-card-background)'}}>
71
+ <CardContent className="py-3 px-3">
72
+ <div className="flex items-center gap-3">
73
+ <ProgressCircle value={progressPercent} size={64} thickness={6} />
74
+ <div className="min-w-0 max-w-xs">
75
+ <div className="text-sm font-semibold truncate" style={{ color: 'var(--text-main)'}}>{progressCopy.headline}</div>
76
+ <div className="text-xs mt-0.5" style={{ color: 'var(--text-secondary)'}}>
77
+ {progressCopy.body}
78
+ </div>
79
+ <div className="text-[10px] mt-1" style={{ color: 'var(--text-secondary)'}}>
80
+ Weighted score • {progressPercent}%
81
+ </div>
82
+ </div>
83
+ </div>
84
+ </CardContent>
85
+ </Card>
86
+ )
87
+
88
+ if (layout === 'inline') return content
89
+
90
+ return (
91
+ <div className="hidden sm:block fixed top-6 right-6 z-50">{content}</div>
92
+ )
93
+ }
94
+
95
+ export default ConnectProgress
96
+
97
+
package/src/ui/index.ts CHANGED
@@ -4,4 +4,5 @@ export * from './input';
4
4
  export * from './textarea';
5
5
  export * from './spinner';
6
6
  export * from './tooltip';
7
- export * from './progress-circle';
7
+ export * from './progress-circle';
8
+ export * from './connect-progress';