feat: new design progress
This commit is contained in:
28
src/pages/layout/context.tsx
Normal file
28
src/pages/layout/context.tsx
Normal file
@ -0,0 +1,28 @@
|
||||
import { ReactNode, createContext, useState } from "react";
|
||||
|
||||
interface LayoutContextType {
|
||||
leftNav: boolean;
|
||||
theme: string;
|
||||
update: (fn: (c: LayoutContextType) => LayoutContextType) => void;
|
||||
}
|
||||
const defaultLayoutContext: LayoutContextType = {
|
||||
leftNav: true,
|
||||
theme: "",
|
||||
update: c => c,
|
||||
};
|
||||
export const LayoutContext = createContext<LayoutContextType>(defaultLayoutContext);
|
||||
|
||||
export function LayoutContextProvider({ children }: { children: ReactNode }) {
|
||||
const [value, setValue] = useState<LayoutContextType>(defaultLayoutContext);
|
||||
return (
|
||||
<LayoutContext.Provider
|
||||
value={{
|
||||
...value,
|
||||
update: fn => {
|
||||
setValue(fn);
|
||||
},
|
||||
}}>
|
||||
{children}
|
||||
</LayoutContext.Provider>
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user