Skip to content

Commit b005f53

Browse files
committed
support codicons in welcome view buttons
1 parent 888f89b commit b005f53

4 files changed

Lines changed: 17 additions & 5 deletions

File tree

src/vs/base/browser/ui/button/button.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55

66
.monaco-text-button {
77
box-sizing: border-box;
8-
display: inline-block;
8+
display: flex;
99
width: 100%;
1010
padding: 4px;
1111
text-align: center;
1212
cursor: pointer;
1313
outline-offset: 2px !important;
14+
justify-content: center;
15+
align-items: center;
1416
}
1517

1618
.monaco-text-button:hover {
@@ -21,3 +23,7 @@
2123
opacity: 0.4;
2224
cursor: default;
2325
}
26+
27+
.monaco-button > .codicon {
28+
margin: 0 0.2em;
29+
}

src/vs/base/browser/ui/button/button.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ import { mixin } from 'vs/base/common/objects';
1212
import { Event as BaseEvent, Emitter } from 'vs/base/common/event';
1313
import { Disposable } from 'vs/base/common/lifecycle';
1414
import { Gesture, EventType } from 'vs/base/browser/touch';
15+
import { renderCodicons } from 'vs/base/common/codicons';
16+
import { escape } from 'vs/base/common/strings';
1517

1618
export interface IButtonOptions extends IButtonStyles {
17-
title?: boolean | string;
19+
readonly title?: boolean | string;
20+
readonly supportCodicons?: boolean;
1821
}
1922

2023
export interface IButtonStyles {
@@ -149,7 +152,11 @@ export class Button extends Disposable {
149152
if (!DOM.hasClass(this._element, 'monaco-text-button')) {
150153
DOM.addClass(this._element, 'monaco-text-button');
151154
}
152-
this._element.textContent = value;
155+
if (this.options.supportCodicons) {
156+
this._element.innerHTML = renderCodicons(escape(value));
157+
} else {
158+
this._element.textContent = value;
159+
}
153160
if (typeof this.options.title === 'string') {
154161
this._element.title = this.options.title;
155162
} else if (this.options.title) {

src/vs/workbench/browser/parts/views/media/views.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
max-width: 260px;
6767
margin-left: auto;
6868
margin-right: auto;
69-
display: block;
7069
}
7170

7271
.monaco-workbench .pane > .pane-body .welcome-view-content {

src/vs/workbench/browser/parts/views/viewPaneContainer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ export abstract class ViewPane extends Pane implements IView {
458458

459459
if (linkedText.nodes.length === 1 && typeof linkedText.nodes[0] !== 'string') {
460460
const node = linkedText.nodes[0];
461-
const button = new Button(this.viewWelcomeContainer, { title: node.title });
461+
const button = new Button(this.viewWelcomeContainer, { title: node.title, supportCodicons: true });
462462
button.label = node.label;
463463
button.onDidClick(_ => {
464464
this.telemetryService.publicLog2<{ viewId: string, uri: string }, WelcomeActionClassification>('views.welcomeAction', { viewId: this.id, uri: node.href });

0 commit comments

Comments
 (0)