New Chnages to Switch Theme

This commit is contained in:
2025-12-08 13:47:58 +05:30
parent d9ee164726
commit 34a65b93be
+4 -3
View File
@@ -11,7 +11,7 @@ interface Props extends HTMLAttributes<"div"> {
darkBgClass?: string[];
lightBgClass?: string[];
rootExtraClass?: string;
onChange?: (mode: "light" | "dark" | "system") => void;
onChange?: string;
}
const {
@@ -23,7 +23,7 @@ const {
lightBgClass = [],
rootExtraClass = "",
class: className,
onChange,
onChange = "onThemeChange",
...rest
}: Props = Astro.props;
@@ -140,7 +140,8 @@ const checkBase = "wr:size-4 wr:opacity-0 wr:scale-90 wr:transition";
localStorage.setItem(storageKey, mode);
reflectUI(mode);
onChange?.(mode);
const fn = window[onChange];
if (typeof fn === "function") fn(mode);
}
// Init