-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathicon.tsx
More file actions
101 lines (95 loc) · 1.85 KB
/
icon.tsx
File metadata and controls
101 lines (95 loc) · 1.85 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import clsx from 'clsx';
import type { IconName } from '../iconNames';
type IconRotate = 90 | 180 | 270;
type IconColor =
| 'mint-50'
| 'mint-100'
| 'mint-200'
| 'mint-300'
| 'mint-400'
| 'mint-500'
| 'mint-600'
| 'mint-700'
| 'mint-800'
| 'mint-900'
| 'pink-50'
| 'pink-100'
| 'pink-200'
| 'pink-300'
| 'pink-400'
| 'pink-500'
| 'pink-600'
| 'pink-700'
| 'pink-800'
| 'pink-900'
| 'gray-50'
| 'gray-100'
| 'gray-200'
| 'gray-300'
| 'gray-400'
| 'gray-500'
| 'gray-600'
| 'gray-700'
| 'gray-800'
| 'gray-900'
| 'blue-400'
| 'red-300'
| 'red-400'
| 'background'
| 'foreground';
interface IconProps extends React.SVGProps<SVGSVGElement> {
name: IconName;
size?: number | string;
width?: number | string;
height?: number | string;
color?: IconColor;
className?: string;
rotate?: IconRotate;
hasRotateAnimation?: boolean;
ariaHidden?: boolean;
}
export const Icon = ({
name,
size,
width,
height,
color,
className,
rotate,
hasRotateAnimation = false,
ariaHidden = true,
style,
...rest
}: IconProps) => {
const w = width ?? size ?? 20;
const h = height ?? size ?? 20;
const rotateClass =
rotate === 90
? 'rotate-90'
: rotate === 180
? 'rotate-180'
: rotate === 270
? 'rotate-[270deg]'
: '';
const combined = clsx(
'inline-block',
'transform',
rotateClass,
hasRotateAnimation && 'transition-transform duration-200',
className,
);
return (
<svg
fill='currentColor'
stroke='currentColor'
width={typeof w === 'number' ? `${w}px` : w}
height={typeof h === 'number' ? `${h}px` : h}
className={combined}
style={{ ...(color && { color: `var(--color-${color})` }), ...style }}
aria-hidden={ariaHidden}
{...rest}
>
<use href={`#icon-${name}`} />
</svg>
);
};