Skip to content

Commit

Permalink
fix: add on-load.js for theme and font
Browse files Browse the repository at this point in the history
Resolves #54
  • Loading branch information
sondregronas committed Sep 30, 2024
1 parent 898384e commit 2f6be91
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 0 additions & 4 deletions piggy/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ function toggleDyslexia() {
pageTransition();
}

// Set the current theme on page load
document.documentElement.setAttribute("data-theme", currentTheme);
document.documentElement.setAttribute("data-font-theme", fontTheme);

if (fontTheme === "default") {
dyslexiaBtn.innerHTML = "Dyslexia Friendly Mode";
} else {
Expand Down
4 changes: 4 additions & 0 deletions piggy/static/js/on-load.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const currentTheme = localStorage.getItem("theme") || "dark";
const fontTheme = localStorage.getItem("data-font-theme") || "default";
document.documentElement.setAttribute("data-theme", currentTheme);
document.documentElement.setAttribute("data-font-theme", fontTheme);
1 change: 1 addition & 0 deletions piggy/templates/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
{% include "partials/parts/styles.html" %}
{% endblock %}

<script src="{{ url_for('static', filename='js/on-load.js') }}"></script>
<script src="{{ url_for('static', filename='js/main.js') }}" defer></script>

0 comments on commit 2f6be91

Please sign in to comment.