Skip to content

Commit bc41ea1

Browse files
chore: update metrics badge component (#35)
1 parent 16c3f00 commit bc41ea1

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

src/components/MetricsBadge.tsx

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import type { Icon } from '@phosphor-icons/react';
2+
13
interface MetricsBadgeProps {
24
href: string;
35
value: string | number;
4-
icon: React.ComponentType<{ size: number; className?: string }>;
6+
icon: Icon;
57
variant?: 'desktop' | 'mobile';
68
loading?: boolean;
79
}
@@ -10,8 +12,8 @@ export default function MetricsBadge({
1012
href,
1113
value,
1214
icon: Icon,
13-
variant,
14-
loading
15+
variant = 'desktop',
16+
loading = false
1517
}: MetricsBadgeProps) {
1618
const linkClass =
1719
variant === 'desktop'
@@ -26,18 +28,19 @@ export default function MetricsBadge({
2628
? 'font-medium text-gray-700 group-hover:text-orange-700'
2729
: 'font-medium text-gray-700';
2830

31+
if (loading) {
32+
return (
33+
<div className="flex items-center gap-1.5 rounded-lg border border-gray-200 bg-white/80 px-3 py-1.5">
34+
<div className="h-3.5 w-3.5 animate-pulse rounded bg-gray-200" />
35+
<div className="h-4 w-12 animate-pulse rounded bg-gray-200" />
36+
</div>
37+
);
38+
}
39+
2940
return (
30-
<>
31-
{loading ? (
32-
<div className="animate-pulse rounded-lg bg-gray-200 px-3 py-1.5">
33-
<div className="h-4 w-8 rounded bg-gray-300"></div>
34-
</div>
35-
) : (
36-
<a href={href} target="_blank" rel="noopener noreferrer" className={linkClass}>
37-
<Icon size={14} className={iconClass} />
38-
<span className={textClass}>{value}</span>
39-
</a>
40-
)}
41-
</>
41+
<a href={href} target="_blank" rel="noopener noreferrer" className={linkClass}>
42+
<Icon size={14} className={iconClass} />
43+
<span className={textClass}>{value}</span>
44+
</a>
4245
);
4346
}

0 commit comments

Comments
 (0)