dark mode theme strategy/dataset strategy
CI / testsuite (pgsql, 8.4, ) (push) Successful in 2m52s
CI / testsuite (mysql, 8.2, ) (push) Successful in 4m5s
CI / testsuite (mysql, 8.4, ) (push) Successful in 2m47s
CI / testsuite (pgsql, 8.2, ) (push) Successful in 4m25s
CI / testsuite (sqlite, 8.2, ) (push) Successful in 4m46s
CI / testsuite (sqlite, 8.2, prefer-lowest) (push) Successful in 3m57s
Release / build (push) Successful in 13s
CI / Coding Standard & Static Analysis (push) Successful in 3m28s
CI / testsuite (sqlite, 8.4, ) (push) Successful in 7m57s
CI / testsuite (pgsql, 8.4, ) (push) Successful in 2m52s
CI / testsuite (mysql, 8.2, ) (push) Successful in 4m5s
CI / testsuite (mysql, 8.4, ) (push) Successful in 2m47s
CI / testsuite (pgsql, 8.2, ) (push) Successful in 4m25s
CI / testsuite (sqlite, 8.2, ) (push) Successful in 4m46s
CI / testsuite (sqlite, 8.2, prefer-lowest) (push) Successful in 3m57s
Release / build (push) Successful in 13s
CI / Coding Standard & Static Analysis (push) Successful in 3m28s
CI / testsuite (sqlite, 8.4, ) (push) Successful in 7m57s
This commit is contained in:
@@ -5,7 +5,7 @@ use Cake\Core\Configure;
|
||||
/**
|
||||
* @var \App\View\AppView $this
|
||||
*/
|
||||
$strategy = Configure::read('CheeseCake.darkMode.strategy', 'class');
|
||||
$strategy = Configure::read('CheeseCake.darkMode.strategy', 'dataset');
|
||||
|
||||
?>
|
||||
<script>
|
||||
@@ -17,6 +17,7 @@ $strategy = Configure::read('CheeseCake.darkMode.strategy', 'class');
|
||||
toggleDarkLink.addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
localStorage.theme = 'dark';
|
||||
console.debug('dark');
|
||||
<?php if ($strategy === 'class') : ?>
|
||||
document.documentElement.classList.add('dark');
|
||||
document.documentElement.classList.remove('auto');
|
||||
@@ -30,6 +31,7 @@ $strategy = Configure::read('CheeseCake.darkMode.strategy', 'class');
|
||||
toggleLightLink.addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
localStorage.theme = 'light';
|
||||
console.debug('light');
|
||||
<?php if ($strategy === 'class') : ?>
|
||||
document.documentElement.classList.remove('auto');
|
||||
document.documentElement.classList.remove('dark');
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
<?php
|
||||
|
||||
use Cake\Core\Configure;
|
||||
|
||||
/**
|
||||
* @var \App\View\AppView $this
|
||||
*/
|
||||
$strategy = Configure::read('CheeseCake.darkMode.strategy', 'dataset');
|
||||
|
||||
?>
|
||||
<script>
|
||||
// On page load or when changing themes, best to add inline in `head` to avoid FOUC
|
||||
<?php if ($strategy === 'class') : ?>
|
||||
|
||||
document.documentElement.classList.toggle(
|
||||
"dark",
|
||||
localStorage.theme === "dark" ||
|
||||
@@ -15,6 +21,13 @@
|
||||
"auto",
|
||||
localStorage.theme === "auto"
|
||||
);
|
||||
<?php else : ?>
|
||||
localStorage.theme === "dark" ||
|
||||
(!("theme" in localStorage) && window.matchMedia("(prefers-color-scheme: dark)").matches) ?
|
||||
document.documentElement.dataset.theme = "dark" :
|
||||
document.documentElement.dataset.theme = "light";
|
||||
<?php endif; ?>
|
||||
|
||||
// Whenever the user explicitly chooses light mode
|
||||
|
||||
// localStorage.theme = "light";
|
||||
@@ -23,4 +36,3 @@
|
||||
// // Whenever the user explicitly chooses to respect the OS preference
|
||||
// localStorage.removeItem("theme");
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user