React components for Shopify's draggable
$ yarn add draggable-reactThis library is still a work in progress. Currently, we expose 3 APIs:
- A
DraggableProvidercomponent - A
DraggableContainercomponent - A
withDraggablehigher-order component
To start off, we can use the containerized variant of the DraggableProvider,
which automatically creates a default DraggableContainer around our app.
Simply replace your main <App /> component with some thing like this:
<DraggableProvider containerized>
<App />
</DraggableProvider> Next, wrap whichever components you wish to make draggable with the HOC,
then consume the draggable prop and use its className. For example:
const DraggableDiv = withDraggable()(({draggable, children}) => (
<div className={draggable.className}>
{children}
</div>
));If you want the supplied prop to have a name other than draggable, you can specify that in the options. For example:
const DraggableDiv = withDraggable({prop: 'drag'})(({drag, children}) => (
<div className={drag.className}>
{children}
</div>
));Check out our Contributing Guidelines
MIT, see LICENSE.md for details.