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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user