Use compliance page logos for favicon and org sidebar

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-01-30 10:28:55 +04:00
parent 96391b4822
commit aa8bc15233
8 changed files with 76 additions and 6 deletions

View File

@@ -5,3 +5,5 @@ export { useList } from "./useList";
export { useStateWithRef } from "./useStateWithRef";
export { useCleanup } from "./useCleanup";
export { useCopy } from "./useCopy";
export { useFavicon } from "./useFavicon";
export { useSystemTheme } from "./useSystemTheme";

View File

@@ -0,0 +1,25 @@
import { useEffect } from "react";
export function useFavicon(faviconUrl?: string | null) {
useEffect(() => {
if (!faviconUrl) return;
let favicon: HTMLLinkElement;
const existingFavicon = document.getElementById("favicon") as (HTMLLinkElement | null);
if (existingFavicon) {
favicon = existingFavicon
favicon.href = faviconUrl;
} else {
favicon = document.createElement("link");
favicon.id = "favicon";
favicon.rel = "icon";
favicon.href = faviconUrl;
document.head.appendChild(favicon);
}
return () => {
favicon.href = "/favicons/favicon.ico";
}
});
}

View File

@@ -0,0 +1,31 @@
import { useEffect, useState } from "react";
export function useSystemTheme(): "light" | "dark" {
const getSystemTheme = () => {
if (typeof window !== "undefined" && window.matchMedia) {
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" as const;
}
return "light" as const;
};
const [theme, setTheme] = useState<"light" | "dark">(getSystemTheme());
useEffect(() => {
if (typeof window === "undefined" || !window.matchMedia) {
return;
}
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
const handleChange = (event: MediaQueryListEvent) => {
setTheme(event.matches ? "dark" : "light");
};
mediaQuery.addEventListener("change", handleChange);
return () => {
mediaQuery.removeEventListener("change", handleChange);
};
}, []);
return theme;
};