feat: support query theme bootstrap for embeds
This commit is contained in:
@@ -1,6 +1,25 @@
|
||||
import type { Theme } from "./theme";
|
||||
|
||||
export type ResolvedTheme = "light" | "dark";
|
||||
export type ThemeQueryMode = "light" | "dark" | "system";
|
||||
|
||||
export function parseThemeQuery(value: string | null | undefined): ThemeQueryMode | null {
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const normalized = value.toLowerCase();
|
||||
|
||||
if (normalized === "light" || normalized === "dark") {
|
||||
return normalized;
|
||||
}
|
||||
|
||||
if (normalized === "auto" || normalized === "system") {
|
||||
return "system";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export function resolveStoredTheme(
|
||||
theme: Theme,
|
||||
|
||||
Reference in New Issue
Block a user