fix: lightswitch

This commit is contained in:
Youwen Wu 2025-06-12 11:42:03 -07:00
parent 0165c126a9
commit 73c3805fdb
Signed by: youwen
GPG key ID: 865658ED1FE61EC3

View file

@ -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]';