Created
July 18, 2022 09:04
-
-
Save crutchcorn/1b69259a35f7618bf73781967ebd10d6 to your computer and use it in GitHub Desktop.
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
let theme = document.documentElement.className; | |
toggleButton(theme); | |
themeToggleBtn.addEventListener('click', () => { | |
theme = currentTheme === 'light' ? 'dark' : 'light'; | |
toggleButton(theme); | |
localStorage.setItem(COLOR_MODE_STORAGE_KEY, theme) | |
}) |
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
const initialTheme = document.documentElement.className; | |
toggleButton(initialTheme); | |
themeToggleBtn.addEventListener('click', () => { | |
const currentTheme = document.documentElement.className; | |
document.documentElement.className = | |
currentTheme === 'light' ? 'dark' : 'light'; | |
const newTheme = document.documentElement.className; | |
toggleButton(newTheme); | |
localStorage.setItem(COLOR_MODE_STORAGE_KEY, newTheme) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment