https://dev.kronoz.win/r/marzneshin.git
1import { createContext, useContext } from "react";
2import type { SidebarItemGroup } from "./types";
3
4interface SidebarContextProps {
5 sidebar: SidebarItemGroup;
6 collapsed: boolean;
7 setCollapsed: (state: boolean) => void;
8 open?: boolean;
9 setOpen?: (state: boolean) => void;
10}
11
12export const SidebarContext = createContext<SidebarContextProps | null>(null);
13
14export const useSidebarContext = () => {
15 const ctx = useContext(SidebarContext);
16 if (!ctx)
17 throw new Error(
18 "Sidebar.* component must be rendered as child of Sidebar ",
19 );
20 return ctx;
21};