Skip to content

Commit 3e41655

Browse files
committed
Fixes vscode webview css font variable changes
1 parent 72e60e0 commit 3e41655

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

src/ui/shared/app-base.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,26 @@ export abstract class App<TBootstrap extends Bootstrap> {
311311

312312
const bodyStyle = body.style;
313313

314-
bodyStyle.setProperty('--font-size', computedStyle.getPropertyValue('--vscode-editor-font-size').trim());
315-
bodyStyle.setProperty(
316-
'--font-family',
317-
computedStyle.getPropertyValue('--vscode-editor-font-family').trim()
318-
);
319-
bodyStyle.setProperty(
320-
'--font-weight',
321-
computedStyle.getPropertyValue('--vscode-editor-font-weight').trim()
322-
);
314+
const font = computedStyle.getPropertyValue('--vscode-font-family').trim();
315+
if (font) {
316+
bodyStyle.setProperty('--font-family', font);
317+
bodyStyle.setProperty('--font-size', computedStyle.getPropertyValue('--vscode-font-size').trim());
318+
bodyStyle.setProperty('--font-weight', computedStyle.getPropertyValue('--vscode-font-weight').trim());
319+
}
320+
else {
321+
bodyStyle.setProperty(
322+
'--font-family',
323+
computedStyle.getPropertyValue('--vscode-editor-font-family').trim()
324+
);
325+
bodyStyle.setProperty(
326+
'--font-size',
327+
computedStyle.getPropertyValue('--vscode-editor-font-size').trim()
328+
);
329+
bodyStyle.setProperty(
330+
'--font-weight',
331+
computedStyle.getPropertyValue('--vscode-editor-font-weight').trim()
332+
);
333+
}
323334

324335
let color = computedStyle.getPropertyValue('--vscode-editor-background').trim();
325336
bodyStyle.setProperty('--color-background', color);

src/ui/shared/colors.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export function lighten(color: string, percentage: number) {
1818
if (rgba == null) return color;
1919

2020
const [r, g, b, a] = rgba;
21-
percentage = (255 * percentage) / 100;
22-
return `rgba(${adjustLight(r, percentage)}, ${adjustLight(g, percentage)}, ${adjustLight(b, percentage)}, ${a})`;
21+
const amount = (255 * percentage) / 100;
22+
return `rgba(${adjustLight(r, amount)}, ${adjustLight(g, amount)}, ${adjustLight(b, amount)}, ${a})`;
2323
}
2424

2525
export function opacity(color: string, percentage: number) {

0 commit comments

Comments
 (0)