remove builder from button (#4146)

This commit is contained in:
Anthony Dresser
2019-02-25 12:42:33 -08:00
committed by GitHub
parent c831596e02
commit f3b0a50db7
2 changed files with 16 additions and 21 deletions

View File

@@ -7,7 +7,6 @@
import { Button as vsButton, IButtonOptions, IButtonStyles as vsIButtonStyles } from 'vs/base/browser/ui/button/button';
import * as DOM from 'vs/base/browser/dom';
import { Color } from 'vs/base/common/color';
import { Builder } from 'sql/base/browser/builder';
export interface IButtonStyles extends vsIButtonStyles {
buttonFocusOutline?: Color;
@@ -15,29 +14,26 @@ export interface IButtonStyles extends vsIButtonStyles {
export class Button extends vsButton {
private buttonFocusOutline: Color;
private $el: Builder;
constructor(container: HTMLElement, options?: IButtonOptions) {
super(container, options);
this.buttonFocusOutline = null;
this.$el = new Builder(this.element);
this.$el.on(DOM.EventType.FOCUS, (e) => {
this.$el.style('outline-color', this.buttonFocusOutline ? this.buttonFocusOutline.toString() : null);
this.$el.style('outline-width', '1px');
});
this._register(DOM.addDisposableListener(this.element, DOM.EventType.FOCUS, () => {
this.element.style.outlineColor = this.buttonFocusOutline ? this.buttonFocusOutline.toString() : null;
this.element.style.outlineWidth = '1px';
}));
this.$el.on(DOM.EventType.MOUSE_DOWN, (e) => {
const mouseEvent = e as MouseEvent;
if (!this.$el.hasClass('disabled') && mouseEvent.button === 0) {
this.$el.addClass('active');
this._register(DOM.addDisposableListener(this.element, DOM.EventType.MOUSE_DOWN, e => {
if (!DOM.hasClass(this.element, 'disabled') && e.button === 0) {
DOM.addClass(this.element, 'active');
}
});
}));
this.$el.on([DOM.EventType.MOUSE_UP], (e) => {
this._register(DOM.addDisposableListener(this.element, DOM.EventType.MOUSE_UP, e => {
DOM.EventHelper.stop(e);
this.$el.removeClass('active');
});
DOM.removeClass(this.element, 'active');
}));
}
public style(styles: IButtonStyles): void {
@@ -46,14 +42,14 @@ export class Button extends vsButton {
}
public set title(value: string) {
this.$el.title(value);
this.element.title = value;
}
public setHeight(value: string) {
this.$el.style('height', value);
this.element.style.height = value;
}
public setWidth(value: string) {
this.$el.style('width', value);
this.element.style.width = value;
}
}
}