Files
PyUIBuilder/src/components/utils/draggable.js

22 lines
579 B
JavaScript
Raw Normal View History

2024-08-04 22:47:43 +05:30
import React from "react"
import {useDraggable} from "@dnd-kit/core"
function Draggable(props) {
const {attributes, listeners, setNodeRef, transform} = useDraggable({
id: 'draggable',
})
const style = transform ? {
transform: `translate3d(${transform.x}px, ${transform.y}px, 0)`,
} : undefined
return (
<button className={`tw-bg-transparent tw-outline-none tw-border-none ${props.className}`} ref={setNodeRef} style={style} {...listeners} {...attributes}>
{props.children}
</button>
)
}
export default Draggable