Skip to content

Commit 48a8ba8

Browse files
authored
Big ol' update (#3)
* Some redrawn icons * Update SVGs, new sizes script, new icons * bump version
1 parent f9acc7e commit 48a8ba8

85 files changed

Lines changed: 243 additions & 114 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@pierre/vscode-icons",
33
"displayName": "Pierre VS Code Icons",
44
"description": "File icon theme for VS Code backed by source SVGs.",
5-
"version": "0.0.4",
5+
"version": "0.0.5",
66
"publisher": "pierrecomputer",
77
"license": "MIT",
88
"type": "module",
@@ -37,7 +37,8 @@
3737
"lint": "oxlint scripts/",
3838
"format": "oxfmt scripts/",
3939
"format:check": "oxfmt --check scripts/",
40-
"format:svgs": "node scripts/format-svgs.mjs"
40+
"format:svgs": "node scripts/format-svgs.mjs",
41+
"sizes": "node scripts/svg-sizes.mjs"
4142
},
4243
"contributes": {
4344
"iconThemes": [

scripts/build-icon-theme.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,20 @@ function buildTheme(icons, { colored = false } = {}) {
109109
}
110110
}
111111

112+
const hasSymlink = icons.some((i) => i.name === "file-symlink-duo");
113+
112114
const theme = {
113115
iconDefinitions,
114116
file: "file-duo",
115117
folder: "folder-duo",
116118
folderExpanded: "folder-open-duo",
119+
...(hasSymlink && { fileSymlink: "file-symlink-duo" }),
117120
fileExtensions,
118121
light: {
119122
file: "file-duo_light",
120123
folder: "folder-duo_light",
121124
folderExpanded: "folder-open-duo_light",
125+
...(hasSymlink && { fileSymlink: "file-symlink-duo_light" }),
122126
fileExtensions: lightFileExtensions,
123127
},
124128
};

scripts/format-svgs.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,30 @@ const svgoConfig = {
1616
convertTransform: false,
1717
inlineStyles: false,
1818
convertColors: false,
19+
convertPathData: { floatPrecision: 3 },
1920
},
2021
},
2122
},
2223
{
2324
name: "removeAttrs",
24-
params: { attrs: ["id"] },
25+
params: { attrs: ["data-*"] },
2526
},
2627
"sortAttrs",
2728
],
2829
};
2930

3031
function preprocess(svg) {
3132
return svg
32-
.replace(/<defs>[\s\S]*?<\/defs>/g, "")
33+
.replace(/<clipPath[\s\S]*?<\/clipPath>/g, "")
34+
.replace(/<defs>\s*<\/defs>/g, "")
3335
.replace(/<g[^>]*>/g, "")
3436
.replace(/<\/g>/g, "")
3537
.replace(/\s+clip-path="[^"]*"/g, "");
3638
}
3739

3840
function postprocess(svg) {
3941
return svg
40-
.replace(/fill="(?!none|currentColor)[^"]+"/g, 'fill="currentColor"')
42+
.replace(/fill="(?!none|currentColor|url\()[^"]+"/g, 'fill="currentColor"')
4143
.replace(/\s+stroke(?:-[\w-]+)?="[^"]*"/g, "");
4244
}
4345

scripts/palette.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const palette = {
77
800: "#6C6C71",
88
},
99
red: { 400: "#ff6762", 600: "#d52c36" },
10+
vermilion: { 400: "#ff8c5b", 600: "#d5512f" },
1011
orange: { 400: "#ffa359", 600: "#d47628" },
1112
yellow: { 400: "#ffd452", 600: "#d5a910" },
1213
green: { 400: "#5ecc71", 600: "#199f43" },

