fix: Navigator folgt dem Unraid-Theme
Die Seite übernimmt das Display-Theme aus Unraid (black/gray dunkel, white/azure hell) als data-theme; die Farben hängen nicht mehr nur an prefers-color-scheme. Ohne bekanntes Theme wird der Seitenhintergrund ausgewertet. Paket 2026.11.21.r004. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
17cb65bd64
commit
a7e8325853
7 files changed
+46
-5
No files matched your search
@@ -4,6 +4,7 @@ const statusText = document.querySelector('#statusText');
|
||||
const transferButton = document.querySelector('#newQueueButton');
|
||||
const settingsButton = document.querySelector('#settingsButton');
|
||||
const API_BASE = window.UNAV_API_BASE || '/api';
|
||||
applyHostTheme();
|
||||
const APP_VERSION = window.UNAV_VERSION || 'dev';
|
||||
const state = {
|
||||
config: null,
|
||||
@@ -4067,3 +4068,20 @@ function contextMenuActions(win, entry) {
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
// Unraid normally tells us its theme (data-theme from the .page). If it does not,
|
||||
// look at the page background around the navigator so custom/unknown themes still match.
|
||||
function applyHostTheme() {
|
||||
if (!appShell || appShell.dataset.theme) return;
|
||||
let element = appShell.parentElement;
|
||||
while (element) {
|
||||
const match = getComputedStyle(element).backgroundColor.match(/rgba?\(([\d.]+),\s*([\d.]+),\s*([\d.]+)(?:,\s*([\d.]+))?/);
|
||||
if (match && (match[4] === undefined || Number(match[4]) > 0.5)) {
|
||||
const [r, g, b] = match.slice(1, 4).map(Number);
|
||||
const luminance = (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255;
|
||||
appShell.dataset.theme = luminance < 0.5 ? 'dark' : 'light';
|
||||
return;
|
||||
}
|
||||
element = element.parentElement;
|
||||
}
|
||||
}
|
||||
@@ -20,8 +20,25 @@
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* Dark palette: set from the Unraid theme (data-theme), or from the OS when the theme is unknown. */
|
||||
.u-nav[data-theme="dark"] {
|
||||
--bg: #101418;
|
||||
--surface: #1b2229;
|
||||
--surface-2: #222b33;
|
||||
--surface-3: #2b3741;
|
||||
--text: #eef3f7;
|
||||
--muted: #a3b0bd;
|
||||
--line: #36434f;
|
||||
--shadow: 0 18px 55px rgba(0, 0, 0, 0.44);
|
||||
color-scheme: dark;
|
||||
}
|
||||
|
||||
.u-nav[data-theme="light"] {
|
||||
color-scheme: light;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.u-nav {
|
||||
.u-nav:not([data-theme]) {
|
||||
--bg: #101418;
|
||||
--surface: #1b2229;
|
||||
--surface-2: #222b33;
|
||||
@@ -30,6 +47,7 @@
|
||||
--muted: #a3b0bd;
|
||||
--line: #36434f;
|
||||
--shadow: 0 18px 55px rgba(0, 0, 0, 0.44);
|
||||
color-scheme: dark;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user