Fixed theme selector incorrectly showing dark mode on first visit
This commit is contained in:
@@ -11,7 +11,7 @@ templ Global() {
|
|||||||
lang="en"
|
lang="en"
|
||||||
x-data="{
|
x-data="{
|
||||||
theme: localStorage.getItem('theme')
|
theme: localStorage.getItem('theme')
|
||||||
|| localStorage.setItem('theme', 'system')}"
|
|| 'system'}"
|
||||||
x-init="$watch('theme', (val) => localStorage.setItem('theme', val))"
|
x-init="$watch('theme', (val) => localStorage.setItem('theme', val))"
|
||||||
x-bind:class="{'dark': theme === 'dark' || (theme === 'system' &&
|
x-bind:class="{'dark': theme === 'dark' || (theme === 'system' &&
|
||||||
window.matchMedia('(prefers-color-scheme: dark)').matches)}"
|
window.matchMedia('(prefers-color-scheme: dark)').matches)}"
|
||||||
|
|||||||
Reference in New Issue
Block a user