Skip to content

Commit a8e0e77

Browse files
committed
feat: add simple icons
1 parent 7245d45 commit a8e0e77

File tree

9 files changed

+61437
-3264
lines changed

9 files changed

+61437
-3264
lines changed

content/icons/brands-icons/index.mdx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
---
22
title: Brands icons
33
description: React brands icons that you can copy and paste into your project.
4-
---
4+
---
5+
6+
<IconsExplorer libraries={["simple-icons"]} />

content/icons/index.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ description: Copy and paste icons for your React app
66
Beautiful icons for your React app. Copy and paste the icons you need. Credits to [Lucide icons](https://github.com/lucide-icons/lucide) and [Simple icons](https://github.com/simple-icons/simple-icons) for brands icons.
77
If you want to add another icon library, please [open a pull request](https://github.com/mehdibha/rcopy/pulls).
88

9-
<IconsExplorer />
9+
<IconsExplorer libraries={["lucide-icons"]} />

content/icons/lucide-icons/index.mdx

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
title: Lucide icons
33
description: Beautiful & consistent React icons made by the Lucide community that you can copy and paste into your apps.
44
---
5+
6+
<IconsExplorer libraries={["lucide-icons"]} />

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
"prettier-plugin-tailwindcss": "^0.5.7",
9191
"prisma": "^5.6.0",
9292
"rimraf": "^5.0.5",
93+
"simple-icons": "^11.8.0",
9394
"tailwindcss": "^3.3.5",
9495
"typescript": "^5.1.6"
9596
},

pnpm-lock.yaml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/build-icons.ts

+59-19
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
import { transform } from "@svgr/core";
22
import fs from "fs";
3-
import * as lucideIcons from "lucide-static";
3+
import lucideIcons from "lucide-static";
44
import path from "path";
55
import { rimraf } from "rimraf";
6-
6+
import * as simpleIcons from "simple-icons";
77

88
async function processLucideIcons() {
99
let index = `
1010
// This file is autogenerated by scripts/build-icons.ts
1111
// Do not edit this file directly.
12-
12+
1313
export const icons = [
1414
`;
1515
const promises = Object.keys(lucideIcons).map(async (name) => {
1616
const icon = lucideIcons[name as keyof typeof lucideIcons];
1717
// Using transform from @svgr/core to transform the SVG into a React component string
18-
const component = await transform(
19-
icon,
20-
{
21-
plugins: ["@svgr/plugin-jsx", "@svgr/plugin-prettier"],
22-
icon: true,
23-
},
24-
{ componentName: `${name}Icon` }
25-
);
26-
console.log(component);
27-
// Append the transformed SVG component to the index string
28-
index += ` {
18+
try {
19+
const component = await transform(
20+
icon,
21+
{
22+
plugins: ["@svgr/plugin-jsx", "@svgr/plugin-prettier"],
23+
icon: true,
24+
},
25+
{ componentName: `${name}Icon` }
26+
);
27+
// Append the transformed SVG component to the index string
28+
index += ` {
2929
name: \`${name}\`,
3030
icon: \`${icon}\`,
3131
code: \`${component}\`
3232
},`;
33+
} catch (error) {
34+
console.log(`Error processing ${name}`);
35+
console.log(lucideIcons[name as keyof typeof lucideIcons])
36+
}
3337
});
34-
try {
35-
await Promise.all(promises.slice(0, 10));
36-
} catch (e) {
37-
console.log(e);
38-
}
38+
await Promise.all(promises);
3939
index += `]`;
4040

4141
rimraf.sync(path.join(process.cwd(), "src", "autogenerated", "lucide-icons.ts"));
@@ -45,4 +45,44 @@ async function processLucideIcons() {
4545
);
4646
}
4747

48+
async function processSimpleIcons() {
49+
let index = `
50+
// This file is autogenerated by scripts/build-icons.ts
51+
// Do not edit this file directly.
52+
53+
export const icons = [
54+
`;
55+
const promises = Object.keys(simpleIcons).map(async (name) => {
56+
const icon = simpleIcons[name as keyof typeof simpleIcons];
57+
// Using transform from @svgr/core to transform the SVG into a React component string
58+
try {
59+
const component = await transform(
60+
icon.svg,
61+
{
62+
plugins: ["@svgr/plugin-jsx", "@svgr/plugin-prettier"],
63+
icon: true,
64+
},
65+
{ componentName: `Icon` }
66+
);
67+
// Append the transformed SVG component to the index string
68+
index += ` {
69+
name: \`${icon.title}\`,
70+
icon: \`${icon.svg}\`,
71+
code: \`${component}\`
72+
},`;
73+
} catch (error) {
74+
console.log(`Error processing ${icon.title}`);
75+
}
76+
});
77+
await Promise.all(promises);
78+
index += `]`;
79+
80+
rimraf.sync(path.join(process.cwd(), "src", "autogenerated", "simple-icons.ts"));
81+
fs.writeFileSync(
82+
path.join(process.cwd(), "src", "autogenerated", "icons", "simple-icons.ts"),
83+
index
84+
);
85+
}
86+
4887
void processLucideIcons();
88+
void processSimpleIcons();

0 commit comments

Comments
 (0)