Skip to content

Commit

Permalink
Update dark mode toggle in footer
Browse files Browse the repository at this point in the history
Signed-off-by: PixelRobots <22979170+PixelRobots@users.noreply.github.com>
  • Loading branch information
PixelRobots committed Oct 3, 2024
1 parent 05952b0 commit 520bf54
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions docs/_includes/nav_footer_custom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<button class="btn js-toggle-dark-mode">☾ dark</button>

<script>
const btnToggle = document.querySelector('.js-toggle-dark-mode');

if (localStorage.getItem('theme') === 'dark') {
jtd.setTheme('dark');
btnToggle.textContent = '☼ light';
} else {
jtd.setTheme('light');
btnToggle.textContent = '☾ dark';
}
</script>

<script>
const toggleDarkMode = document.querySelector('.js-toggle-dark-mode');

jtd.addEvent(toggleDarkMode, 'click', function () {
if (jtd.getTheme() === 'dark') {
jtd.setTheme('light');
toggleDarkMode.textContent = '☾ dark';
localStorage.setItem('theme', 'light');
} else {
jtd.setTheme('dark');
toggleDarkMode.textContent = '☼ light';
localStorage.setItem('theme', 'dark');
}
});
</script>

</br>

0 comments on commit 520bf54

Please sign in to comment.