🎨 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:
23
src/tools/color.ts
Normal file
23
src/tools/color.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user