New Chnages to Switch Theme
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user