mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
19 lines
575 B
TypeScript
19 lines
575 B
TypeScript
import { useBkndWindowContext } from "ui/client/ClientProvider";
|
|
import { useBknd } from "ui/client/bknd";
|
|
|
|
export type Theme = "light" | "dark";
|
|
|
|
export function useTheme(fallback: Theme = "light"): { theme: Theme } {
|
|
const b = useBknd();
|
|
const winCtx = useBkndWindowContext();
|
|
if (b) {
|
|
if (b?.adminOverride?.color_scheme) {
|
|
return { theme: b.adminOverride.color_scheme };
|
|
} else if (!b.fallback) {
|
|
return { theme: b.config.server.admin.color_scheme ?? fallback };
|
|
}
|
|
}
|
|
|
|
return { theme: winCtx.color_scheme ?? fallback };
|
|
}
|