Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hc light class to webviews #151441

Merged
merged 2 commits into from Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -469,9 +469,14 @@
}

if (body) {
body.classList.remove('vscode-light', 'vscode-dark', 'vscode-high-contrast', 'vscode-reduce-motion', 'vscode-using-screen-reader');
body.classList.remove('vscode-light', 'vscode-dark', 'vscode-high-contrast', 'vscode-high-contrast-light', 'vscode-reduce-motion', 'vscode-using-screen-reader');

if (initData.activeTheme) {
body.classList.add(initData.activeTheme);
if (initData.activeTheme === 'vscode-high-contrast-light') {
// backwards compatibility
body.classList.add('vscode-high-contrast');
}
}

if (initData.reduceMotion) {
Expand Down
9 changes: 7 additions & 2 deletions src/vs/workbench/contrib/webview/browser/pre/index.html
Expand Up @@ -5,7 +5,7 @@
<meta charset="UTF-8">

<meta http-equiv="Content-Security-Policy"
content="default-src 'none'; script-src 'sha256-xgIcbQmGjpT42GEj54VFSNh6MI15PZ2D1+DdVehfYBI=' 'self'; frame-src 'self'; style-src 'unsafe-inline';">
content="default-src 'none'; script-src 'sha256-v9xEHcwDE5dc/lU7HYs5bG3LpPWGmQe0w/Vz6kmdd60=' 'self'; frame-src 'self'; style-src 'unsafe-inline';">

<!-- Disable pinch zooming -->
<meta name="viewport"
Expand Down Expand Up @@ -472,9 +472,14 @@
}

if (body) {
body.classList.remove('vscode-light', 'vscode-dark', 'vscode-high-contrast', 'vscode-reduce-motion', 'vscode-using-screen-reader');
body.classList.remove('vscode-light', 'vscode-dark', 'vscode-high-contrast', 'vscode-high-contrast-light', 'vscode-reduce-motion', 'vscode-using-screen-reader');

if (initData.activeTheme) {
body.classList.add(initData.activeTheme);
if (initData.activeTheme === 'vscode-high-contrast-light') {
// backwards compatibility
body.classList.add('vscode-high-contrast');
}
}

if (initData.reduceMotion) {
Expand Down
6 changes: 4 additions & 2 deletions src/vs/workbench/contrib/webview/browser/themeing.ts
Expand Up @@ -90,15 +90,17 @@ export class WebviewThemeDataProvider extends Disposable {
enum ApiThemeClassName {
light = 'vscode-light',
dark = 'vscode-dark',
highContrast = 'vscode-high-contrast'
highContrast = 'vscode-high-contrast',
highContrastLight = 'vscode-high-contrast-light',
}

namespace ApiThemeClassName {
export function fromTheme(theme: IColorTheme): ApiThemeClassName {
switch (theme.type) {
case ColorScheme.LIGHT: return ApiThemeClassName.light;
case ColorScheme.DARK: return ApiThemeClassName.dark;
default: return ApiThemeClassName.highContrast;
case ColorScheme.HIGH_CONTRAST_DARK: return ApiThemeClassName.highContrast;
case ColorScheme.HIGH_CONTRAST_LIGHT: return ApiThemeClassName.highContrastLight;
}
}
}