Created
March 26, 2023 07:04
-
-
Save crutchcorn/8de3f1183da6a884c3bf67b16430f834 to your computer and use it in GitHub Desktop.
Used in a Twitter thread
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; | |
toggleButtonIcon(theme); | |
themeToggleBtn.addEventListener('click', () => { | |
theme = theme === 'light' ? 'dark' : 'light'; | |
toggleButtonIcon(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; | |
toggleButtonIcon(initialTheme); | |
themeToggleBtn.addEventListener('click', () => { | |
const currentTheme = document.documentElement.className; | |
document.documentElement.className = | |
currentTheme === 'light' ? 'dark' : 'light'; | |
const newTheme = document.documentElement.className; | |
toggleButtonIcon(newTheme); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment