Skip to content

Commit 4d40ea2

Browse files
authored
Merge pull request microsoft#165576 from GauravB159/registerThemeParticipant-refactoring
Register theme participant refactoring
2 parents 687514b + 7b9d289 commit 4d40ea2

File tree

9 files changed

+43
-93
lines changed

9 files changed

+43
-93
lines changed

src/vs/workbench/contrib/codeEditor/browser/accessibility/accessibility.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@
77
padding: 10px;
88
vertical-align: middle;
99
overflow: auto;
10+
background-color: var(--vscode-editorWidget-background);
11+
color: var(--vscode-editorWidget-foreground);
12+
box-shadow: 0 2px 8px var(--vscode-widget-shadow);
13+
border: 2px solid var(--vscode-contrastBorder);
1014
}

src/vs/workbench/contrib/codeEditor/browser/accessibility/accessibility.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiati
2727
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
2828
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
2929
import { IOpenerService } from 'vs/platform/opener/common/opener';
30-
import { contrastBorder, editorWidgetBackground, widgetShadow, editorWidgetForeground } from 'vs/platform/theme/common/colorRegistry';
31-
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
3230
import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
3331
import { Action2, registerAction2 } from 'vs/platform/actions/common/actions';
3432
import { ICommandService } from 'vs/platform/commands/common/commands';
@@ -329,25 +327,3 @@ registerEditorCommand(new AccessibilityHelpCommand({
329327
primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape]
330328
}
331329
}));
332-
333-
registerThemingParticipant((theme, collector) => {
334-
const widgetBackground = theme.getColor(editorWidgetBackground);
335-
if (widgetBackground) {
336-
collector.addRule(`.monaco-editor .accessibilityHelpWidget { background-color: ${widgetBackground}; }`);
337-
}
338-
339-
const widgetForeground = theme.getColor(editorWidgetForeground);
340-
if (widgetBackground) {
341-
collector.addRule(`.monaco-editor .accessibilityHelpWidget { color: ${widgetForeground}; }`);
342-
}
343-
344-
const widgetShadowColor = theme.getColor(widgetShadow);
345-
if (widgetShadowColor) {
346-
collector.addRule(`.monaco-editor .accessibilityHelpWidget { box-shadow: 0 2px 8px ${widgetShadowColor}; }`);
347-
}
348-
349-
const hcBorder = theme.getColor(contrastBorder);
350-
if (hcBorder) {
351-
collector.addRule(`.monaco-editor .accessibilityHelpWidget { border: 2px solid ${hcBorder}; }`);
352-
}
353-
});

src/vs/workbench/contrib/codeEditor/browser/codeEditor.contribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ import './toggleMultiCursorModifier';
1919
import './toggleRenderControlCharacter';
2020
import './toggleRenderWhitespace';
2121
import './toggleWordWrap';
22-
import './untitledTextEditorHint';
22+
import './untitledTextEditorHint/untitledTextEditorHint';
2323
import './workbenchReferenceSearch';

src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
align-items: center;
2929
pointer-events: all;
3030
transition: top 200ms linear;
31+
background-color: var(--vscode-editorWidget-background) !important;
32+
color: var(--vscode-editorWidget-foreground);
33+
box-shadow: 0 0 8px 2px var(--vscode-widget-shadow);
34+
border: 1px solid var(--vscode-contrastBorder);
3135
}
3236

