forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththemeDetector.ts
More file actions
24 lines (21 loc) · 802 Bytes
/
themeDetector.ts
File metadata and controls
24 lines (21 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
// From here:
// https://stackoverflow.com/questions/37257911/detect-light-dark-theme-programatically-in-visual-studio-code
// Detect vscode-light, vscode-dark, and vscode-high-contrast class name on the body element.
export function detectBaseTheme(): 'vscode-light' | 'vscode-dark' | 'vscode-high-contrast' {
const body = document.body;
if (body) {
switch (body.className) {
default:
case 'vscode-light':
return 'vscode-light';
case 'vscode-dark':
return 'vscode-dark';
case 'vscode-high-contrast':
return 'vscode-high-contrast';
}
}
return 'vscode-light';
}