Skip to content

Commit e8ad9b0

Browse files
authored
feat!: add generated, font-based icon themes (#18)
implement a system that generates file icon themes from a single set of svg icons. this system will use fantasticon to generate the icon font file and other assets for consuming the icons. marked as a breaking change because it deprecates the old svg icon themes (despite the general backwards compatibility of the new system). this one's a big one, but it can't be helped 😭
1 parent 56f3637 commit e8ad9b0

File tree

149 files changed

+519
-1116
lines changed

Some content is hidden

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

149 files changed

+519
-1116
lines changed

.fantasticonrc

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env node
2+
3+
const { FontAssetType, OtherAssetType } = require("fantasticon");
4+
5+
/** @type {import("fantasticon").RunnerOptions} */
6+
module.exports = {
7+
name: "glyph",
8+
inputDir: "static/icons",
9+
outputDir: "static",
10+
assetTypes: [OtherAssetType.TS],
11+
fontTypes: [FontAssetType.WOFF],
12+
formatOptions: {
13+
ts: {
14+
types: ["constant", "enum"],
15+
},
16+
},
17+
pathOptions: {
18+
ts: "src/constants/glyph.ts",
19+
},
20+
getIconId({ basename }) {
21+
return basename.replaceAll("-", "_");
22+
},
23+
};

.github/workflows/publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
- run: |
2020
bun install
21-
bun run build:vsix
21+
bun run build --production
2222
echo "filepath=$(ls dist/*.vsix)" >> $GITHUB_ENV
2323
echo "version=$(ls dist/*.vsix | grep -oE '\d+\.\d+\.\d+')" >> $GITHUB_ENV
2424

bun.lockb

48.8 KB
Binary file not shown.

package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,24 @@
5050
},
5151
"scripts": {
5252
"build": "bun run clean && bun run scripts/build.ts",
53-
"build:vsix": "bun run build --production",
5453
"clean": "git clean -xdf dist",
54+
"generate": "fantasticon",
5555
"prepare": "husky"
5656
},
57+
"dependencies": {
58+
"brace-expansion": "^4.0.0"
59+
},
5760
"devDependencies": {
5861
"@commitlint/cli": "^19",
5962
"@commitlint/config-conventional": "^19",
6063
"@tsconfig/bun": "^1.0.7",
6164
"@tsconfig/strictest": "^2.0.5",
65+
"@types/brace-expansion": "^1.1.2",
6266
"@types/bun": "^1.1.6",
6367
"@types/vscode": "^1.87",
6468
"@vscode/vsce": "^2.25.0",
6569
"esbuild": "^0.23.0",
70+
"fantasticon": "^3.0.0",
6671
"husky": "^9"
6772
},
6873
"commitlint": {

scripts/build.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { build } from "esbuild";
2+
import * as themes from "../src/themes";
23

34
const isProduction = process.argv.includes("--production");
45

5-
// see: https://code.visualstudio.com/api/working-with-extensions/bundling-extension#using-esbuild
6+
// see: https://aka.ms/vscode-bundle-extension#using-esbuild
67
await build({
78
entryPoints: [
8-
"static/**/*",
9-
"theme/**/*",
9+
"static/*",
1010
"src/extension.ts",
1111
"package.json",
1212
"package.nls.json",
@@ -19,6 +19,7 @@ await build({
1919
".md": "copy",
2020
".png": "copy",
2121
".svg": "copy",
22+
".woff": "copy",
2223
},
2324
outdir: "dist",
2425
external: ["vscode"],
@@ -30,7 +31,11 @@ await build({
3031
sourcemap: !isProduction,
3132
});
3233

34+
await Array.fromAsync(Object.values(themes), async (theme) => {
35+
await theme.write();
36+
});
37+
3338
if (isProduction) {
3439
const { createVSIX } = await import("@vscode/vsce");
35-
await createVSIX({ cwd: "dist" });
40+
await createVSIX({ cwd: "dist", dependencies: false });
3641
}

src/constants/glyph.ts

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
export enum Glyph {
2+
Vue = "vue",
3+
Video = "video",
4+
Triangle = "triangle",
5+
Test = "test",
6+
Tag = "tag",
7+
Table = "table",
8+
Svelte = "svelte",
9+
Shield = "shield",
10+
Shell = "shell",
11+
Settings = "settings",
12+
RootFolder = "root_folder",
13+
RootFolderExpanded = "root_folder_expanded",
14+
React = "react",
15+
Prisma = "prisma",
16+
Parenthesis = "parenthesis",
17+
OpenSource = "open_source",
18+
Next = "next",
19+
Microsoft = "microsoft",
20+
Merge = "merge",
21+
Lock = "lock",
22+
Information = "information",
23+
Image = "image",
24+
I18n = "i18n",
25+
History = "history",
26+
Git = "git",
27+
Gatsby = "gatsby",
28+
Format = "format",
29+
Folder = "folder",
30+
FolderExpanded = "folder_expanded",
31+
Fingerprint = "fingerprint",
32+
File = "file",
33+
Expo = "expo",
34+
Eslint = "eslint",
35+
Document = "document",
36+
Docs = "docs",
37+
Database = "database",
38+
Copyright = "copyright",
39+
Commit = "commit",
40+
Certificate = "certificate",
41+
Camera = "camera",
42+
Brackets = "brackets",
43+
Braces = "braces",
44+
Audio = "audio",
45+
Archive = "archive",
46+
Angular = "angular",
47+
}
48+
49+
export const GLYPH_CODEPOINTS: { [key in Glyph]: string } = {
50+
[Glyph.Vue]: "61697",
51+
[Glyph.Video]: "61698",
52+
[Glyph.Triangle]: "61699",
53+
[Glyph.Test]: "61700",
54+
[Glyph.Tag]: "61701",
55+
[Glyph.Table]: "61702",
56+
[Glyph.Svelte]: "61703",
57+
[Glyph.Shield]: "61704",
58+
[Glyph.Shell]: "61705",
59+
[Glyph.Settings]: "61706",
60+
[Glyph.RootFolder]: "61707",
61+
[Glyph.RootFolderExpanded]: "61708",
62+
[Glyph.React]: "61709",
63+
[Glyph.Prisma]: "61710",
64+
[Glyph.Parenthesis]: "61711",
65+
[Glyph.OpenSource]: "61712",
66+
[Glyph.Next]: "61713",
67+
[Glyph.Microsoft]: "61714",
68+
[Glyph.Merge]: "61715",
69+
[Glyph.Lock]: "61716",
70+
[Glyph.Information]: "61717",
71+
[Glyph.Image]: "61718",
72+
[Glyph.I18n]: "61719",
73+
[Glyph.History]: "61720",
74+
[Glyph.Git]: "61721",
75+
[Glyph.Gatsby]: "61722",
76+
[Glyph.Format]: "61723",
77+
[Glyph.Folder]: "61724",
78+
[Glyph.FolderExpanded]: "61725",
79+
[Glyph.Fingerprint]: "61726",
80+
[Glyph.File]: "61727",
81+
[Glyph.Expo]: "61728",
82+
[Glyph.Eslint]: "61729",
83+
[Glyph.Document]: "61730",
84+
[Glyph.Docs]: "61731",
85+
[Glyph.Database]: "61732",
86+
[Glyph.Copyright]: "61733",
87+
[Glyph.Commit]: "61734",
88+
[Glyph.Certificate]: "61735",
89+
[Glyph.Camera]: "61736",
90+
[Glyph.Brackets]: "61737",
91+
[Glyph.Braces]: "61738",
92+
[Glyph.Audio]: "61739",
93+
[Glyph.Archive]: "61740",
94+
[Glyph.Angular]: "61741",
95+
};

src/constants/index.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const COLOR_DEFAULT = "#7b7d84" as const;
2+
const COLOR_LIGHT = "#62646a" as const;
3+
4+
export const DEFAULT_COLOR_MAP = [
5+
["default", COLOR_DEFAULT],
6+
["light", COLOR_LIGHT],
7+
] as const;
8+
9+
export const PREFIX = "glyph" as const;

src/themes.ts

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
import { Glyph } from "./constants/glyph";
2+
import { IconSet } from "./utils/icon-set";
3+
4+
export const minimal = new IconSet("minimal");
5+
6+
export const legacy = new IconSet("legacy")
7+
.icon(Glyph.Angular, {
8+
fileExtensions:
9+
"{component,directive,guard,module,resolver,service,pipe}.{js,ts},filter.js,ng-template",
10+
fileNames: "angular.json,angular-cli.json",
11+
})
12+
.icon(Glyph.Archive, {
13+
fileExtensions: "7z,br,brotli,bzip2,gz,gzip,rar,tar,tgz,xz,zip",
14+
})
15+
.icon(Glyph.Audio, {
16+
fileExtensions: "aiff,flac,m4a,mp3,wav,wma",
17+
})
18+
.icon(Glyph.Braces, {
19+
fileExtensions: "js",
20+
languageIds:
21+
"c,coffeescript,cpp,csharp,css,fsharp,go,groovy,handlebars,html,jade,java,javascript,javascriptreact,less,lua,objective-c,perl,php,properties,python,ruby,rust,scss,swift,typescript,typescriptreact,xml,yaml",
22+
})
23+
.icon(Glyph.Brackets, {
24+
fileExtensions: "htm,html,xml",
25+
})
26+
.icon(Glyph.Camera, {
27+
fileExtensions: "snap",
28+
})
29+
.icon(Glyph.Certificate, {
30+
fileExtensions: "cer,cert,crt",
31+
fileNames: "{licence,license,unlicense}{,.md,.txt}",
32+
})
33+
.icon(Glyph.Copyright, {
34+
fileNames: "authors{,.md,.txt}",
35+
})
36+
.icon(Glyph.Database, {
37+
fileExtensions: "graphql,json,sqlite",
38+
languageIds: "json,sql",
39+
})
40+
.icon(Glyph.Docs, {
41+
fileExtensions: "md,mdx",
42+
languageIds: "markdown",
43+
})
44+
.icon(Glyph.Document, {
45+
fileExtensions: "doc,docx,pdf,ppt,pptx,rtf,txt",
46+
fileNames: "_headers,_redirects,.htaccess,robots.txt,sitemap.xml",
47+
})
48+
.icon(Glyph.Fingerprint, {
49+
fileExtensions: "asc,gpg,key,pem,pub",
50+
fileNames: ".htpasswd",
51+
})
52+
.icon(Glyph.Format, {
53+
fileNames:
54+
".prettierignore,.prettierrc{,.js,.json,.yaml,.yml},prettier.config.js",
55+
})
56+
.icon(Glyph.Gatsby, {
57+
fileNames: "gatsby-{browser,config,node,ssr}.js",
58+
})
59+
.icon(Glyph.Git, {
60+
fileExtensions: "patch",
61+
fileNames:
62+
".git-history,.gitattributes,.gitconfig,.gitignore,.gitkeep,.gitmodules",
63+
})
64+
.icon(Glyph.History, {
65+
fileNames: "{changelog,changes}{,.md,.txt}",
66+
})
67+
.icon(Glyph.I18n, {
68+
fileExtensions: "mo,po,pot",
69+
})
70+
.icon(Glyph.Image, {
71+
fileExtensions:
72+
"bmp,eps,gif,ico,img,jpeg,jpg,png,psd,raw,svg,tif,tiff,webp",
73+
})
74+
.icon(Glyph.Information, {
75+
fileExtensions: "log",
76+
fileNames: "readme{,.md,.txt}",
77+
})
78+
.icon(Glyph.Lock, {
79+
fileExtensions: "lock",
80+
fileNames: "security{,.md,.txt}",
81+
})
82+
.icon(Glyph.Microsoft, {
83+
fileExtensions:
84+
"code-workplace,csproj,ruleset,sln,suo,vb,vbs,{vcxitems,vcxproj}{,.filters},vscodeignore,vsix,vsixmanifest",
85+
})
86+
.icon(Glyph.OpenSource, {
87+
fileNames: "contributing.md,credits{,.md,.txt}",
88+
})
89+
.icon(Glyph.Parenthesis, {
90+
fileExtensions: "cl,el,elc,fasl,l,lisp,lsp,wat",
91+
languageIds: "clojure",
92+
})
93+
.icon(Glyph.React, {
94+
fileExtensions: "jsx,tsx",
95+
})
96+
.icon(Glyph.Settings, {
97+
fileExtensions:
98+
"cfg,conf,config,dlc,dll,env{,.example},ini,option,prefs,prop,properties,props,settings,sln.dotsettings{,.user},toml",
99+
fileNames:
100+
".buildignore,.jshintignore,.clang-{format,tidy},.mrconfig,.yardopts,manifest.mf,package.json",
101+
languageIds: "makefile",
102+
})
103+
.icon(Glyph.Shell, {
104+
fileExtensions: "awk,fish,tcsh,zshrc",
105+
languageIds: "bat,powershell,shellscript",
106+
})
107+
.icon(Glyph.Shield, {
108+
fileNames:
109+
".eslintcache,.eslintignore,.eslintrc{,.cjs,.js,.json,.yaml,.yml}",
110+
})
111+
.icon(Glyph.Table, {
112+
fileExtensions: "csv,tsv,xls,xlsx",
113+
})
114+
.icon(Glyph.Tag, {
115+
fileExtensions: "css,less,sass,scss,styl",
116+
})
117+
.icon(Glyph.Test, {
118+
fileExtensions:
119+
"e2e-spec.{js,ts},{js,jsx,ts,tsx}.snap,{spec,test}.{js,jsx,ts,tsx}",
120+
})
121+
.icon(Glyph.Video, {
122+
fileExtensions: "avi,m2v,m4v,mkv,mov,mp4,mpeg,mpg,mpv,webm,wmv",
123+
})
124+
.icon(Glyph.Vue, {
125+
fileExtensions: "store.{js,ts},vue",
126+
fileNames: "store.{js,ts},{nuxt.config,vue.config}.{js,ts}",
127+
});

0 commit comments

Comments
 (0)