Theme follows the system by default; the header switch cycles auto/light/dark and is stored per browser. The presenter has its own switch (T), dark by default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
25 lines
823 B
PHP
25 lines
823 B
PHP
<?php
|
|
/**
|
|
* Applies the stored colour scheme before first paint (no flash of the wrong theme).
|
|
* Must be included in <head>. The theme switch (element theme_switch, webroot/js/plenario.js
|
|
* `Theme`) writes the same localStorage key.
|
|
*
|
|
* @var \App\View\AppView $this
|
|
* @var string $key localStorage key (presenter uses its own, the beamer is not the laptop)
|
|
* @var string $fallback Theme without stored choice: '' = follow the system, 'dark' or 'light'
|
|
*/
|
|
$key ??= 'plenario-theme';
|
|
$fallback ??= '';
|
|
?>
|
|
<script>
|
|
(function () {
|
|
var theme = <?= json_encode($fallback) ?>;
|
|
try {
|
|
theme = localStorage.getItem(<?= json_encode($key) ?>) || theme;
|
|
} catch (e) {}
|
|
if (theme === 'light' || theme === 'dark') {
|
|
document.documentElement.setAttribute('data-theme', theme);
|
|
}
|
|
})();
|
|
</script>
|