remeber darkmode pick

This commit is contained in:
gws 2024-11-13 11:52:42 +01:00
parent db5d01f04a
commit 62ff3ca28f

View file

@ -59,6 +59,7 @@
src="/flag-for-united-kingdom-svgrepo-com.svg" _="{{ hyper }}"></a> src="/flag-for-united-kingdom-svgrepo-com.svg" _="{{ hyper }}"></a>
{% endif %} {% endif %}
<div class='toggle-dark'> <div class='toggle-dark'>
<label> <label>
<input type='checkbox' _="on click <input type='checkbox' _="on click
@ -66,15 +67,16 @@
if me.checked if me.checked
log('checked') log('checked')
add .dark to the closest <body/> add .dark to the closest <body/>
window.localStorage.setItem('darkmode', 'true')
else else
remove .dark from the closest <body/> remove .dark from the closest <body/>
window.localStorage.setItem('darkmode', 'false')
end end
log('darkmode') then log(window.localStorage.getItem('darkmode'))
end end
on load on load
if (the first <body/> match .dark) if window.localStorage.getItem('darkmode') == 'true'
log('loaded as dark') then send click to me
set me.checked to true then
log(me)
"> ">
<span class='slider'></span> <span class='slider'></span>
</label> </label>