mirror of
https://github.com/linkwarden/linkwarden.git
synced 2026-06-30 15:56:58 +00:00
51 lines
917 B
TypeScript
51 lines
917 B
TypeScript
import { cn } from "@/lib/utils";
|
|
import { useDroppable } from "@dnd-kit/core";
|
|
|
|
const Droppable = ({
|
|
children,
|
|
id,
|
|
data,
|
|
className,
|
|
}: {
|
|
children: React.ReactNode;
|
|
id: string;
|
|
data?: {
|
|
/**
|
|
* Id of collection or tag to drop into.
|
|
*/
|
|
id?: string;
|
|
/**
|
|
* Name of collection or tag to drop into.
|
|
*/
|
|
name?: string;
|
|
ownerId?: string;
|
|
type?: "collection" | "tag";
|
|
};
|
|
className?: string;
|
|
}) => {
|
|
const { setNodeRef, isOver } = useDroppable({
|
|
id,
|
|
data,
|
|
});
|
|
|
|
return (
|
|
<div
|
|
ref={setNodeRef}
|
|
className={cn(
|
|
isOver &&
|
|
"bg-primary/10 outline-2 outline-dashed outline-primary rounded-lg",
|
|
className
|
|
)}
|
|
data-over={isOver ? "true" : undefined}
|
|
style={{
|
|
position: "relative",
|
|
zIndex: isOver ? 1 : "auto",
|
|
}}
|
|
>
|
|
{children}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default Droppable;
|