Files
cheese-cake/templates/element/javascript/dark_mode_top.php
T
bs 99e01b3de3
CI / testsuite (pgsql, 8.2, ) (push) Successful in 4m4s
CI / testsuite (mysql, 8.2, ) (push) Successful in 4m23s
CI / testsuite (mysql, 8.4, ) (push) Successful in 2m50s
CI / testsuite (pgsql, 8.4, ) (push) Successful in 2m47s
CI / testsuite (sqlite, 8.4, ) (push) Successful in 2m46s
CI / testsuite (sqlite, 8.2, ) (push) Successful in 4m43s
Release / build (push) Successful in 10s
CI / testsuite (sqlite, 8.2, prefer-lowest) (push) Successful in 4m46s
CI / Coding Standard & Static Analysis (push) Successful in 3m35s
dark mode elements inline javascript
2026-08-27 02:35:47 -07:00

27 lines
779 B
PHP

<?php
/**
* @var \App\View\AppView $this
*/
?>
<script>
// On page load or when changing themes, best to add inline in `head` to avoid FOUC
document.documentElement.classList.toggle(
"dark",
localStorage.theme === "dark" ||
(!("theme" in localStorage) && window.matchMedia("(prefers-color-scheme: dark)").matches),
);
document.documentElement.classList.toggle(
"auto",
localStorage.theme === "auto"
);
// Whenever the user explicitly chooses light mode
// localStorage.theme = "light";
// // Whenever the user explicitly chooses dark mode
// localStorage.theme = "dark";
// // Whenever the user explicitly chooses to respect the OS preference
// localStorage.removeItem("theme");
</script>