significant refactor
This commit is contained in:
@@ -4,20 +4,25 @@ import { useMantineColorScheme } from "@mantine/core";
|
||||
import { useEffect } from "react";
|
||||
|
||||
const ColorSchemeProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
const { metadata: { colorScheme } } = useAuth()
|
||||
const {
|
||||
metadata: { colorScheme },
|
||||
} = useAuth();
|
||||
const { setColorScheme } = useMantineColorScheme();
|
||||
const theme = useMantineTheme();
|
||||
|
||||
useEffect(() => {
|
||||
if (!colorScheme) return;
|
||||
|
||||
|
||||
setColorScheme(colorScheme);
|
||||
const themeColorMeta = document.querySelector('meta[name="theme-color"]');
|
||||
if (themeColorMeta) {
|
||||
themeColorMeta.setAttribute('content', colorScheme === 'dark' ? theme.colors.dark[8] : theme.colors.gray[0]);
|
||||
themeColorMeta.setAttribute(
|
||||
"content",
|
||||
colorScheme === "dark" ? theme.colors.dark[8] : theme.colors.gray[0]
|
||||
);
|
||||
}
|
||||
}, [colorScheme]);
|
||||
return children
|
||||
}
|
||||
return children;
|
||||
};
|
||||
|
||||
export default ColorSchemeProvider;
|
||||
|
||||
Reference in New Issue
Block a user