Skip to content

Commit 01a85f2

Browse files
rebornixKalmaegi
andauthored
Polish find widget css rules (microsoft#203762)
* refactor css variables for findWidget * adapt css variable for findWidget * Polish find widget css rules --------- Co-authored-by: weartist <[email protected]>
1 parent d6885f6 commit 01a85f2

File tree

2 files changed

+49
-73
lines changed

2 files changed

+49
-73
lines changed

src/vs/editor/contrib/find/browser/findWidget.css

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@
1414
padding: 0 4px;
1515
box-sizing: border-box;
1616
transform: translateY(calc(-100% - 10px)); /* shadow (10px) */
17+
box-shadow: 0 0 8px 2px var(--vscode-widget-shadow);
18+
border: 1px solid var(--vscode-contrastBorder);
19+
color: var(--vscode-editorWidget-foreground);
20+
border-left: 1px solid var(--vscode-widget-border);
21+
border-right: 1px solid var(--vscode-widget-border);
22+
border-bottom: 1px solid var(--vscode-widget-border);
1723
border-bottom-left-radius: 4px;
1824
border-bottom-right-radius: 4px;
25+
background-color: var(--vscode-editorWidget-background);
1926
}
2027

2128
.monaco-workbench.reduce-motion .monaco-editor .find-widget {
@@ -39,9 +46,11 @@
3946
transform: translateY(0);
4047
}
4148

49+
/* This outline-color rule is used to override the outline color for synthetic-focus find input. */
4250
.monaco-editor .find-widget .monaco-inputbox.synthetic-focus {
4351
outline: 1px solid -webkit-focus-ring-color;
4452
outline-offset: -1px;
53+
outline-color: var(--vscode-focusBorder);
4554
}
4655

4756
.monaco-editor .find-widget .monaco-inputbox .input {
@@ -214,13 +223,30 @@
214223
display:none;
215224
}
216225

226+
.monaco-editor .find-widget.no-results .matchesCount {
227+
color: var(--vscode-errorForeground);
228+
}
229+
217230
.monaco-editor .findMatch {
218231
animation-duration: 0;
219232
animation-name: inherit !important;
233+
background-color: var(--vscode-editor-findMatchHighlightBackground);
234+
}
235+
236+
.monaco-editor .currentFindMatch {
237+
background-color: var(--vscode-editor-findMatchBackground);
238+
border: 2px solid var(--vscode-editor-findMatchBorder);
239+
padding: 1px;
240+
box-sizing: border-box;
241+
}
242+
243+
.monaco-editor .findScope {
244+
background-color: var(--vscode-editor-findRangeHighlightBackground);
220245
}
221246

222247
.monaco-editor .find-widget .monaco-sash {
223248
left: 0 !important;
249+
background-color: var(--vscode-editorWidget-resizeBorder, var(--vscode-editorWidget-border));
224250
}
225251

226252
.monaco-editor.hc-black .find-widget .button:before {
@@ -229,6 +255,28 @@
229255
left: 2px;
230256
}
231257

