Skip to content

Commit 3f62fd7

Browse files
Merge pull request #13 from claytercek/main
Address major concerns from v0.1.0 release
2 parents 1b5eb13 + 2c94508 commit 3f62fd7

File tree

3 files changed

+450
-329
lines changed

3 files changed

+450
-329
lines changed

extension.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
id = "github-theme"
22
name = "Github Theme"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
schema_version = 1
55
authors = ["Pyae Sone Aung <[email protected]>", "Clay Tercek"]
66
description = "GitHub themes for Zed"

src/theme.js

Lines changed: 62 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,44 @@ export function getTheme({ themeKey, name, type }) {
1818
return themeKey.startsWith('light') ? tokens[lightTokenName] : tokens[darkTokenName]
1919
}
2020

21+
22+
/**
23+
* @param {string} tokenName
24+
* @param {number} alphaValue
25+
*/
26+
const alpha = (tokenName, alphaValue) => {
27+
const baseToken = tokens[tokenName];
28+
if (!baseToken) {
29+
console.warn(`Token '${tokenName}' not found in theme '${themeKey}'`)
30+
return null;
31+
}
32+
33+
const hexAlpha = Math.round(alphaValue * 255).toString(16).padStart(2, '0');
34+
35+
// Remove the '#' if present
36+
let color = baseToken.replace('#', '');
37+
38+
// If it's already an 8-digit HEXA, replace the last two characters
39+
if (color.length === 8) {
40+
color = color.slice(0, 6) + hexAlpha;
41+
}
42+
// If it's a 6-digit HEX, append the new alpha
43+
else if (color.length === 6) {
44+
color += hexAlpha;
45+
}
46+
// If it's a 3-digit HEX, expand it and append the new alpha
47+
else if (color.length === 3) {
48+
color = color.split('').map(char => char + char).join('') + hexAlpha;
49+
}
50+
else {
51+
console.warn(`Invalid color format for token '${tokenName}': ${baseToken}`);
52+
return baseToken;
53+
}
54+
55+
return '#' + color;
56+
}
57+
2158
return {
22-
"$schema": "https://zed.dev/schema/themes/v0.1.0.json",
2359
appearance: type,
2460
name,
2561
style: {
@@ -50,8 +86,8 @@ export function getTheme({ themeKey, name, type }) {
5086
"editor.active_line_number": tokens['fgColor/default'],
5187
"editor.active_wrap_guide": tokens['borderColor/muted'],
5288
"editor.background": tokens['bgColor/default'],
53-
"editor.document_highlight.read_background": tokens['bgColor/accent-muted'],
54-
"editor.document_highlight.write_background": tokens['bgColor/accent-emphasis'],
89+
"editor.document_highlight.read_background": alpha("fgColor/accent", 0.3),
90+
"editor.document_highlight.write_background": alpha("fgColor/accent", 0.2),
5591
"editor.foreground": tokens['fgColor/default'],
5692
"editor.gutter.background": tokens['bgColor/default'],
5793
"editor.highlighted_line.background": tokens['bgColor/neutral-muted'],
@@ -78,6 +114,10 @@ export function getTheme({ themeKey, name, type }) {
78114
"ghost_element.hover": tokens['bgColor/default'],
79115
"ghost_element.selected": tokens['bgColor/neutral-muted'],
80116

117+
"hidden": tokens['fgColor/disabled'],
118+
"hidden.background": tokens['bgColor/disabled'],
119+
"hidden.border": tokens['borderColor/disabled'],
120+
81121
"hint": tokens['fgColor/muted'],
82122
"hint.background": tokens['bgColor/muted'],
83123
"hint.border": tokens['borderColor/muted'],
@@ -90,7 +130,7 @@ export function getTheme({ themeKey, name, type }) {
90130
"icon.disabled": tokens['fgColor/disabled'],
91131
"icon.placeholder": tokens['fgColor/fgColor/placeholder'],
92132

93-
"ignored": tokens['fgColor/disabled'],
133+
"ignored": tokens['fgColor/muted'],
94134
"ignored.background": tokens['bgColor/disabled'],
95135
"ignored.border": tokens['borderColor/disabled'],
96136

@@ -122,7 +162,7 @@ export function getTheme({ themeKey, name, type }) {
122162
"scrollbar.track.border": tokens['borderColor/transparent'],
123163
"scrollbar_thumb.background": tokens['bgColor/neutal-muted'],
124164

125-
"search.match_background": tokens['bgColor/attention-muted'],
165+
"search.match_background": alpha("base/color/yellow/1", 0.3),
126166

127167
"status_bar.background": tokens['bgColor/inset'],
128168

@@ -163,13 +203,13 @@ export function getTheme({ themeKey, name, type }) {
163203

164204
"terminal.background": tokens['bgColor/inset'],
165205
"terminal.bright_foreground": tokens['fgColor/onEmphasis'],
166-
"terminal.dim_foreground": tokens['fgColor/default'],
167-
"terminal.foreground": tokens['fgColor/muted'],
206+
"terminal.dim_foreground": tokens['fgColor/muted'],
207+
"terminal.foreground": tokens['fgColor/default'],
168208

169209
"text": tokens['fgColor/default'],
170210
"text.accent": tokens['fgColor/accent'],
171211
"text.disabled": tokens['fgColor/disabled'],
172-
"text.muted": tokens['fgColor/muted'],
212+
"text.muted": tokens['fgColor/default'],
173213
"text.placeholder": tokens['fgColor/placeholder'],
174214

175215
"title_bar.background": tokens['bgColor/inset'],
@@ -194,9 +234,9 @@ export function getTheme({ themeKey, name, type }) {
194234
"teal",
195235
"red"
196236
].map(color => ({
197-
"cursor": tokens[`data/${color}/color`],
198-
"background": tokens[`data/${color}/color/muted`],
199-
"border": tokens[`data/${color}/color/muted`]
237+
"cursor": tokens[`data/${color}/color/emphasis`],
238+
"background": tokens[`data/${color}/color/emphasis`],
239+
"selection": alpha(`data/${color}/color/emphasis`, 0.4)
200240
})),
201241

202242
"syntax": {
@@ -266,7 +306,7 @@ export function getTheme({ themeKey, name, type }) {
266306
"font_weight": null
267307
},
268308
"hint": {
269-
"color": "fgColor/muted",
309+
"color": tokens["fgColor/muted"],
270310
"font_style": null,
271311
"font_weight": 700
272312
},
@@ -296,12 +336,12 @@ export function getTheme({ themeKey, name, type }) {
296336
"font_weight": null
297337
},
298338
"operator": {
299-
"color": "fgColor/default",
339+
"color": tokens["fgColor/default"],
300340
"font_style": null,
301341
"font_weight": null
302342
},
303343
"predictive": {
304-
"color": "fgColor/placeholder",
344+
"color": tokens["fgColor/placeholder"],
305345
"font_style": "italic",
306346
"font_weight": null
307347
},
@@ -311,7 +351,7 @@ export function getTheme({ themeKey, name, type }) {
311351
"font_weight": null
312352
},
313353
"primary": {
314-
"color": "fgColor/default",
354+
"color": tokens["fgColor/default"],
315355
"font_style": null,
316356
"font_weight": null
317357
},
@@ -321,17 +361,17 @@ export function getTheme({ themeKey, name, type }) {
321361
"font_weight": null
322362
},
323363
"punctuation": {
324-
"color": "fgColor/default",
364+
"color": tokens["fgColor/default"],
325365
"font_style": null,
326366
"font_weight": null
327367
},
328368
"punctuation.bracket": {
329-
"color": "fgColor/default",
369+
"color": tokens["fgColor/default"],
330370
"font_style": null,
331371
"font_weight": null
332372
},
333373
"punctuation.delimiter": {
334-
"color": "fgColor/default",
374+
"color": tokens["fgColor/default"],
335375
"font_style": null,
336376
"font_weight": null
337377
},
@@ -352,8 +392,8 @@ export function getTheme({ themeKey, name, type }) {
352392
},
353393
"string.escape": {
354394
"color": lightDark("base/color/green/6", "base/color/green/1"),
355-
"font_style": "bold",
356-
"font_weight": null
395+
"font_style": null,
396+
"font_weight": 700
357397
},
358398
"string.regex": {
359399
"color": lightDark("base/color/blue/8", "base/color/blue/1"),
@@ -391,7 +431,7 @@ export function getTheme({ themeKey, name, type }) {
391431
"font_weight": null
392432
},
393433
"variable": {
394-
"color": lightDark("base/color/orange/6", "base/color/orange/2"),
434+
"color": tokens["fgColor/default"],
395435
"font_style": null,
396436
"font_weight": null
397437
},
@@ -408,4 +448,4 @@ export function getTheme({ themeKey, name, type }) {
408448
}
409449
}
410450
}
411-
}
451+
}

0 commit comments

Comments
 (0)