feat(admin): make the left navigation bar collapsable (#10774)

This commit is contained in:
JimmFly
2025-03-13 09:57:09 +00:00
parent a4608b52f2
commit 21aa47c094
22 changed files with 782 additions and 361 deletions
@@ -0,0 +1,51 @@
import {
createContext,
type ReactNode,
type RefObject,
useContext,
} from 'react';
import type { ImperativePanelHandle } from 'react-resizable-panels';
export type SinglePanelContextType = {
isOpen: boolean;
panelContent: ReactNode;
setPanelContent: (content: ReactNode) => void;
togglePanel: () => void;
openPanel: () => void;
closePanel: () => void;
};
export interface PanelContextType {
leftPanel: SinglePanelContextType;
rightPanel: SinglePanelContextType;
}
export type ResizablePanelProps = {
panelRef: RefObject<ImperativePanelHandle>;
onExpand: () => void;
onCollapse: () => void;
};
export const PanelContext = createContext<PanelContextType | undefined>(
undefined
);
export const usePanelContext = () => {
const context = useContext(PanelContext);
if (!context) {
throw new Error('usePanelContext must be used within a PanelProvider');
}
return context;
};
export const useLeftPanel = () => {
const context = usePanelContext();
return context.leftPanel;
};
export const useRightPanel = () => {
const context = usePanelContext();
return context.rightPanel;
};