diff --git a/index.html b/index.html index d6f71d1..dfd6579 100644 --- a/index.html +++ b/index.html @@ -2,7 +2,7 @@ - + @@ -14,6 +14,8 @@ t === "dark" || (!t && matchMedia("(prefers-color-scheme: dark)").matches); if (dark) document.documentElement.classList.add("dark"); + var icon = document.getElementById("favicon"); + if (icon) icon.href = dark ? "/logo-dark.png" : "/logo.png"; })(); diff --git a/public/logo-dark.png b/public/logo-dark.png index 46bfff7..a1b8be9 100644 Binary files a/public/logo-dark.png and b/public/logo-dark.png differ diff --git a/public/vite.svg b/public/vite.svg deleted file mode 100644 index e7b8dfb..0000000 --- a/public/vite.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/hooks/useTheme.tsx b/src/hooks/useTheme.tsx index 18dd07a..c6dae7b 100644 --- a/src/hooks/useTheme.tsx +++ b/src/hooks/useTheme.tsx @@ -31,8 +31,23 @@ function readStoredTheme(): ThemePreference { return "system"; } +function applyFavicon(effectiveTheme: EffectiveTheme): void { + const href = effectiveTheme === "dark" ? "/logo-dark.png" : "/logo.png"; + let link = document.querySelector('link[rel="icon"]'); + if (!link) { + link = document.createElement("link"); + link.rel = "icon"; + link.type = "image/png"; + document.head.appendChild(link); + } + if (!link.href.endsWith(href)) { + link.href = href; + } +} + function applyEffectiveTheme(effectiveTheme: EffectiveTheme): void { document.documentElement.classList.toggle("dark", effectiveTheme === "dark"); + applyFavicon(effectiveTheme); } const themeCycle: ThemePreference[] = ["system", "light", "dark"];