Skip to content

Commit

Permalink
fix: Jupyter notebook sometimes not changing to dark theme on first load
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlie-XIAO committed Sep 12, 2024
1 parent b30b3f4 commit 065e0aa
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions assets/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,22 @@ $(document).ready(function () {
let jupyterTheme = determineComputedTheme();

$(".jupyter-notebook-iframe-container iframe").each(function () {
$(this).contents().find("head").append(cssLink);
var jupyterIFrame = $(this);
jupyterIFrame.contents().find("head").append(cssLink);

if (jupyterTheme == "dark") {
$(this).bind("load", function () {
$(this).contents().find("body").attr({
"data-jp-theme-light": "false",
"data-jp-theme-name": "JupyterLab Dark",
});
function changeToJupyterDarkTheme() {
jupyterIFrame.contents().find("body").attr({
"data-jp-theme-light": "false",
"data-jp-theme-name": "JupyterLab Dark",
});
}

if (jupyterTheme == "dark") {
if (jupyterIFrame[0].contentWindow.document.readyState === "complete") {
changeToJupyterDarkTheme();
}
$(this).bind("load", changeToJupyterDarkTheme);
}
});

// trigger popovers
Expand Down

0 comments on commit 065e0aa

Please sign in to comment.