From 34a65b93bed28b3536eaa072d5a0533243c5039c Mon Sep 17 00:00:00 2001 From: Ajay Ghanwat Date: Mon, 8 Dec 2025 13:47:58 +0530 Subject: [PATCH] New Chnages to Switch Theme --- src/components/ThemeSwitcher.astro | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/ThemeSwitcher.astro b/src/components/ThemeSwitcher.astro index 25b1796..d748a91 100644 --- a/src/components/ThemeSwitcher.astro +++ b/src/components/ThemeSwitcher.astro @@ -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