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);
|
||||
}, []);
|
||||
|
||||
const switchTheme = (newTheme: string) => {
|
||||
console.log(newTheme);
|
||||
if (newTheme === "dark") setFadeProps({
|
||||
const switchTheme = (theme: string) => {
|
||||
if (theme === "dark") setFadeProps({
|
||||
sun: styles.fadeIn,
|
||||
moon: styles.fadeOut
|
||||
});
|
||||
@ -31,16 +30,16 @@ const ThemeSwitch: NextPage<{ size?: string }> = ({ size }) => {
|
||||
moon: styles.fadeIn
|
||||
});
|
||||
|
||||
setTheme(newTheme);
|
||||
setTheme(theme);
|
||||
};
|
||||
|
||||
if (!mounted) {
|
||||
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>;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
return <div className={styles.switch}>
|
||||
|
@ -24,6 +24,11 @@
|
||||
animation: fadeIn 0.2s ease-in-out;
|
||||
animation-fill-mode: forwards;
|
||||
}
|
||||
|
||||
.placeHolder {
|
||||
opacity: 1 !important;
|
||||
transform: translate(0, 0) !important;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fadeOut {
|
||||
|
Loading…
Reference in New Issue
Block a user