FEAT: Sidebar update to include followed streamers & categories;
FEAT: Sidebar now alters page width on open/close (DynamicPageContent); FIX: Properly disallow shortcut keys when typing in an input field;
This commit is contained in:
26
frontend/src/context/SidebarContext.tsx
Normal file
26
frontend/src/context/SidebarContext.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import { createContext, useContext, useState, ReactNode } from "react";
|
||||
|
||||
interface SidebarContextType {
|
||||
showSideBar: boolean;
|
||||
setShowSideBar: (show: boolean) => void;
|
||||
}
|
||||
|
||||
const SidebarContext = createContext<SidebarContextType | undefined>(undefined);
|
||||
|
||||
export function SidebarProvider({ children }: { children: ReactNode }) {
|
||||
const [showSideBar, setShowSideBar] = useState(false);
|
||||
|
||||
return (
|
||||
<SidebarContext.Provider value={{ showSideBar, setShowSideBar }}>
|
||||
{children}
|
||||
</SidebarContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function useSidebar() {
|
||||
const context = useContext(SidebarContext);
|
||||
if (context === undefined) {
|
||||
throw new Error("useSidebar must be used within a SidebarProvider");
|
||||
}
|
||||
return context;
|
||||
}
|
||||
Reference in New Issue
Block a user