-
Notifications
You must be signed in to change notification settings - Fork 267
Expand file tree
/
Copy pathconnectionIcon.tsx
More file actions
36 lines (31 loc) · 938 Bytes
/
connectionIcon.tsx
File metadata and controls
36 lines (31 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { cn, CodeHostType, getCodeHostIcon } from "@/lib/utils";
import { useMemo } from "react";
import Image from "next/image";
import placeholderLogo from "@/public/placeholder_avatar.png";
interface ConnectionIconProps {
type: string;
className?: string;
}
export const ConnectionIcon = ({
type,
className,
}: ConnectionIconProps) => {
const Icon = useMemo(() => {
const iconInfo = getCodeHostIcon(type as CodeHostType);
if (iconInfo) {
return (
<Image
src={iconInfo.src}
className={cn(cn("rounded-full w-8 h-8", iconInfo.className), className)}
alt={`${type} logo`}
/>
)
}
return <Image
src={placeholderLogo}
alt={''}
className={cn("rounded-full w-8 h-8", className)}
/>
}, [className, type]);
return Icon;
}