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

Use css vars for lightbulb #165186

Merged
merged 1 commit into from
Nov 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions src/vs/editor/contrib/codeAction/browser/lightBulbWidget.css
Original file line number Diff line number Diff line change
@@ -3,14 +3,38 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

.monaco-editor .contentWidgets .codicon-light-bulb,
.monaco-editor .contentWidgets .codicon-lightbulb-autofix {
.monaco-editor .lightBulbWidget {
display: flex;
align-items: center;
justify-content: center;
}

.monaco-editor .contentWidgets .codicon-light-bulb:hover,
.monaco-editor .contentWidgets .codicon-lightbulb-autofix:hover {
.monaco-editor .lightBulbWidget:hover{
cursor: pointer;
}

.monaco-editor .lightBulbWidget.codicon-light-bulb {
color: var(--vscode-editorLightBulb-foreground);
}

.monaco-editor .lightBulbWidget.codicon-lightbulb-autofix {
color: var(--vscode-editorLightBulbAutoFix-foreground, var(--vscode-editorLightBulb-foreground));
}

.monaco-editor .lightBulbWidget:before {
position: relative;
z-index: 2;
}

.monaco-editor .lightBulbWidget:after {
position: absolute;
top: 0;
left: 0;
content: '';
display: block;
width: 100%;
height: 100%;
opacity: 0.3;
background-color: var(--vscode-editor-background);
z-index: 1;
}
35 changes: 4 additions & 31 deletions src/vs/editor/contrib/codeAction/browser/lightBulbWidget.ts
Original file line number Diff line number Diff line change
@@ -17,8 +17,6 @@ import { computeIndentLevel } from 'vs/editor/common/model/utils';
import type { CodeActionSet, CodeActionTrigger } from 'vs/editor/contrib/codeAction/common/types';
import * as nls from 'vs/nls';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { editorBackground, editorLightBulbAutoFixForeground, editorLightBulbForeground } from 'vs/platform/theme/common/colorRegistry';
import { IColorTheme, ICssStyleCollector, registerThemingParticipant } from 'vs/platform/theme/common/themeService';

namespace LightBulbState {

@@ -48,7 +46,7 @@ export class LightBulbWidget extends Disposable implements IContentWidget {

private static readonly _posPref = [ContentWidgetPositionPreference.EXACT];

private readonly _domNode: HTMLDivElement;
private readonly _domNode: HTMLElement;

private readonly _onClick = this._register(new Emitter<{ x: number; y: number; actions: CodeActionSet; trigger: CodeActionTrigger }>());
public readonly onClick = this._onClick.event;
@@ -65,8 +63,9 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
@IKeybindingService keybindingService: IKeybindingService
) {
super();
this._domNode = document.createElement('div');
this._domNode.className = Codicon.lightBulb.classNames;

this._domNode = dom.$('div.lightBulbWidget');

this._register(Gesture.ignoreTarget(this._domNode));

this._editor.addContentWidget(this);
@@ -235,29 +234,3 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
this._domNode.title = value;
}
}

registerThemingParticipant((theme: IColorTheme, collector: ICssStyleCollector) => {

const editorBackgroundColor = theme.getColor(editorBackground)?.transparent(0.7);

// Lightbulb Icon
const editorLightBulbForegroundColor = theme.getColor(editorLightBulbForeground);
if (editorLightBulbForegroundColor) {
collector.addRule(`
.monaco-editor .contentWidgets ${Codicon.lightBulb.cssSelector} {
color: ${editorLightBulbForegroundColor};
background-color: ${editorBackgroundColor};
}`);
}

// Lightbulb Auto Fix Icon
const editorLightBulbAutoFixForegroundColor = theme.getColor(editorLightBulbAutoFixForeground);
if (editorLightBulbAutoFixForegroundColor) {
collector.addRule(`
.monaco-editor .contentWidgets ${Codicon.lightbulbAutofix.cssSelector} {
color: ${editorLightBulbAutoFixForegroundColor};
background-color: ${editorBackgroundColor};
}`);
}

});