Skip to content

Commit

Permalink
Set a dark class for the dark mode (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Apr 28, 2024
1 parent ddf7ff9 commit 03ec455
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ ITables ChangeLog
- We have added a logo for ITables ([#257](https://github.com/mwouts/itables/issues/257))
- The _loading_ message gives more information, including the version of ITables and where DataTables is loaded from ([#258](https://github.com/mwouts/itables/issues/258))

**Fixed**
- We have improve the compatibility with dark themes ([#255](https://github.com/mwouts/itables/issues/255))


2.0.0 (2024-03-16)
------------------
Expand Down
11 changes: 11 additions & 0 deletions itables/html/init_datatables.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script>
if (document.body.dataset.jpThemeLight == "false" || // Jupyter Lab
document.body.dataset.vscodeThemeKind == "vscode-dark" || // VS Code
document.documentElement.dataset.theme == "dark" || // Jupyter Book
window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.documentElement.classList.add('dark');
}
else {
document.documentElement.classList.remove('dark');
}
</script>
2 changes: 2 additions & 0 deletions itables/javascript.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ def init_notebook_mode(
if hasattr(pl.Series, "_repr_html_"):
del pl.Series._repr_html_

display(HTML(read_package_file("html/init_datatables.html")))

if not connected:
display(HTML(generate_init_offline_itables_html(dt_bundle)))

Expand Down
2 changes: 1 addition & 1 deletion tests/test_connected_notebook_is_small.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_connected_notebook_is_small(tmp_path, display_logo_when_loading):
)
jupytext([str(nb_py), "--to", "ipynb", "--set-kernel", "itables", "--execute"])
assert nb_ipynb.exists()
assert nb_ipynb.stat().st_size < (8000 if display_logo_when_loading else 5000)
assert nb_ipynb.stat().st_size < (8500 if display_logo_when_loading else 5000)


def test_offline_notebook_is_not_too_large(tmp_path):
Expand Down

0 comments on commit 03ec455

Please sign in to comment.