Skip to content

Commit 17be0ec

Browse files
authored
Fix voila theme (#142)
* initialize theme based on app * fix toggle theme size
1 parent f1271ab commit 17be0ec

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/datagrid.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,7 @@ export
268268
class DataGridView extends DOMWidgetView {
269269
_createElement(tagName: string) {
270270
this.pWidget = new JupyterPhosphorPanelWidget({ view: this });
271-
// initialize to light theme unless set earlier
272-
this._isLightTheme = this._isLightTheme === undefined ? true : this._isLightTheme;
271+
this._initializeTheme();
273272
return this.pWidget.node;
274273
}
275274

@@ -434,6 +433,19 @@ export
434433
this.grid.renderers = renderers;
435434
}
436435

436+
private _initializeTheme() {
437+
// initialize theme unless set earlier
438+
if (this._isLightTheme !== undefined) {
439+
return;
440+
}
441+
442+
// initialize theme based on application settings
443+
this._isLightTheme = !(
444+
document.body.classList.contains('theme-dark') /* jupyter notebook or voila */ ||
445+
document.body.dataset.jpThemeLight === 'false' /* jupyter lab */
446+
);
447+
}
448+
437449
renderers: Dict<CellRendererView>;
438450
default_renderer: CellRendererView;
439451
grid: FeatherGrid;

widget-examples/basic/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ function main() {
233233
buttonBoxPanel.addWidget(bw);
234234
const spacer = new Widget();
235235
buttonBoxPanel.addWidget(spacer);
236-
BoxPanel.setSizeBasis(bw, 100);
236+
BoxPanel.setSizeBasis(bw, 120);
237237
BoxPanel.setStretch(spacer, 1);
238238

239239
boxPanel.addWidget(buttonBoxPanel);

0 commit comments

Comments
 (0)