MOVE: Theme to quick settings
This commit is contained in:
27
frontend/src/context/ThemeContext.tsx
Normal file
27
frontend/src/context/ThemeContext.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import React, { createContext, useContext, useState, ReactNode } from "react";
|
||||
|
||||
// Theme context and types
|
||||
interface ThemeContextType {
|
||||
theme: string;
|
||||
setTheme: (theme: string) => void;
|
||||
}
|
||||
|
||||
const ThemeContext = createContext<ThemeContextType | undefined>(undefined);
|
||||
|
||||
export const ThemeProvider = ({ children }: { children: ReactNode }) => {
|
||||
const [theme, setTheme] = useState<string>("light");
|
||||
|
||||
return (
|
||||
<ThemeContext.Provider value={{ theme, setTheme }}>
|
||||
{children}
|
||||
</ThemeContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export const useTheme = () => {
|
||||
const context = useContext(ThemeContext);
|
||||
if (!context) {
|
||||
throw new Error("useTheme must be used within a ThemeProvider");
|
||||
}
|
||||
return context;
|
||||
};
|
||||
Reference in New Issue
Block a user