scripts/svg-sizes.mjs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import { readdir, stat } from "node:fs/promises";
2+
import path from "node:path";
3+
import { fileURLToPath } from "node:url";
4+
5+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
6+
const svgDir = path.resolve(__dirname, "..", "svgs");
7+
8+
function formatBytes(bytes) {
9+
if (bytes >= 1024) {
10+
return `${(bytes / 1024).toFixed(1)} KB`;
11+
}
12+
return `${bytes.toLocaleString()} B`;
13+
}
14+
15+
function parseArgs() {
16+
const args = process.argv.slice(2);
17+
const idx = args.indexOf("--threshold");
18+
if (idx !== -1 && args[idx + 1]) {
19+
return { threshold: Number(args[idx + 1]) };
20+
}
21+
return { threshold: null };
22+
}
23+
24+
async function svgSizes() {
25+
const { threshold } = parseArgs();
26+
const files = (await readdir(svgDir)).filter((f) => f.endsWith(".svg")).sort();
27+
28+
const entries = await Promise.all(
29+
files.map(async (file) => {
30+
const info = await stat(path.join(svgDir, file));
31+
return { file, size: info.size };
32+
}),
33+
);
34+
35+
entries.sort((a, b) => b.size - a.size);
36+
37+
const maxName = Math.max(...entries.map((e) => e.file.length));
38+
const maxSize = Math.max(...entries.map((e) => formatBytes(e.size).length));
39+
const colWidth = maxName + maxSize + 4;
40+
const termWidth = process.stdout.columns || 80;
41+
const cols = Math.max(1, Math.floor(termWidth / (colWidth + 2)));
42+
43+
console.log("\nSVG File Sizes (largest first)");
44+
console.log("\u2500".repeat(Math.min(termWidth, cols * (colWidth + 2))));
45+
46+
for (let i = 0; i < entries.length; i += cols) {
47+
const row = entries.slice(i, i + cols);
48+
const cells = row.map(({ file, size }) => {
49+
const sizeStr = formatBytes(size).padStart(maxSize);
50+
const marker = threshold !== null && size > threshold ? "*" : " ";
51+
return `${marker} ${file.padEnd(maxName)} ${sizeStr}`;
52+
});
53+
console.log(cells.join(" "));
54+
}
55+
56+
const totalSize = entries.reduce((sum, e) => sum + e.size, 0);
57+
const avg = Math.round(totalSize / entries.length);
58+
const max = entries[0];
59+
60+
console.log("\u2500".repeat(Math.min(termWidth, cols * (colWidth + 2))));
61+
console.log(` Total: ${entries.length} files, ${formatBytes(totalSize)}`);
62+
console.log(` Avg: ${formatBytes(avg)}`);
63+
console.log(` Max: ${max.file} (${formatBytes(max.size)})`);
64+
65+
if (threshold !== null) {
66+
const over = entries.filter((e) => e.size > threshold);
67+
console.log(
68+
` Over ${formatBytes(threshold)}: ${over.length} file${over.length === 1 ? "" : "s"} *`,
69+
);
70+
}
71+
72+
console.log();
73+
}
74+
75+
svgSizes();

scripts/themes/complete.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,13 @@ const tooling = [
256256
},
257257
{
258258
name: "bun-duo",
259-
// color: color(palette.orange),
260-
color: duoColor(palette.pink, palette.orange),
259+
color: color(palette.brown),
260+
// color: duoColor(palette.pink, palette.brown),
261261
fileNames: ["bunfig.toml", "bun.lockb", "bun.lock"],
262262
},
263263
{
264264
name: "oxc",
265-
color: color(palette.orange),
265+
color: color(palette.cyan),
266266
fileNames: [".oxlintrc.json"],
267267
},
268268
{

scripts/themes/default.mjs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ export default [
5252
fileExtensions: ["rb", "erb", "gemspec", "rake"],
5353
fileNames: ["Gemfile", "Rakefile"],
5454
},
55+
{
56+
name: "file-symlink-duo",
57+
},
58+
{
59+
name: "server-duo",
60+
fileExtensions: ["db", "sql", "sqlite", "sqlite3"],
61+
},
62+
{
63+
name: "file-table-duo",
64+
fileExtensions: ["csv", "tsv", "xls", "xlsx", "ods"],
65+
},
5566
{
5667
name: "font",
5768
fileExtensions: ["ttf", "otf", "woff", "woff2", "eot"],
@@ -72,8 +83,7 @@ export default [
7283
},
7384
{
7485
name: "git",
75-
color: color(palette.orange),
76-
opacity: 0.75,
86+
color: color(palette.vermilion),
7787
fileNames: [".gitignore", ".gitattributes", ".gitmodules", ".gitkeep"],
7888
},
7989
];

svgs/IconLayers3Middle.svg

Lines changed: 5 additions & 0 deletions
Loading

svgs/astro.svg

Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)