Icon.tsx
1.94 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
54
55
56
57
58
59
60
61
62
63
64
65
66
export type IconName =
| 'check-circle'
| 'chevron-down'
| 'chevron-left'
| 'chevron-right'
| 'close-circle'
| 'download'
| 'eye'
| 'file'
| 'info-circle'
| 'play'
| 'plus'
| 'refresh'
| 'search'
| 'trash'
| 'upload'
| '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',
download: 'M12 3v12 M7 10l5 5 5-5 M5 21h14',
eye: 'M2.5 12s3.5-6 9.5-6 9.5 6 9.5 6-3.5 6-9.5 6-9.5-6-9.5-6 M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6',
file: 'M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8l-5-5z M14 3v5h5',
'info-circle': 'M12 10v6 M12 7h.01 M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18',
play: 'M8 5v14l11-7-11-7z',
plus: 'M12 5v14 M5 12h14',
refresh: 'M20 6v5h-5 M4 18v-5h5 M18.5 9A7 7 0 0 0 6.8 6.8L4 11 M5.5 15A7 7 0 0 0 17.2 17.2L20 13',
search: 'M10.5 17a6.5 6.5 0 1 1 4.6-1.9L20 20',
trash: 'M4 7h16 M10 11v6 M14 11v6 M6 7l1 14h10l1-14 M9 7V4h6v3',
upload: 'M12 21V9 M7 14l5-5 5 5 M5 21h14',
'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>
);
}