mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-21 23:46:18 -05:00
Changing favicon color when navbar color changes.
This commit is contained in:
parent
9cdc0b5085
commit
bd217d98ce
14 changed files with 1378 additions and 1 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue