Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipywidgets's HTMLManager package overrides the JupyterLab CSS in nbconvert #3340

Closed
martinRenou opened this issue Jan 10, 2022 · 3 comments · Fixed by #3342
Closed

ipywidgets's HTMLManager package overrides the JupyterLab CSS in nbconvert #3340

martinRenou opened this issue Jan 10, 2022 · 3 comments · Fixed by #3342
Labels

Comments

@martinRenou
Copy link
Member

martinRenou commented Jan 10, 2022

Description

ipywidgets's HTMLManager package seems to override JupyterLab CSS variables when loaded

Reproduce

  1. Install nbconvert==6.4.0 and ipywidgets==7.6.5
  2. Create a Notebook test.ipynb containing widgets
  3. Convert the Notebook to HTML using a dark theme, using the following command:
    jupyter nbconvert --to html --HTMLExporter.theme=dark test.ipynb
  4. Open the resulting HTML file with your browser, you should see the following:
theme.mp4

Expected behavior

The resulting HTML page should have a dark theme, ipywidgets should keep the CSS variables untouched when a theme is already loaded.

Ideally, ipywidgets wouldn't even ship those CSS variables.

Extra Context

It seems that, by chance, Voila is not impacted by this issue. I understand that the ipywidgets's control package CSS gets loaded before Voila loads the theme. But I might be wrong.
Voila is not impacted by this because it doesn't use HTMLManager.

@martinRenou martinRenou changed the title ipywidgets's control package overrides the JupyterLab CSS in nbconvert ipywidgets's HTMLManager package overrides the JupyterLab CSS in nbconvert Jan 10, 2022
@martinRenou
Copy link
Member Author

martinRenou commented Jan 10, 2022

Edited the title and issue summary. It seems that it's the HTMLManager that's bringing this CSS.

For the nbconvert case (HTML Manager):

import '@jupyter-widgets/controls/css/widgets.css';

For the classic Notebook case (widgetsnbextension)

require('@jupyter-widgets/controls/css/widgets.css');

@martinRenou
Copy link
Member Author

I wonder if we could have a conditional require that checks if the labvariables are already available in the page, if they are not, we require them.

@martinRenou
Copy link
Member Author

Related issue: jupyter/nbconvert#1506

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant