Skip to content

Commit 9b8e6ed

Browse files
committed
using instead the CSS to set size
1 parent 65b2188 commit 9b8e6ed

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

src/vs/editor/contrib/colorPicker/browser/colorPicker.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@
5050
flex: 1;
5151
}
5252

53+
.colorpicker-header .picked-color .picked-color-representation {
54+
white-space: nowrap;
55+
margin-left: 30px;
56+
margin-right: 5px;
57+
}
58+
5359
.colorpicker-header .picked-color .codicon {
5460
color: inherit;
5561
font-size: 14px;

src/vs/editor/contrib/colorPicker/browser/colorPickerWidget.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
2222

2323
const $ = dom.$;
2424

25-
function elementsOverlapHorizontally(el1: HTMLElement, el2: HTMLElement) {
26-
const domRect1 = el1.getBoundingClientRect();
27-
const domRect2 = el2.getBoundingClientRect();
28-
return !(
29-
domRect1.right < domRect2.left ||
30-
domRect1.left > domRect2.right
31-
);
32-
}
33-
3425
export class ColorPickerHeader extends Disposable {
3526

3627
private readonly _domNode: HTMLElement;
@@ -48,7 +39,8 @@ export class ColorPickerHeader extends Disposable {
4839

4940
this._pickedColorNode = dom.append(this._domNode, $('.picked-color'));
5041
this._pickedColorRepresentation = dom.append(this._pickedColorNode, document.createElement('div'));
51-
const icon = dom.append(this._pickedColorNode, $('.codicon.codicon-color-mode'));
42+
this._pickedColorRepresentation.classList.add('picked-color-representation');
43+
dom.append(this._pickedColorNode, $('.codicon.codicon-color-mode'));
5244

5345
const tooltip = localize('clickToToggleColorOptions', "Click to toggle color options (rgb/hsl/hex)");
5446
this._pickedColorNode.setAttribute('title', tooltip);
@@ -78,16 +70,6 @@ export class ColorPickerHeader extends Disposable {
7870
this._domNode.classList.add('standalone-colorpicker');
7971
this._closeButton = this._register(new CloseButton(this._domNode));
8072
}
81-
82-
const resizeObserver = new ResizeObserver(() => {
83-
this._pickedColorRepresentation.style.display = 'block';
84-
if (elementsOverlapHorizontally(this._pickedColorRepresentation, icon)) {
85-
this._pickedColorRepresentation.style.display = 'none';
86-
} else {
87-
this._pickedColorRepresentation.style.display = 'block';
88-
}
89-
});
90-
resizeObserver.observe(this._domNode);
9173
}
9274

9375
public get domNode(): HTMLElement {

0 commit comments

Comments
 (0)