Skip to content

Commit 8fa90c2

Browse files
committed
Adds icons contribution for custom GitLens icons
1 parent 4092918 commit 8fa90c2

19 files changed

+1543
-107
lines changed

.fantasticonrc.js

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//@ts-check
2+
3+
/** @type { import('fantasticon').RunnerOptions} } */
4+
const config = {
5+
name: 'glicons',
6+
prefix: 'glicons',
7+
codepoints: require('./images/icons/template/mapping.json'),
8+
inputDir: './images/icons',
9+
outputDir: './dist',
10+
// @ts-ignore
11+
fontTypes: ['woff2'],
12+
normalize: true,
13+
// @ts-ignore
14+
assetTypes: ['html', 'scss', 'json'],
15+
templates: {
16+
html: './images/icons/template/icons-contribution.hbs',
17+
scss: './images/icons/template/styles.hbs',
18+
},
19+
formatOptions: {
20+
json: {
21+
indent: 2,
22+
},
23+
},
24+
pathOptions: {
25+
woff2: './dist/glicons.woff2',
26+
scss: './src/webviews//apps/shared/glicons.scss',
27+
html: './icons-contribution.json',
28+
json: './images/icons/template/mapping.json',
29+
},
30+
onComplete: _fontConfig => {
31+
const fs = require('fs');
32+
// Update the icons contribution point in package.json
33+
const package = require('./package.json');
34+
package.contributes.icons = require('./icons-contribution.json').icons;
35+
36+
const packageJSON = `${JSON.stringify(package, undefined, '\t')}\n`;
37+
38+
fs.writeFileSync('./package.json', packageJSON);
39+
fs.rmSync('./icons-contribution.json');
40+
},
41+
};
42+
43+
module.exports = config;

.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
emojis.json
22
git.d.ts
3+
glicons.scss
4+
images/icons/template/icons-contribution.hbs
5+
images/icons/template/mapping.json
6+
images/icons/template/styles.hbs

.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
{
1515
"files": "*.md",
1616
"options": { "tabWidth": 2 }
17+
},
18+
{
19+
"files": "*.svg",
20+
"options": { "parser": "html" }
1721
}
1822
]
1923
}

images/icons/commit-horizontal.svg

+1
Loading

images/icons/compare-ref-working.svg

+1
Loading

images/icons/graph.svg

+1
Loading

images/icons/next-commit.svg

+1
Loading

images/icons/prev-commit-menu.svg

+1
Loading

images/icons/prev-commit.svg

+1
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"icons": {
3+
{{#each codepoints}}
4+
"gitlens-{{@key}}": {
5+
"description": "{{@key}} icon",
6+
"default": {
7+
"fontPath": "dist/glicons.woff2",
8+
"fontCharacter": "\\\{{codepoint this}}"
9+
}
10+
{{#if @last}}
11+
}
12+
{{else}}
13+
},
14+
{{/if}}
15+
{{/each}}
16+
}
17+
}

images/icons/template/mapping.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"commit-horizontal": 61697,
3+
"graph": 61698,
4+
"next-commit": 61699,
5+
"prev-commit-menu": 61700,
6+
"prev-commit": 61701,
7+
"compare-ref-working": 61702
8+
}

images/icons/template/styles.hbs

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
@font-face {
2+
font-family: '{{ name }}';
3+
font-display: block;
4+
src: {{{ fontSrc }}};
5+
}
6+
7+
.glicon {
8+
font: normal normal normal 16px/1 {{ name }};
9+
display: inline-block;
10+
text-decoration: none;
11+
text-rendering: auto;
12+
text-align: center;
13+
-webkit-font-smoothing: antialiased;
14+
-moz-osx-font-smoothing: grayscale;
15+
user-select: none;
16+
-webkit-user-select: none;
17+
-ms-user-select: none;
18+
}
19+
20+
/*---------------------
21+
* Modifiers
22+
*-------------------*/
23+
24+
@keyframes glicon-spin {
25+
100% {
26+
transform: rotate(360deg);
27+
}
28+
}
29+
30+
.glicon-sync.glicon-modifier-spin,
31+
.glicon-loading.glicon-modifier-spin,
32+
.glicon-gear.glicon-modifier-spin {
33+
/* Use steps to throttle FPS to reduce CPU usage */
34+
animation: glicon-spin 1.5s steps(30) infinite;
35+
}
36+
37+
.glicon-modifier-disabled {
38+
opacity: 0.5;
39+
}
40+
41+
.glicon-modifier-hidden {
42+
opacity: 0;
43+
}
44+
45+
/* custom speed & easing for loading icon */
46+
.glicon-loading {
47+
animation-duration: 1s !important;
48+
animation-timing-function: cubic-bezier(0.53, 0.21, 0.29, 0.67) !important;
49+
}
50+
51+
/*---------------------
52+
* Icons
53+
*-------------------*/
54+
55+
{{#each codepoints}}
56+
.{{ ../prefix }}-{{ @key }}:before {
57+
content: '\\{{ codepoint this }}';
58+
}
59+
{{/each}}

0 commit comments

Comments
 (0)