3337
.monaco-workbench.reduce-motion .monaco-editor .find-widget {
@@ -83,3 +87,13 @@
8387
div.simple-find-part-wrapper div.button {
8488
border-radius: 5px;
8589
}
90+
91+
.no-results.matchesCount {
92+
color: var(--vscode-errorForeground);
93+
}
94+
95+
div.simple-find-part-wrapper div.button:hover:not(.disabled) {
96+
background-color: var(--vscode-toolbar-hoverBackground);
97+
outline: 1px dashed var(--vscode-toolbar-hoverOutline);
98+
outline-offset: -1px;
99+
}

src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.ts

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import { IMessage as InputBoxMessage } from 'vs/base/browser/ui/inputbox/inputBo
1515
import { SimpleButton, findPreviousMatchIcon, findNextMatchIcon, NLS_NO_RESULTS, NLS_MATCHES_LOCATION } from 'vs/editor/contrib/find/browser/findWidget';
1616
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
1717
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
18-
import { editorWidgetBackground, inputActiveOptionBorder, inputActiveOptionBackground, inputActiveOptionForeground, inputBackground, inputBorder, inputForeground, inputValidationErrorBackground, inputValidationErrorBorder, inputValidationErrorForeground, inputValidationInfoBackground, inputValidationInfoBorder, inputValidationInfoForeground, inputValidationWarningBackground, inputValidationWarningBorder, inputValidationWarningForeground, widgetShadow, editorWidgetForeground, errorForeground, toolbarHoverBackground, toolbarHoverOutline, contrastBorder } from 'vs/platform/theme/common/colorRegistry';
19-
import { IColorTheme, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
18+
import { inputActiveOptionBorder, inputActiveOptionBackground, inputActiveOptionForeground, inputBackground, inputBorder, inputForeground, inputValidationErrorBackground, inputValidationErrorBorder, inputValidationErrorForeground, inputValidationInfoBackground, inputValidationInfoBorder, inputValidationInfoForeground, inputValidationWarningBackground, inputValidationWarningBorder, inputValidationWarningForeground } from 'vs/platform/theme/common/colorRegistry';
19+
import { IColorTheme } from 'vs/platform/theme/common/themeService';
2020
import { ContextScopedFindInput } from 'vs/platform/history/browser/contextScopedHistoryWidget';
2121
import { widgetClose } from 'vs/platform/theme/common/iconRegistry';
2222
import * as strings from 'vs/base/common/strings';
@@ -395,50 +395,3 @@ export abstract class SimpleFindWidget extends Widget {
395395
return nls.localize('ariaSearchNoResultWithLineNumNoCurrentMatch', "{0} found for '{1}'", label, searchString);
396396
}
397397
}
398-
399-
// theming
400-
registerThemingParticipant((theme, collector) => {
401-
const findWidgetBGColor = theme.getColor(editorWidgetBackground);
402-
if (findWidgetBGColor) {
403-
collector.addRule(`.monaco-workbench .simple-find-part { background-color: ${findWidgetBGColor} !important; }`);
404-
}
405-
406-
const widgetForeground = theme.getColor(editorWidgetForeground);
407-
if (widgetForeground) {
408-
collector.addRule(`.monaco-workbench .simple-find-part { color: ${widgetForeground}; }`);
409-
}
410-
411-
const widgetShadowColor = theme.getColor(widgetShadow);
412-
if (widgetShadowColor) {
413-
collector.addRule(`.monaco-workbench .simple-find-part { box-shadow: 0 0 8px 2px ${widgetShadowColor}; }`);
414-
}
415-
416-
const hcBorder = theme.getColor(contrastBorder);
417-
if (hcBorder) {
418-
collector.addRule(`.monaco-workbench .simple-find-part { border: 1px solid ${hcBorder}; }`);
419-
}
420-
421-
const error = theme.getColor(errorForeground);
422-
if (error) {
423-
collector.addRule(`.no-results.matchesCount { color: ${error}; }`);
424-
}
425-
426-
const toolbarHoverBackgroundColor = theme.getColor(toolbarHoverBackground);
427-
if (toolbarHoverBackgroundColor) {
428-
collector.addRule(`
429-
div.simple-find-part-wrapper div.button:hover:not(.disabled) {
430-
background-color: ${toolbarHoverBackgroundColor};
431-
}
432-
`);
433-
}
434-
435-
const toolbarHoverOutlineColor = theme.getColor(toolbarHoverOutline);
436-
if (toolbarHoverOutlineColor) {
437-
collector.addRule(`
438-
div.simple-find-part-wrapper div.button:hover:not(.disabled) {
439-
outline: 1px dashed ${toolbarHoverOutlineColor};
440-
outline-offset: -1px;
441-
}
442-
`);
443-
}
444-
});

src/vs/workbench/contrib/codeEditor/browser/inspectEditorTokens/inspectEditorTokens.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
padding: 10px;
1111
}
1212

