FEAT: Implement quick settings context;
UPDATE: Enhance quick settings UI & theme settings;
This commit is contained in:
32
frontend/src/context/QuickSettingsContext.tsx
Normal file
32
frontend/src/context/QuickSettingsContext.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { createContext, useContext, useState, ReactNode } from "react";
|
||||
|
||||
interface QuickSettingsContextType {
|
||||
showQuickSettings: boolean;
|
||||
setShowQuickSettings: (show: boolean) => void;
|
||||
}
|
||||
|
||||
const QuickSettingsContext = createContext<
|
||||
QuickSettingsContextType | undefined
|
||||
>(undefined);
|
||||
|
||||
export function QuickSettingsProvider({ children }: { children: ReactNode }) {
|
||||
const [showQuickSettings, setShowQuickSettings] = useState(false);
|
||||
|
||||
return (
|
||||
<QuickSettingsContext.Provider
|
||||
value={{ showQuickSettings, setShowQuickSettings }}
|
||||
>
|
||||
{children}
|
||||
</QuickSettingsContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function useQuickSettings() {
|
||||
const context = useContext(QuickSettingsContext);
|
||||
if (context === undefined) {
|
||||
throw new Error(
|
||||
"useQuickSettings must be used within a QuickSettingsProvider"
|
||||
);
|
||||
}
|
||||
return context;
|
||||
}
|
||||
Reference in New Issue
Block a user