diff --git a/php/public/apply-theme.js b/php/public/apply-theme.js new file mode 100644 index 00000000..91783b16 --- /dev/null +++ b/php/public/apply-theme.js @@ -0,0 +1,14 @@ +"use strict"; + +// Apply the saved theme immediately to avoid a flash of the wrong theme. +try { document.documentElement.setAttribute('data-theme', localStorage.getItem('theme') ?? ''); } catch (e) {} + +// React when the user toggles the theme on the parent page while this page is +// open in an iframe. localStorage.setItem() fires a 'storage' event on every +// other window / frame that shares the same origin, so we can keep in sync +// without the parent having to know about us. +window.addEventListener('storage', (e) => { + if (e.key === 'theme') { + document.documentElement.setAttribute('data-theme', e.newValue ?? ''); + } +}); diff --git a/php/public/toggle-dark-mode.js b/php/public/toggle-dark-mode.js index 8f1e13a4..60d9f489 100644 --- a/php/public/toggle-dark-mode.js +++ b/php/public/toggle-dark-mode.js @@ -11,7 +11,7 @@ function toggleTheme() { function setThemeToDOM(value) { // Set the theme to the root document and all possible iframe documents (so they can adapt their styling, too). - const documents = [document, Array.from(document.querySelectorAll('iframe')).map((iframe) => iframe.contentDocument)].flat() + const documents = [document, ...Array.from(document.querySelectorAll('iframe')).map((iframe) => iframe.contentDocument).filter(Boolean)] documents.forEach((doc) => doc.documentElement.setAttribute('data-theme', value)); } diff --git a/php/src/Controller/DockerController.php b/php/src/Controller/DockerController.php index a0e1493b..b9df82da 100644 --- a/php/src/Controller/DockerController.php +++ b/php/src/Controller/DockerController.php @@ -402,6 +402,7 @@ readonly class DockerController {
+ diff --git a/php/templates/log.twig b/php/templates/log.twig index d8194981..8dc849a4 100644 --- a/php/templates/log.twig +++ b/php/templates/log.twig @@ -5,6 +5,7 @@ +