13+
.monaco-editor .token-inspect-widget {
14+
background-color: var(--vscode-editorHoverWidget-background);
15+
}
16+
17+
.monaco-editor .token-inspect-widget .tiw-metadata-separator {
18+
background-color: var(--vscode-editorHoverWidget-border)
19+
}
20+
1321
.tiw-token {
1422
font-family: var(--monaco-monospace-font);
1523
}

src/vs/workbench/contrib/codeEditor/browser/inspectEditorTokens/inspectEditorTokens.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { SemanticTokensLegend, SemanticTokens } from 'vs/editor/common/languages
2020
import { FontStyle, ColorId, StandardTokenType, TokenMetadata } from 'vs/editor/common/encodedTokenAttributes';
2121
import { ILanguageService } from 'vs/editor/common/languages/language';
2222
import { INotificationService } from 'vs/platform/notification/common/notification';
23-
import { editorHoverBackground, editorHoverBorder } from 'vs/platform/theme/common/colorRegistry';
23+
import { editorHoverBorder } from 'vs/platform/theme/common/colorRegistry';
2424
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
2525
import { findMatchingThemeRule } from 'vs/workbench/services/textMate/common/TMHelper';
2626
import { ITextMateService } from 'vs/workbench/services/textMate/browser/textMate';
@@ -676,10 +676,5 @@ registerThemingParticipant((theme, collector) => {
676676
if (border) {
677677
const borderWidth = isHighContrast(theme.type) ? 2 : 1;
678678
collector.addRule(`.monaco-editor .token-inspect-widget { border: ${borderWidth}px solid ${border}; }`);
679-
collector.addRule(`.monaco-editor .token-inspect-widget .tiw-metadata-separator { background-color: ${border}; }`);
680-
}
681-
const background = theme.getColor(editorHoverBackground);
682-
if (background) {
683-
collector.addRule(`.monaco-editor .token-inspect-widget { background-color: ${background}; }`);
684679
}
685680
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
.monaco-editor .contentWidgets .untitled-hint {
7+
color: var(--vscode-input-placeholderForeground);
8+
}
9+
10+
.monaco-editor .contentWidgets .untitled-hint a {
11+
color: var(--vscode-textLink-foreground)
12+
}

src/vs/workbench/contrib/codeEditor/browser/untitledTextEditorHint.ts renamed to src/vs/workbench/contrib/codeEditor/browser/untitledTextEditorHint/untitledTextEditorHint.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import 'vs/css!./untitledTextEditorHint';
67
import * as dom from 'vs/base/browser/dom';
78
import { DisposableStore, dispose, IDisposable } from 'vs/base/common/lifecycle';
89
import { ContentWidgetPositionPreference, ICodeEditor, IContentWidget, IContentWidgetPosition } from 'vs/editor/browser/editorBrowser';
910
import { localize } from 'vs/nls';
10-
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
11-
import { inputPlaceholderForeground, textLinkForeground } from 'vs/platform/theme/common/colorRegistry';
1211
import { ChangeLanguageAction } from 'vs/workbench/browser/parts/editor/editorStatus';
1312
import { ICommandService } from 'vs/platform/commands/common/commands';
1413
import { PLAINTEXT_LANGUAGE_ID } from 'vs/editor/common/languages/modesRegistry';
@@ -193,15 +192,4 @@ class UntitledTextEditorHintContentWidget implements IContentWidget {
193192
}
194193
}
195194

196-
registerThemingParticipant((theme, collector) => {
197-
const inputPlaceholderForegroundColor = theme.getColor(inputPlaceholderForeground);
198-
if (inputPlaceholderForegroundColor) {
199-
collector.addRule(`.monaco-editor .contentWidgets .untitled-hint { color: ${inputPlaceholderForegroundColor}; }`);
200-
}
201-
const textLinkForegroundColor = theme.getColor(textLinkForeground);
202-
if (textLinkForegroundColor) {
203-
collector.addRule(`.monaco-editor .contentWidgets .untitled-hint a { color: ${textLinkForegroundColor}; }`);
204-
}
205-
});
206-
207195
registerEditorContribution(UntitledTextEditorHintContribution.ID, UntitledTextEditorHintContribution);

0 commit comments

Comments
 (0)