0.0.1-alpha.5 • Published 5 years ago

dragrid v0.0.1-alpha.5

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
5 years ago

Logo of Dragrid

Dragrid

Simple grid with dragging feature for React

Demonstration of dragrid

Install

using yarn:

yarn add dragrid

using npm:

npm install dragrid

Usage

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

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

  render() {
    return (
      <Grid
        elements={this.state.data}
        renderElement={(element => <div>{element}</div>)}
        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.

npm install
npm run storybook