New Chnages to Switch Theme
This commit is contained in:
@@ -11,7 +11,7 @@ interface Props extends HTMLAttributes<"div"> {
|
|||||||
darkBgClass?: string[];
|
darkBgClass?: string[];
|
||||||
lightBgClass?: string[];
|
lightBgClass?: string[];
|
||||||
rootExtraClass?: string;
|
rootExtraClass?: string;
|
||||||
onChange?: (mode: "light" | "dark" | "system") => void;
|
onChange?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -23,7 +23,7 @@ const {
|
|||||||
lightBgClass = [],
|
lightBgClass = [],
|
||||||
rootExtraClass = "",
|
rootExtraClass = "",
|
||||||
class: className,
|
class: className,
|
||||||
onChange,
|
onChange = "onThemeChange",
|
||||||
...rest
|
...rest
|
||||||
}: Props = Astro.props;
|
}: Props = Astro.props;
|
||||||
|
|
||||||
@@ -140,7 +140,8 @@ const checkBase = "wr:size-4 wr:opacity-0 wr:scale-90 wr:transition";
|
|||||||
localStorage.setItem(storageKey, mode);
|
localStorage.setItem(storageKey, mode);
|
||||||
reflectUI(mode);
|
reflectUI(mode);
|
||||||
|
|
||||||
onChange?.(mode);
|
const fn = window[onChange];
|
||||||
|
if (typeof fn === "function") fn(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
|
|||||||
Reference in New Issue
Block a user