Files
spacedrive/interface/app/$libraryId/Explorer/View/Context.tsx
2024-04-22 18:54:42 +00:00

27 lines
739 B
TypeScript

import { createContext, useContext, type ReactNode, type RefObject } from 'react';
import { useActiveItem } from './useActiveItem';
export interface ExplorerViewContextProps extends ReturnType<typeof useActiveItem> {
ref: RefObject<HTMLDivElement>;
/**
* Padding to apply when scrolling to an item.
*/
scrollPadding?: { top?: number; bottom?: number };
contextMenu?: ReactNode;
selectable: boolean;
listViewOptions?: {
hideHeaderBorder?: boolean;
};
}
export const ExplorerViewContext = createContext<ExplorerViewContextProps | null>(null);
export const useExplorerViewContext = () => {
const ctx = useContext(ExplorerViewContext);
if (ctx === null) throw new Error('ViewContext.Provider not found!');
return ctx;
};