Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/frinyvonnick/dragrid

Simple grid with dragging feature for React
https://github.com/frinyvonnick/dragrid

component drag-and-drop easy-to-use frontend javascript react simple ui

Last synced: 23 days ago
JSON representation

Simple grid with dragging feature for React

Awesome Lists containing this project

README

        

![Logo of Dragrid](https://raw.githubusercontent.com/frinyvonnick/dragrid/master/misc/logo.png)

# Dragrid

Simple grid with dragging feature for React

![Demonstration of dragrid](https://raw.githubusercontent.com/frinyvonnick/dragrid/master/misc/demo.gif)

## Install

using yarn:
```bash
yarn add dragrid
```

using npm:
```bash
npm install dragrid
```

## Usage

```jsx
import React, { Component } from 'react'
import { Grid } from 'dragrid'

class Example extends Component {
state = {
data: [1, 2, 3, 4, 5, 6],
}

render() {
return (

{element}
)}
onDrop={(elementIndex, targetIndex) => {
const copy = [...this.state.data]
const element = copy.splice(elementIndex, 1)
copy.splice(targetIndex, 0, element)
this.setState({ data: copy })
}}
/>
)
}
}
```

Dragrid uses storybook for development purpose you can also check out stories for a more concrete example.

```bash
npm install
npm run storybook
```