Various fixes in theme switch
This commit is contained in:
parent
a89e36aa65
commit
aa0601523d
@ -20,9 +20,8 @@ const ThemeSwitch: NextPage<{ size?: string }> = ({ size }) => {
|
|||||||
setMounted(true);
|
setMounted(true);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const switchTheme = (newTheme: string) => {
|
const switchTheme = (theme: string) => {
|
||||||
console.log(newTheme);
|
if (theme === "dark") setFadeProps({
|
||||||
if (newTheme === "dark") setFadeProps({
|
|
||||||
sun: styles.fadeIn,
|
sun: styles.fadeIn,
|
||||||
moon: styles.fadeOut
|
moon: styles.fadeOut
|
||||||
});
|
});
|
||||||
@ -31,16 +30,16 @@ const ThemeSwitch: NextPage<{ size?: string }> = ({ size }) => {
|
|||||||
moon: styles.fadeIn
|
moon: styles.fadeIn
|
||||||
});
|
});
|
||||||
|
|
||||||
setTheme(newTheme);
|
setTheme(theme);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!mounted) {
|
if (!mounted) {
|
||||||
return <div className={styles.switch} title="Theme switching needs JS to be enabled.">
|
return <div className={styles.switch} title="Theme switching needs JS to be enabled.">
|
||||||
<FileJs size={size || "1.5em"} />
|
<FileJs size={size || "1.5em"} className={styles.placeHolder} />
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sunClasses = fadeProps.sun || (theme === "dark" ? styles.selected : undefined);
|
const sunClasses = fadeProps.sun || (theme !== "light" ? styles.selected : undefined);
|
||||||
const moonClasses = fadeProps.moon || (theme === "light" ? styles.selected : undefined);
|
const moonClasses = fadeProps.moon || (theme === "light" ? styles.selected : undefined);
|
||||||
|
|
||||||
return <div className={styles.switch}>
|
return <div className={styles.switch}>
|
||||||
|
@ -24,6 +24,11 @@
|
|||||||
animation: fadeIn 0.2s ease-in-out;
|
animation: fadeIn 0.2s ease-in-out;
|
||||||
animation-fill-mode: forwards;
|
animation-fill-mode: forwards;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.placeHolder {
|
||||||
|
opacity: 1 !important;
|
||||||
|
transform: translate(0, 0) !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes fadeOut {
|
@keyframes fadeOut {
|
||||||
|
Loading…
Reference in New Issue
Block a user