Skip to content

Commit

Permalink
Handle theme colour logic as soon as possible
Browse files Browse the repository at this point in the history
This avoids presenting a frame or two of light mode, when the user has
forced the documentation into dark mode.
  • Loading branch information
pradyunsg committed Aug 31, 2021
1 parent ceaa691 commit 4212282
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/furo/assets/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ function setupScrollSpy() {
}

function setupTheme() {
// Set the current theme to auto.
setTheme(localStorage.getItem("theme") || "auto");

// Attach event handlers for toggling themes
const buttons = document.getElementsByClassName("theme-toggle");
Array.from(buttons).forEach((btn) => {
Expand Down
3 changes: 3 additions & 0 deletions src/furo/theme/furo/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
{%- block extrahead -%}{%- endblock -%}
</head>
<body>
<script>
document.body.dataset.theme = localStorage.getItem("theme") || "auto";
</script>
{% block body %}{% endblock %}

{%- block scripts -%}
Expand Down

0 comments on commit 4212282

Please sign in to comment.