1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-05 14:17:26 +02:00

AdminerDarkSwitcher: Handle first click

Fixed an issue where the Dark Mode Switcher icon did not respond on the first click if the Dark Mode cookie had not been set yet. Now, clicking the icon correctly sets the cookie and immediately toggles Dark Mode.
This commit is contained in:
Pexle Chris
2025-04-27 15:13:21 +03:00
committed by Jakub Vrana
parent 5f7fb62803
commit cf52c4c0a8

View File

@@ -28,6 +28,8 @@ const saved = document.cookie.match(/adminer_dark=(\d)/);
if (saved) {
adminerDark = +saved[1];
adminerDarkSet();
} else {
adminerDark = +matchMedia('(prefers-color-scheme: dark)').matches;
}
</script>
<?php
@@ -35,7 +37,7 @@ if (saved) {
function navigation($missing) {
echo "<big style='position: fixed; bottom: .5em; right: .5em; cursor: pointer;'>☀</big>"
. Adminer\script("if (adminerDark != null) adminerDarkSet(); qsl('big').onclick = adminerDarkSwitch;") . "\n"
. Adminer\script("adminerDarkSet(); qsl('big').onclick = adminerDarkSwitch;") . "\n"
;
}