258+
/* Action bars */
259+
.monaco-editor .find-widget .button:not(.disabled):hover,
260+
.monaco-editor .find-widget .codicon-find-selection:hover {
261+
background-color: var(--vscode-toolbar-hoverBackground) !important;
262+
}
263+
264+
.monaco-editor.findMatch {
265+
background-color: var(--vscode-editor-findMatchHighlightBackground);
266+
}
267+
268+
.monaco-editor.currentFindMatch {
269+
background-color: var(--vscode-editor-findMatchBackground);
270+
}
271+
272+
.monaco-editor.findScope {
273+
background-color: var(--vscode-editor-findRangeHighlightBackground);
274+
}
275+
276+
.monaco-editor.findMatch {
277+
background-color: var(--vscode-editorWidget-background);
278+
}
279+
232280
/* Close button position. */
233281
.monaco-editor .find-widget > .button.codicon-widget-close {
234282
position: absolute;

src/vs/editor/contrib/find/browser/findWidget.ts

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { ISashEvent, IVerticalSashLayoutProvider, Orientation, Sash } from 'vs/b
1616
import { Widget } from 'vs/base/browser/ui/widget';
1717
import { Delayer } from 'vs/base/common/async';
1818
import { Codicon } from 'vs/base/common/codicons';
19-
import { Color } from 'vs/base/common/color';
2019
import { onUnexpectedError } from 'vs/base/common/errors';
2120
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
2221
import { toDisposable } from 'vs/base/common/lifecycle';
@@ -36,7 +35,7 @@ import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/c
3635
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
3736
import { INotificationService } from 'vs/platform/notification/common/notification';
3837
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
39-
import { asCssVariable, contrastBorder, editorFindMatch, editorFindMatchBorder, editorFindMatchHighlight, editorFindMatchHighlightBorder, editorFindRangeHighlight, editorFindRangeHighlightBorder, editorWidgetBackground, editorWidgetBorder, editorWidgetForeground, editorWidgetResizeBorder, errorForeground, focusBorder, inputActiveOptionBackground, inputActiveOptionBorder, inputActiveOptionForeground, toolbarHoverBackground, widgetBorder, widgetShadow } from 'vs/platform/theme/common/colorRegistry';
38+
import { asCssVariable, editorFindMatchHighlightBorder, editorFindRangeHighlightBorder, inputActiveOptionBackground, inputActiveOptionBorder, inputActiveOptionForeground } from 'vs/platform/theme/common/colorRegistry';
4039
import { registerIcon, widgetClose } from 'vs/platform/theme/common/iconRegistry';
4140
import { IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
4241
import { ThemeIcon } from 'vs/base/common/themables';
@@ -1376,84 +1375,13 @@ export class SimpleButton extends Widget {
13761375
// theming
13771376

13781377
registerThemingParticipant((theme, collector) => {
1379-
const addBackgroundColorRule = (selector: string, color: Color | undefined): void => {
1380-
if (color) {
1381-
collector.addRule(`.monaco-editor ${selector} { background-color: ${color}; }`);
1382-
}
1383-
};
1384-
1385-
addBackgroundColorRule('.findMatch', theme.getColor(editorFindMatchHighlight));
1386-
addBackgroundColorRule('.currentFindMatch', theme.getColor(editorFindMatch));
1387-
addBackgroundColorRule('.findScope', theme.getColor(editorFindRangeHighlight));
1388-
1389-
const widgetBackground = theme.getColor(editorWidgetBackground);
1390-
addBackgroundColorRule('.find-widget', widgetBackground);
1391-
1392-
const widgetShadowColor = theme.getColor(widgetShadow);
1393-
if (widgetShadowColor) {
1394-
collector.addRule(`.monaco-editor .find-widget { box-shadow: 0 0 8px 2px ${widgetShadowColor}; }`);
1395-
}
1396-
1397-
const widgetBorderColor = theme.getColor(widgetBorder);
1398-
if (widgetBorderColor) {
1399-
collector.addRule(`.monaco-editor .find-widget { border-left: 1px solid ${widgetBorderColor}; border-right: 1px solid ${widgetBorderColor}; border-bottom: 1px solid ${widgetBorderColor}; }`);
1400-
}
1401-
14021378
const findMatchHighlightBorder = theme.getColor(editorFindMatchHighlightBorder);
14031379
if (findMatchHighlightBorder) {
14041380
collector.addRule(`.monaco-editor .findMatch { border: 1px ${isHighContrast(theme.type) ? 'dotted' : 'solid'} ${findMatchHighlightBorder}; box-sizing: border-box; }`);
14051381
}
14061382

1407-
const findMatchBorder = theme.getColor(editorFindMatchBorder);
1408-
if (findMatchBorder) {
1409-
collector.addRule(`.monaco-editor .currentFindMatch { border: 2px solid ${findMatchBorder}; padding: 1px; box-sizing: border-box; }`);
1410-
}
1411-
14121383
const findRangeHighlightBorder = theme.getColor(editorFindRangeHighlightBorder);
14131384
if (findRangeHighlightBorder) {
14141385
collector.addRule(`.monaco-editor .findScope { border: 1px ${isHighContrast(theme.type) ? 'dashed' : 'solid'} ${findRangeHighlightBorder}; }`);
14151386
}
1416-
1417-
const hcBorder = theme.getColor(contrastBorder);
1418-
if (hcBorder) {
1419-
collector.addRule(`.monaco-editor .find-widget { border: 1px solid ${hcBorder}; }`);
1420-
}
1421-
1422-
const foreground = theme.getColor(editorWidgetForeground);
1423-
if (foreground) {
1424-
collector.addRule(`.monaco-editor .find-widget { color: ${foreground}; }`);
1425-
}
1426-
1427-
const error = theme.getColor(errorForeground);
1428-
if (error) {
1429-
collector.addRule(`.monaco-editor .find-widget.no-results .matchesCount { color: ${error}; }`);
1430-
}
1431-
1432-
const resizeBorderBackground = theme.getColor(editorWidgetResizeBorder);
1433-
if (resizeBorderBackground) {
1434-
collector.addRule(`.monaco-editor .find-widget .monaco-sash { background-color: ${resizeBorderBackground}; }`);
1435-
} else {
1436-
const border = theme.getColor(editorWidgetBorder);
1437-
if (border) {
1438-
collector.addRule(`.monaco-editor .find-widget .monaco-sash { background-color: ${border}; }`);
1439-
}
1440-
}
1441-
1442-
// Action bars
1443-
const toolbarHoverBackgroundColor = theme.getColor(toolbarHoverBackground);
1444-
if (toolbarHoverBackgroundColor) {
1445-
collector.addRule(`
1446-
.monaco-editor .find-widget .button:not(.disabled):hover,
1447-
.monaco-editor .find-widget .codicon-find-selection:hover {
1448-
background-color: ${toolbarHoverBackgroundColor} !important;
1449-
}
1450-
`);
1451-
}
1452-
1453-
// This rule is used to override the outline color for synthetic-focus find input.
1454-
const focusOutline = theme.getColor(focusBorder);
1455-
if (focusOutline) {
1456-
collector.addRule(`.monaco-editor .find-widget .monaco-inputbox.synthetic-focus { outline-color: ${focusOutline}; }`);
1457-
1458-
}
14591387
});

0 commit comments

Comments
 (0)