fix: lightswitch
This commit is contained in:
parent
0165c126a9
commit
73c3805fdb
1 changed files with 8 additions and 3 deletions
|
@ -159,8 +159,8 @@
|
|||
</article>
|
||||
<script>
|
||||
function toggle() {
|
||||
document.body.classList.add('animation-ready');
|
||||
document.body.classList.toggle('dark');
|
||||
const isCurrentlyDark = document.body.classList.contains('dark');
|
||||
applyTheme(!isCurrentlyDark);
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', function(event) {
|
||||
|
@ -173,7 +173,12 @@
|
|||
const btn = document.getElementById('lightswitch');
|
||||
|
||||
const applyTheme = isDark => {
|
||||
toggle();
|
||||
document.body.classList.add('animation-ready');
|
||||
if (isDark) {
|
||||
document.body.classList.add('dark');
|
||||
} else {
|
||||
document.body.classList.remove('dark');
|
||||
}
|
||||
btn.textContent = isDark
|
||||
? '[lights on]'
|
||||
: '[lights out]';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue