-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathCapabilityIcon.tsx
More file actions
53 lines (45 loc) · 1.02 KB
/
CapabilityIcon.tsx
File metadata and controls
53 lines (45 loc) · 1.02 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { Icon } from '@iconify/react';
import {
ChatIcon,
ToolsIcon,
InfoCircleFilledIcon,
ShareIcon,
ChartIcon,
SettingIcon,
RefreshIcon,
EditIcon,
DeleteIcon,
} from 'tdesign-icons-react';
interface IconProps {
size?: string | number;
className?: string;
}
const iconMap: Record<string, React.ComponentType<IconProps>> = {
ChatIcon,
ToolsIcon,
InfoCircleFilledIcon,
ShareIcon,
ChartIcon,
SettingIcon,
RefreshIcon,
EditIcon,
DeleteIcon,
};
interface CapabilityIconProps {
iconName: string;
size?: number;
className?: string;
}
export default function CapabilityIcon({ iconName, size = 18, className = '' }: CapabilityIconProps) {
if (!iconName) {
return null;
}
const IconComponent = iconMap[iconName];
if (IconComponent) {
return <IconComponent size={size} className={className} />;
}
if (iconName.includes(':')) {
return <Icon icon={iconName} width={size} height={size} className={className} />;
}
return <span className={className}>{iconName}</span>;
}