🎨 Made color switcher change Mantine styles

Moved the color switcher's functions to a context provider and made Mantine's styles derived off of that context.
This commit is contained in:
Aimsucks
2022-06-08 14:58:32 +00:00
parent b26ab50c8d
commit 845d6a3d87
9 changed files with 75 additions and 53 deletions

23
src/tools/color.ts Normal file
View File

@@ -0,0 +1,23 @@
import { createContext, useContext } from 'react';
type colorThemeContextType = {
primaryColor: string;
secondaryColor: string;
setPrimaryColor: (color: string) => void;
setSecondaryColor: (color: string) => void;
};
export const ColorTheme = createContext<colorThemeContextType>({
primaryColor: 'red',
secondaryColor: 'orange',
setPrimaryColor: () => {},
setSecondaryColor: () => {},
});
export function useColorTheme() {
const context = useContext(ColorTheme);
if (context === undefined) {
throw new Error('useColorTheme must be used within a ColorTheme.Provider');
}
return context;
}