Changing favicon color when navbar color changes.
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Controller Tests / controller-tests (push) Waiting to run
Jest Tests / jest-tests (push) Waiting to run

This commit is contained in:
Roland 2026-02-04 12:23:28 -07:00
parent 9cdc0b5085
commit bd217d98ce
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
14 changed files with 1378 additions and 1 deletions

View file

@ -8,9 +8,32 @@ import {useCPUTemperature, useIOStats, useLoad, useMemoryStats, usePowerStats, u
import {useReorganizationStatus} from "../contexts/FileWorkerStatusContext";
import {SearchIconButton} from "./Search";
import {Icon, Popup} from "./Theme";
import {HELP_VIEWER_URI, NAME} from "./Vars";
import {HELP_VIEWER_URI, NAME, semanticUIColorMap} from "./Vars";
import _ from "lodash";
function updateFavicon(colorName) {
// Fall back to violet if invalid color
const safeColor = colorName in semanticUIColorMap ? colorName : 'violet';
const faviconPath = `/favicon-${safeColor}.svg`;
// Update all favicon links
const iconLinks = document.querySelectorAll('link[rel="icon"], link[rel="shortcut icon"]');
iconLinks.forEach(link => {
link.href = faviconPath;
});
// Also update the 32x32 and 16x16 specific icons if they exist
const icon32 = document.querySelector('link[sizes="32x32"]');
const icon16 = document.querySelector('link[sizes="16x16"]');
if (icon32) icon32.href = faviconPath;
if (icon16) icon16.href = faviconPath;
// Update theme-color meta tag for iOS/Android status bar
const hexColor = semanticUIColorMap[safeColor];
const themeColorMeta = document.querySelector('meta[name="theme-color"]');
if (themeColorMeta) themeColorMeta.content = hexColor;
}
const links = [
{text: 'Videos', to: '/videos', key: 'videos'},
{text: 'Archive', to: '/archive', key: 'archive'},
@ -80,6 +103,13 @@ function useNavColorSetting() {
}
}, [settings.nav_color]);
// Update favicon to match nav color
React.useEffect(() => {
if (navColor) {
updateFavicon(navColor);
}
}, [navColor]);
return navColor
}