isdragging in different context for styling

This commit is contained in:
2024-09-27 13:19:38 -06:00
parent fbfde530d8
commit f0e8f86201
9 changed files with 91 additions and 56 deletions

View File

@@ -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>
);
}