mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 23:58:31 -06:00
isdragging in different context for styling
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
"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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user