Icon.tsx
1.33 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
export type IconName = 'check-circle' | 'chevron-down' | 'chevron-left' | 'chevron-right' | 'close-circle' | 'info-circle' | 'search' | 'warning-circle';
export interface IconProps {
name: IconName;
size?: number;
label?: string;
className?: string;
}
const paths: Record<IconName, string> = {
'check-circle': 'M9 12l2 2 4-5 M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18',
'chevron-down': 'M6 9l6 6 6-6',
'chevron-left': 'M15 6l-6 6 6 6',
'chevron-right': 'M9 6l6 6-6 6',
'close-circle': 'M9 9l6 6 M15 9l-6 6 M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18',
'info-circle': 'M12 10v6 M12 7h.01 M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18',
search: 'M10.5 17a6.5 6.5 0 1 1 4.6-1.9L20 20',
'warning-circle': 'M12 8v5 M12 16h.01 M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18',
};
/** 组件库内部统一图标资产,避免各组件散落使用临时文本箭头。 */
export function Icon({ className, label, name, size = 16 }: IconProps) {
return (
<svg
aria-hidden={label ? undefined : 'true'}
aria-label={label}
className={className}
data-icon={name}
fill="none"
height={size}
role={label ? 'img' : undefined}
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2.4"
viewBox="0 0 24 24"
width={size}
>
<path d={paths[name]} />
</svg>
);
}