@jupyterlab/git
Version:
A JupyterLab extension for version control using git
33 lines (32 loc) • 1.13 kB
JavaScript
import { Widget } from '@lumino/widgets';
/**
* A widget form containing a text block and a checkbox,
* can be used as a Dialog body.
*/
export class CheckboxForm extends Widget {
constructor(textBody, checkboxLabel) {
super();
this.node.appendChild(this.createBody(textBody, checkboxLabel));
}
createBody(textBody, checkboxLabel) {
const mainNode = document.createElement('div');
const text = document.createElement('div');
text.textContent = textBody;
const checkboxContainer = document.createElement('label');
this._checkbox = document.createElement('input');
this._checkbox.type = 'checkbox';
this._checkbox.checked = true;
const label = document.createElement('span');
label.textContent = checkboxLabel;
checkboxContainer.appendChild(this._checkbox);
checkboxContainer.appendChild(label);
mainNode.appendChild(text);
mainNode.appendChild(checkboxContainer);
return mainNode;
}
getValue() {
return {
checked: this._checkbox.checked
};
}
}