mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 52dcb723a39ae75bee1bd56b3312d7fcdc87aeed (#6719)
This commit is contained in:
@@ -25,6 +25,12 @@ export interface ICheckboxStyles {
|
||||
inputActiveOptionBackground?: Color;
|
||||
}
|
||||
|
||||
export interface ISimpleCheckboxStyles {
|
||||
checkboxBackground?: Color;
|
||||
checkboxBorder?: Color;
|
||||
checkboxForeground?: Color;
|
||||
}
|
||||
|
||||
const defaultOpts = {
|
||||
inputActiveOptionBorder: Color.fromHex('#007ACC00'),
|
||||
inputActiveOptionBackground: Color.fromHex('#0E639C50')
|
||||
@@ -32,7 +38,7 @@ const defaultOpts = {
|
||||
|
||||
export class CheckboxActionViewItem extends BaseActionViewItem {
|
||||
|
||||
private checkbox: Checkbox;
|
||||
private checkbox!: Checkbox;
|
||||
private readonly disposables = new DisposableStore();
|
||||
|
||||
render(container: HTMLElement): void {
|
||||
@@ -45,7 +51,7 @@ export class CheckboxActionViewItem extends BaseActionViewItem {
|
||||
title: this._action.label
|
||||
});
|
||||
this.disposables.add(this.checkbox);
|
||||
this.disposables.add(this.checkbox.onChange(() => this._action.checked = this.checkbox.checked, this));
|
||||
this.disposables.add(this.checkbox.onChange(() => this._action.checked = this.checkbox!.checked, this));
|
||||
this.element.appendChild(this.checkbox.domNode);
|
||||
}
|
||||
|
||||
@@ -174,3 +180,46 @@ export class Checkbox extends Widget {
|
||||
this.domNode.setAttribute('aria-disabled', String(true));
|
||||
}
|
||||
}
|
||||
|
||||
export class SimpleCheckbox extends Widget {
|
||||
private checkbox: Checkbox;
|
||||
private styles: ISimpleCheckboxStyles;
|
||||
|
||||
readonly domNode: HTMLElement;
|
||||
|
||||
constructor(private title: string, private isChecked: boolean) {
|
||||
super();
|
||||
|
||||
this.checkbox = new Checkbox({ title: this.title, isChecked: this.isChecked, actionClassName: 'monaco-simple-checkbox' });
|
||||
|
||||
this.domNode = this.checkbox.domNode;
|
||||
|
||||
this.styles = {};
|
||||
|
||||
this.checkbox.onChange(() => {
|
||||
this.applyStyles();
|
||||
});
|
||||
}
|
||||
|
||||
get checked(): boolean {
|
||||
return this.checkbox.checked;
|
||||
}
|
||||
|
||||
set checked(newIsChecked: boolean) {
|
||||
this.checkbox.checked = newIsChecked;
|
||||
|
||||
this.applyStyles();
|
||||
}
|
||||
|
||||
style(styles: ISimpleCheckboxStyles): void {
|
||||
this.styles = styles;
|
||||
|
||||
this.applyStyles();
|
||||
}
|
||||
|
||||
protected applyStyles(): void {
|
||||
this.domNode.style.color = this.styles.checkboxForeground ? this.styles.checkboxForeground.toString() : null;
|
||||
this.domNode.style.backgroundColor = this.styles.checkboxBackground ? this.styles.checkboxBackground.toString() : null;
|
||||
this.domNode.style.borderColor = this.styles.checkboxBorder ? this.styles.checkboxBorder.toString() : null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user