Skip to content

Commit

Permalink
Lazy load CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
martinRenou committed Jul 17, 2024
1 parent 3a2fb6e commit cbcbbad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 12 additions & 2 deletions packages/voila/src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ export class WidgetManager extends JupyterLabManager {
}

private _registerWidgets(): void {
// Lazy loading of either ipywidgets 7 or ipywidgets 8 widgets and CSS
// Depending on what is requested by the kernel, one or the other will load
this.register({
name: '@jupyter-widgets/base',
version: "2.0.0",
Expand All @@ -187,7 +189,11 @@ export class WidgetManager extends JupyterLabManager {
this.register({
name: '@jupyter-widgets/controls',
version: "2.0.0",
exports: async () => require('@jupyter-widgets/controls') as any,
exports: async () => {
const controlsWidgets = require('@jupyter-widgets/controls') as any;
require('@jupyter-widgets/controls/css/widgets-base.css');
return controlsWidgets;
},
});
this.register({
name: '@jupyter-widgets/output',
Expand All @@ -202,7 +208,11 @@ export class WidgetManager extends JupyterLabManager {
this.register({
name: '@jupyter-widgets/controls',
version: "1.5.0",
exports: async () => require('@jupyter-widgets/controls7') as any,
exports: async () => {
const controls7Widget = require('@jupyter-widgets/controls7') as any;
require('@jupyter-widgets/controls7/css/widgets-base.css');
return controls7Widget;
},
});
}

Expand Down
2 changes: 0 additions & 2 deletions packages/voila/style/index.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '@jupyter-widgets/controls7/css/widgets-base.css';

@font-face /* 0 */ {
font-family: MJXZERO;
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Zero.woff')
Expand Down

0 comments on commit cbcbbad

Please sign in to comment.