Init 1
This commit is contained in:
commit
4e67004628
82 changed files with 7599 additions and 0 deletions
12
source/js/theme.js
Normal file
12
source/js/theme.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Toggle theme
|
||||
|
||||
const getTheme = localStorage.getItem('theme')
|
||||
const themeToggle = document.querySelector('.theme-toggle')
|
||||
const isDark = getTheme === 'dark'
|
||||
|
||||
document.body.classList.toggle('dark-theme', isDark)
|
||||
|
||||
themeToggle.addEventListener('click', () => {
|
||||
document.body.classList.toggle('dark-theme')
|
||||
localStorage.setItem('theme', document.body.classList.contains('dark-theme') ? 'dark' : 'light')
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue