-
Notifications
You must be signed in to change notification settings - Fork 776
Expand file tree
/
Copy pathlucide.ts
More file actions
37 lines (31 loc) · 975 Bytes
/
lucide.ts
File metadata and controls
37 lines (31 loc) · 975 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
37
import * as LucideIcons from "lucide-static";
const icons = {};
for (const icon in LucideIcons) {
let iconSvg = LucideIcons[icon];
if (icon == "default") {
continue;
}
// set stroke-width to 1.5
if (iconSvg && iconSvg.includes("stroke-width")) {
iconSvg = iconSvg.replace(/stroke-width="2"/g, 'stroke-width="1.5"');
}
icons[icon] = iconSvg;
const dashKeys = camelToDash(icon);
for (const dashKey of dashKeys) {
if (dashKey !== icon) {
icons[dashKey] = iconSvg;
}
}
}
export default icons;
function camelToDash(key) {
// barChart2 -> bar-chart-2
const withNumber = key.replace(/[A-Z0-9]/g, (m) => "-" + m.toLowerCase());
// barChart2 -> bar-chart2
const withoutNumber = key.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase());
if (withNumber !== withoutNumber) {
// both are required because unplugin icon resolver doesn't put a dash before numbers
return [withNumber, withoutNumber];
}
return [withNumber];
}