-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from BU-Spark/site
updated dark/light scheme selection
- Loading branch information
Showing
3 changed files
with
30 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<button class="btn js-toggle-dark-mode fs-3">dark color scheme</button> | ||
|
||
<script> | ||
document.addEventListener('DOMContentLoaded', function() { | ||
const toggleDarkMode = document.querySelector('.js-toggle-dark-mode'); | ||
const currentTheme = localStorage.getItem('theme') || 'light'; | ||
|
||
if (currentTheme === 'dark') { | ||
jtd.setTheme('dark'); | ||
toggleDarkMode.textContent = 'light color scheme'; | ||
} else { | ||
jtd.setTheme('light'); | ||
toggleDarkMode.textContent = 'dark color scheme'; | ||
} | ||
|
||
jtd.addEvent(toggleDarkMode, 'click', function() { | ||
if (jtd.getTheme() === 'dark') { | ||
jtd.setTheme('light'); | ||
toggleDarkMode.textContent = 'dark color scheme'; | ||
localStorage.setItem('theme', 'light'); | ||
} else { | ||
jtd.setTheme('dark'); | ||
toggleDarkMode.textContent = 'light color scheme'; | ||
localStorage.setItem('theme', 'dark'); | ||
} | ||
}); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// per https://just-the-docs.com/docs/customization/#override-and-completely-custom-styles | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters