mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
40 lines
889 B
TypeScript
40 lines
889 B
TypeScript
"use client";
|
|
import {
|
|
createContext,
|
|
useContext,
|
|
ReactNode,
|
|
useState,
|
|
SetStateAction,
|
|
Dispatch,
|
|
} from "react";
|
|
|
|
export interface DraggingStyleContextInterface {
|
|
setIsDragging: Dispatch<SetStateAction<boolean>>;
|
|
}
|
|
const defaultDraggingValue: DraggingStyleContextInterface = {
|
|
setIsDragging: () => {},
|
|
};
|
|
export const DragStyleContext =
|
|
createContext<DraggingStyleContextInterface>(defaultDraggingValue);
|
|
|
|
export function useDragStyleContext() {
|
|
return useContext(DragStyleContext);
|
|
}
|
|
|
|
export function DragStyleContextProvider({
|
|
children,
|
|
}: {
|
|
children: ReactNode;
|
|
}) {
|
|
const [isDragging, setIsDragging] = useState(false);
|
|
return (
|
|
<DragStyleContext.Provider value={{ setIsDragging }}>
|
|
<div
|
|
className={"min-h-0 flex flex-col " + (isDragging ? " dragging " : "")}
|
|
>
|
|
{children}
|
|
</div>
|
|
</DragStyleContext.Provider>
|
|
);
|
|
}
|